blob: 470b44fe7db88a54fce8178a1e2c578d43b9ce77 [file] [log] [blame]
<!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 testInvalidSelector(selectorString) {
var styleContainer = document.getElementById('style-container');
styleContainer.innerHTML = ':not(' + selectorString + ') { }';
const parsed = document.getElementById('style-container').sheet.cssRules.length == 1;
debug(`selector '${styleContainer.innerHTML}' parsed: ${parsed ? "YES" : "NO"}`);
styleContainer.innerHTML = '';
}
var validSelectorsPart1 = [
// Basic types.
"*",
"#id",
":first-child",
":visited",
// Compound selectors.
".class:not(.notclass)",
// Complex selectors.
"a > b",
"a + b",
"a + b > c ~ d e + g",
// Functional pseudo classes.
":not(:link)",
":not(:is(cocoa, cappuccino))",
":not(:matches(cocoa, cappuccino))",
];
var invalidSelectors = [
// Pseudo elements.
"::first-letter",
"::first-line",
"::before",
"::after",
// Not selectors.
"",
" ",
",",
".123class",
"#123id",
"[]",
"()",
")",
"{}",
"}",
// Unbalanced parenthesized functional pseudo classes.
":not(",
":is(",
":matches(",
":nth-child(2n+1 of",
];
debug("3 :not(valid, valid, invalid) selectors");
for (var i = 0; i < validSelectorsPart1.length; ++i) {
for (var j = i; j < validSelectorsPart1.length; ++j) {
for (var k = 0; k < invalidSelectors.length; ++k) {
var selectorString = validSelectorsPart1[i] + ',' + validSelectorsPart1[j] + ',' + invalidSelectors[k];
testInvalidSelector(selectorString);
}
}
}
</script>
<script src="../../resources/js-test-post.js"></script>
</html>