summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css/nth-child-negative-a-param.html
blob: 752b03136466bb964b257b1b8e33f7f95082313d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!doctype html>
<html>
<head>
<title>Test for Bug 31267 - :nth-child(-2n) should match no element</title>
<style>
li {
    color:green;
}
li:nth-child(-1n) {
    color:red;
}
li:nth-child(-2n) {
    color:red;
}
</style>
<script>
if (window.testRunner)
    testRunner.dumpAsText();

function test()
{
    var success = true;
    for (var a_param = -1; a_param >= -2; a_param--) {
        var nth_child = "li:nth-child(" + a_param + "n)";
        var elements = document.querySelectorAll(nth_child);
        if (elements.length != 0) {
            success = false;
            for (var i = 0; i < elements.length; i++)
                elements[i].innerHTML = "FAIL: " + nth_child + " must not match any elements.";
        }
    }

    var message = "FAIL";
    var color = "red";
    if (success) {
        message = "PASS";
        color = "green";
    }
    var result = document.getElementById("result");
    result.innerHTML = message;
    result.style.color = color;
}
</script>
<body onload="test()">
<ol>
<li>This must be green because li:nth-child(-an) must not match any elements.</li>
<li>This must be green because li:nth-child(-an) must not match any elements.</li>
<li>This must be green because li:nth-child(-an) must not match any elements.</li>
<li>This must be green because li:nth-child(-an) must not match any elements.</li>
</ol>
<div id="result">
Test didn't run
</div>
</body>
</html>