benjamin@webkit.org | 075b402 | 2015-02-03 04:11:42 +0000 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <script src="../../resources/js-test-pre.js"></script> |
| 5 | <style> |
| 6 | li+li+:nth-last-child(-5n+14)+li+li+li~li+li+li~li { |
| 7 | color:rgb(4, 5, 6); |
| 8 | } |
| 9 | ul>[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 | } |
| 12 | ul>: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 | |
| 45 | description('Test nth-last-child inside deep backtracking.'); |
| 46 | |
| 47 | // nth-last-child inside two adjacent backtracking chains. |
| 48 | shouldBe('document.querySelectorAll("li+li+:nth-last-child(-5n+14)+li+li+li~li+li+li~li").length', '7'); |
| 49 | var allItems = document.querySelectorAll('li'); |
| 50 | shouldBe('allItems.length', '20'); |
| 51 | var coloredItems = 0; |
| 52 | for (var i = 0; i < allItems.length; ++i) { |
| 53 | if (getComputedStyle(allItems[i]).color === 'rgb(4, 5, 6)') |
| 54 | coloredItems++; |
| 55 | } |
| 56 | shouldBe('coloredItems', '7'); |
| 57 | |
| 58 | // nth-last-child inside two adjacent backtracking chains, inside one descendant backtracking chain. |
| 59 | shouldBe('document.querySelectorAll("ul>[foo=bar]:nth-last-child(-3n+18)+li+li+li~li+li+li~li>span.first>span.second a").length', '11'); |
| 60 | var allLinks = document.querySelectorAll('a'); |
| 61 | shouldBe('allLinks.length', '20'); |
| 62 | var backgroundColoredCount = 0; |
| 63 | var nonOpaqueCount = 0; |
| 64 | for (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 | } |
| 71 | shouldBe('backgroundColoredCount', '11'); |
| 72 | |
| 73 | shouldBe('document.querySelectorAll("ul>:nth-last-child(-3n+3)>*>* a").length', '1'); |
| 74 | shouldBe('nonOpaqueCount', '1'); |
| 75 | </script> |
| 76 | <script src="../../resources/js-test-post.js"></script> |
| 77 | </html> |