blob: 9fa7ee588a08438570ba1cbe926e4294f3411e1c [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 :is(selectorList) for querySelector and style.');
function testValidSelector(selectorString, expectedSerializedSelector) {
shouldNotThrow('document.querySelector(":is(' + selectorString.replace(/\\/g, '\\\\') + ')")');
var styleContainer = document.getElementById('style-container');
styleContainer.innerHTML = ':is(' + selectorString + ') { }';
shouldBe("document.getElementById('style-container').sheet.cssRules.length", "1");
if (!expectedSerializedSelector)
expectedSerializedSelector = selectorString;
shouldBeEqualToString("document.getElementById('style-container').sheet.cssRules[0].selectorText", ':is(' + expectedSerializedSelector + ')');
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)",
":nth-child(2n of a, b, c)",
];
debug("1 valid selectors");
for (var i = 0; i < validSelectors.length; ++i) {
var selectorString = validSelectors[i];
testValidSelector(selectorString);
testValidSelector(selectorString + " ", selectorString);
}
</script>
<script src="../../resources/js-test-post.js"></script>
</html>