<!doctype html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<style>
target {
    background-color: white;
    color: black;
}
:nth-last-child(n of target) {
    background-color: rgb(1, 2, 3);
}
</style>
</head>
<body>
    <div style="display:none" id="test-root">
        <target id="target"></target>
        <script>
            description('The selector :nth-last-child() should fail to match if the following sibling have not been parsed yet.');
            debug("Testing the state in the middle of HTML parsing.")
            shouldBe('document.querySelectorAll(":nth-last-child(n of target)").length', '0');
            shouldBeEqualToString('getComputedStyle(document.getElementById("target")).backgroundColor', 'rgb(255, 255, 255)');
        </script>
        <target></target>
    </div>
</body>
<script>
    debug("Testing the state after parsing the test sub-tree.")
    shouldBe('document.querySelectorAll(":nth-last-child(n of target)").length', '2');
    shouldBeEqualToString('getComputedStyle(document.getElementById("target")).backgroundColor', 'rgb(1, 2, 3)');
</script>
<script src="../../resources/js-test-post.js"></script>
</html>
