blob: c87e3b8778a18cad2538f0b3d5e6b8cb8a10d8af [file] [log] [blame]
benjamin@webkit.org075b4022015-02-03 04:11:42 +00001<!doctype html>
2<html>
3<head>
4<script src="../../resources/js-test-pre.js"></script>
5<style>
6li+li+:nth-last-child(-5n+14)+li+li+li~li+li+li~li {
7 color:rgb(4, 5, 6);
8}
9ul>[foo=bar]:nth-last-child(-3n+18)+li+li+li~li+li+li~li>span.first>span.second a {
10 background-color:rgb(1,2,3);
11}
12ul>:nth-last-child(-3n+3)>*>* a {
13 opacity: 0.5;
14}
15</style>
16</head>
17<body>
18<div>
19 <ul style="display:none">
20 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
21 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
22 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
23 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
24 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
25 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
26 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
27 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
28 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
29 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
30 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
31 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
32 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
33 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
34 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
35 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
36 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
37 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
38 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
39 <li foo=bar><span class="first"><span class="second"><span><a href="http://www.webkit.org">WebKit!</a></span></span></span></li>
40 </ul>
41</div>
42</body>
43<script>
44
45description('Test nth-last-child inside deep backtracking.');
46
47// nth-last-child inside two adjacent backtracking chains.
48shouldBe('document.querySelectorAll("li+li+:nth-last-child(-5n+14)+li+li+li~li+li+li~li").length', '7');
49var allItems = document.querySelectorAll('li');
50shouldBe('allItems.length', '20');
51var coloredItems = 0;
52for (var i = 0; i < allItems.length; ++i) {
53 if (getComputedStyle(allItems[i]).color === 'rgb(4, 5, 6)')
54 coloredItems++;
55}
56shouldBe('coloredItems', '7');
57
58// nth-last-child inside two adjacent backtracking chains, inside one descendant backtracking chain.
59shouldBe('document.querySelectorAll("ul>[foo=bar]:nth-last-child(-3n+18)+li+li+li~li+li+li~li>span.first>span.second a").length', '11');
60var allLinks = document.querySelectorAll('a');
61shouldBe('allLinks.length', '20');
62var backgroundColoredCount = 0;
63var nonOpaqueCount = 0;
64for (var i = 0; i < allLinks.length; ++i) {
65 var computedStyle = getComputedStyle(allLinks[i]);
66 if (computedStyle.backgroundColor === 'rgb(1, 2, 3)')
67 backgroundColoredCount++;
68 if (computedStyle.opacity === '0.5')
69 ++nonOpaqueCount;
70}
71shouldBe('backgroundColoredCount', '11');
72
73shouldBe('document.querySelectorAll("ul>:nth-last-child(-3n+3)>*>* a").length', '1');
74shouldBe('nonOpaqueCount', '1');
75</script>
76<script src="../../resources/js-test-post.js"></script>
77</html>