| <!doctype html> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| <style> |
| body:nth-last-child(n) div:nth-last-child(n) ul:nth-last-child(n) li:nth-last-child(n) span:nth-last-child(n) span:nth-last-child(n) span:nth-last-child(n) span:nth-last-child(n) span:nth-last-child(n) span:nth-last-child(n) { |
| background-color:rgb(1, 2, 3); |
| } |
| body:nth-last-child(n+1) div:nth-last-child(n+1) ul:nth-last-child(n+1) li:nth-last-child(n+1) span:nth-last-child(n+1) span:nth-last-child(n+1) span:nth-last-child(n+1) span:nth-last-child(n+1) span:nth-last-child(n+1) span:nth-last-child(n+1) { |
| color:rgb(4, 5, 6); |
| } |
| </style> |
| <script> |
| window.jsTestIsAsync = true; |
| function test() { |
| description('Verify the nth-last-child() pseudo class does not leak registers.'); |
| |
| shouldBe('document.querySelectorAll("body:nth-last-child(n) div:nth-last-child(n) ul:nth-last-child(n) li:nth-last-child(n) span:nth-last-child(n) span:nth-last-child(n) span:nth-last-child(n) span:nth-last-child(n) span:nth-last-child(n) span:nth-last-child(n)").length', '1'); |
| shouldBeEqualToString('getComputedStyle(document.getElementById("target")).backgroundColor', 'rgb(1, 2, 3)'); |
| shouldBe('document.querySelectorAll("body:nth-last-child(n+1) div:nth-last-child(n+1) ul:nth-last-child(n+1) li:nth-last-child(n+1) span:nth-last-child(n+1) span:nth-last-child(n+1) span:nth-last-child(n+1) span:nth-last-child(n+1) span:nth-last-child(n+1) span:nth-last-child(n+1)").length', '1'); |
| shouldBeEqualToString('getComputedStyle(document.getElementById("target")).color', 'rgb(4, 5, 6)'); |
| |
| shouldBe('document.querySelectorAll("body:nth-last-child(1) div:nth-last-child(1) ul:nth-last-child(1) li:nth-last-child(1) span:nth-last-child(1) span:nth-last-child(1) span:nth-last-child(1) span:nth-last-child(1) span:nth-last-child(1) span:nth-last-child(1)").length', '0'); |
| shouldBe('document.querySelectorAll("body:nth-last-child(2) div:nth-last-child(2) ul:nth-last-child(2) li:nth-last-child(2) span:nth-last-child(2) span:nth-last-child(2) span:nth-last-child(2) span:nth-last-child(2) span:nth-last-child(2) span:nth-last-child(2)").length', '0'); |
| shouldBe('document.querySelectorAll("body:nth-last-child(2n) div:nth-last-child(2n) ul:nth-last-child(2n) li:nth-last-child(2n) span:nth-last-child(2n) span:nth-last-child(2n) span:nth-last-child(2n) span:nth-last-child(2n) span:nth-last-child(2n) span:nth-last-child(2n)").length', '0'); |
| shouldBe('document.querySelectorAll("body:nth-last-child(2n+1) div:nth-last-child(2n+1) ul:nth-last-child(2n+1) li:nth-last-child(2n+1) span:nth-last-child(2n+1) span:nth-last-child(2n+1) span:nth-last-child(2n+1) span:nth-last-child(2n+1) span:nth-last-child(2n+1) span:nth-last-child(2n+1)").length', '0'); |
| finishJSTest(); |
| } |
| window.addEventListener('DOMContentLoaded', test); |
| </script> |
| </head> |
| <body> |
| <div style="display:none"> |
| <ul> |
| <li><span><span><span><span><span><span id=target></span></span></span></span></span></span></li> |
| </ul> |
| </div> |
| </body> |
| <script src="../../resources/js-test-post.js"></script> |
| </html> |