100 lines
2.1 KiB
HTML
100 lines
2.1 KiB
HTML
<!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 validSelectors = [
|
|
// Basic types.
|
|
"*",
|
|
"foobar",
|
|
"#id",
|
|
".class",
|
|
":first-child",
|
|
":last-child",
|
|
":visited",
|
|
|
|
// Compound selectors.
|
|
"foobar#id.class",
|
|
".class:not(.notclass)",
|
|
"#id:empty",
|
|
|
|
// Complex selectors.
|
|
"a > b",
|
|
"a b",
|
|
"a + b",
|
|
"a ~ b",
|
|
"a + b > c ~ d e + g",
|
|
|
|
// Functional pseudo classes.
|
|
":-webkit-any(.selector,#tama,#hanayo,#midoriko)",
|
|
":not(:link)",
|
|
":not(:is(cocoa, cappuccino))",
|
|
":not(:matches(cocoa, cappuccino))",
|
|
":nth-child(even of a, b, c)",
|
|
];
|
|
|
|
var invalidSelectors = [
|
|
// Pseudo elements.
|
|
"::first-letter",
|
|
"::first-line",
|
|
"::before",
|
|
"::after",
|
|
":first-letter",
|
|
":first-line",
|
|
":before",
|
|
":after",
|
|
|
|
// Not selectors.
|
|
"",
|
|
" ",
|
|
",",
|
|
|
|
".123class",
|
|
"#123id",
|
|
"[]",
|
|
"()",
|
|
")",
|
|
"{}",
|
|
"}",
|
|
|
|
// Empty functional pseudo classes.
|
|
":not()",
|
|
":is()",
|
|
":matches()",
|
|
":nth-child()",
|
|
":nth-child(2n of)",
|
|
|
|
// Unbalanced parenthesized functional pseudo classes.
|
|
":not(",
|
|
":is(",
|
|
":matches(",
|
|
":nth-child(2n+1 of",
|
|
];
|
|
|
|
debug("2 :not(valid, invalid) selectors");
|
|
for (var i = 0; i < validSelectors.length; ++i) {
|
|
for (var j = 0; j < invalidSelectors.length; ++j) {
|
|
var selectorString = validSelectors[i] + ',' + invalidSelectors[j];
|
|
testInvalidSelector(selectorString);
|
|
}
|
|
}
|
|
|
|
</script>
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</html>
|