summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css/css3-nth-tokens-style.html
blob: bb7c8e8e49b545c47b8995d74df6e47f387a6cd5 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
<style>
span.c1:nth-of-type(2n + 1){ color: red; }
span.c1:nth-of-type(2n - 2){ color: green; }
span.c2:nth-of-type(odd){ color: red; }
span.c2:nth-of-type(even){ color: green; }
span.c3:nth-of-type(n3){ color: red; }
span.c3:nth-of-type(foo){ color: green; }
span.c4:nth-of-type(2n3){ color: red; }
span.c4:nth-of-type(foon + bar ){ color: green; }

</style>

</head>
<body>
<p id="description"></p>
debug("These spans should alternate red and green");
<div id="test1"></div>
debug("These spans should alternate red and green");
<div id="test2"></div>
debug("These spans should be black");
<div id="test3"></div>
debug("These spans should be black");
<div id="test4"></div>
<br>
<script>
var i=1;
for(; i < 5; i++) {
    var str = "";
    var j=1;
    for (; j < 9; j++) {
        str += '<span class="c' + i + '" id="span' + i + j + '"> span </span>';
    }
    document.getElementById("test"+i).innerHTML = str;
}

</script>

<div id="console"></div>
<script>
description('This test passes if the nth-of-type can accept a parameter that is an+b, odd or even. But it does not accept any other parameter.');



el = document.getElementById("span11");
shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('color')", "'rgb(255, 0, 0)'");

el = document.getElementById("span12");
shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('color')", "'rgb(0, 128, 0)'");

el = document.getElementById("span21");
shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('color')", "'rgb(255, 0, 0)'");

el = document.getElementById("span22");
shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('color')", "'rgb(0, 128, 0)'");

el = document.getElementById("span31");
shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('color')", "'rgb(0, 0, 0)'");

el = document.getElementById("span32");
shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('color')", "'rgb(0, 0, 0)'");

el = document.getElementById("span41");
shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('color')", "'rgb(0, 0, 0)'");

el = document.getElementById("span42");
shouldBe("document.defaultView.getComputedStyle(el, null).getPropertyValue('color')", "'rgb(0, 0, 0)'");
</script>
</body>
</html>