blob: c4edf8b1e4144a1e22d097fdb28d0d89f923378a [file] [log] [blame]
<!doctype html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<style id="style-target"></style>
</head>
<body>
<script>
description('Verify the never generates a valid selector for an invalid functional pseudo class.');
function invalidRules(functonalPseudoClassName) {
return [':' + functonalPseudoClassName + '\\',
':' + functonalPseudoClassName + '\\\\',
':' + functonalPseudoClassName + '\\\\\\',
':' + functonalPseudoClassName + '\\\\\\\\',
':' + functonalPseudoClassName + '\\(',
':' + functonalPseudoClassName + '\\\\(',
':' + functonalPseudoClassName + '\\\\\\(',
':' + functonalPseudoClassName + '\\\\\\\\(',
':' + functonalPseudoClassName + '\\ .foo',
':' + functonalPseudoClassName + '\\\\ .foo',
':' + functonalPseudoClassName + '\\\\\\ .foo',
':' + functonalPseudoClassName + '\\\\\\\\ .foo',
':' + functonalPseudoClassName + '\\\\( .foo',
':' + functonalPseudoClassName + '\\\\\\( .foo',
':' + functonalPseudoClassName + '\\\\\\\\( .foo',
':' + functonalPseudoClassName + '\\()',
':' + functonalPseudoClassName + '\\\\()',
':' + functonalPseudoClassName + '\\\\\\()',
':' + functonalPseudoClassName + '\\\\\\\\()',
':' + functonalPseudoClassName + '\\ .foo)',
':' + functonalPseudoClassName + '\\\\ .foo)',
':' + functonalPseudoClassName + '\\\\\\ .foo)',
':' + functonalPseudoClassName + '\\\\\\\\ .foo)',
':' + functonalPseudoClassName + '\\\\( .foo)',
':' + functonalPseudoClassName + '\\\\\\( .foo)',
':' + functonalPseudoClassName + '\\\\\\\\( .foo)'];
}
function testQuerySelector(functonalPseudoClassName) {
for (var testCase of invalidRules(functonalPseudoClassName)) {
if (testCase == ':-webkit-any\\()' || testCase == ':-webkit-any\\(') {
shouldNotThrow('document.querySelectorAll("' + testCase + '").length');
continue;
}
shouldThrow('document.querySelectorAll("' + testCase + '").length');
}
}
function testStyling(functonalPseudoClassName) {
var styleElement = document.getElementById("style-target");
for (var testCase of invalidRules(functonalPseudoClassName)) {
styleElement.textContent = testCase + " { background-color: red; }";
shouldBe("document.styleSheets[1].cssRules.length", "0");
}
styleElement.textContent = "";
}
function test(functonalPseudoClassName) {
testQuerySelector(functonalPseudoClassName);
testStyling(functonalPseudoClassName);
}
var functionalPseudoClasses = [
"-webkit-any",
"dir",
"lang",
"not",
"nth-child",
"nth-last-child",
"nth-last-of-type",
"nth-of-type",
"role",
];
for (var functionalPseudoClass of functionalPseudoClasses)
test(functionalPseudoClass);
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>