blob: 1a4e9bde28e4b9b37eb9319715164090b64bdf75 [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 :matches(selectorList) for querySelector and style.');
function testValidSelector(selectorString, expectedSerializedSelector) {
shouldNotThrow('document.querySelector(":matches(' + selectorString.replace(/\\/g, '\\\\') + ')")');
var styleContainer = document.getElementById('style-container');
styleContainer.innerHTML = ':matches(' + selectorString + ') { }';
shouldBe("document.getElementById('style-container').sheet.cssRules.length", "1");
if (!expectedSerializedSelector)
expectedSerializedSelector = selectorString;
shouldBeEqualToString("document.getElementById('style-container').sheet.cssRules[0].selectorText", ':matches(' + expectedSerializedSelector + ')');
styleContainer.innerHTML = '';
}
debug("3 valid selectors");
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)",
];
/* Try all combinations, each value is unique to the others. */
for (var i = 0; i < validSelectorsPart1.length; ++i) {
for (var j = i; j < validSelectorsPart1.length; ++j) {
for (var k = j; k < validSelectorsPart1.length; ++k) {
var selectorString = validSelectorsPart1[i] + ', ' + validSelectorsPart1[j] + ', ' + validSelectorsPart1[k];
testValidSelector(selectorString);
testValidSelector(selectorString + " ", selectorString);
}
}
}
</script>
<script src="../../resources/js-test-post.js"></script>
</html>