| <!doctype html> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| <style id="style-container"> |
| </style> |
| </head> |
| <body> |
| </body> |
| <script> |
| description('Test the parsing of :not(selectorList) for querySelector and style.'); |
| |
| function testValidSelector(selectorString, expectedSerializedSelector) { |
| shouldNotThrow('document.querySelector(":not(' + selectorString.replace(/\\/g, '\\\\') + ')")'); |
| |
| var styleContainer = document.getElementById('style-container'); |
| styleContainer.innerHTML = ':not(' + selectorString + ') { }'; |
| shouldBe("document.getElementById('style-container').sheet.cssRules.length", "1"); |
| if (!expectedSerializedSelector) |
| expectedSerializedSelector = selectorString; |
| shouldBeEqualToString("document.getElementById('style-container').sheet.cssRules[0].selectorText", ':not(' + expectedSerializedSelector + ')'); |
| styleContainer.innerHTML = ''; |
| } |
| |
| debug("3 valid selectors"); |
| |
| var validSelectorsPart2 = [ |
| // Basic types. |
| "foobar", |
| ".class", |
| ":last-child", |
| |
| // Compound selectors. |
| "foobar#id.class", |
| "#id:empty", |
| |
| // Complex selectors. |
| "a b", |
| "a ~ b", |
| |
| // Functional pseudo classes. |
| ":-webkit-any(.selector, #tama, #hanayo, #midoriko)", |
| ":nth-child(2n of a, b, c)", |
| ]; |
| |
| /* Try all combinations, each value is unique to the others. */ |
| for (var i = 0; i < validSelectorsPart2.length; ++i) { |
| for (var j = i; j < validSelectorsPart2.length; ++j) { |
| for (var k = j; k < validSelectorsPart2.length; ++k) { |
| var selectorString = validSelectorsPart2[i] + ', ' + validSelectorsPart2[j] + ', ' + validSelectorsPart2[k]; |
| testValidSelector(selectorString); |
| testValidSelector(selectorString + " ", selectorString); |
| } |
| } |
| } |
| |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </html> |