<!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("2 valid selectors");
for (var i = 0; i < validSelectors.length; ++i) {
    for (var j = 0; j < validSelectors.length; ++j) {
        var selectorString = validSelectors[i] + ', ' + validSelectors[j];
        testValidSelector(selectorString);
        testValidSelector(selectorString + "    ", selectorString);
    }
}

</script>
<script src="../../resources/js-test-post.js"></script>
</html>
