87 lines
5.0 KiB
HTML
87 lines
5.0 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
<style>
|
|
#test-root * {
|
|
background-color: red;
|
|
}
|
|
</style>
|
|
<style id="style">
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div style="display:none" id="test-root">
|
|
<testcaseA id="testcase1" attribute1="value1" class="bar baz bazoo" attribute3="value3">Not empty</testcaseA>
|
|
<testcaseB id="testcase2" class="bar baz bazoo" attribute2="value2" attribute3="value3"></testcaseB>
|
|
<testcaseA id="testcase3" attribute1="value1" class="foo baz bazoo">Not empty</testcaseA>
|
|
<testcaseB id="testcase4" attribute1="value1" class="foo bar bazoo">Not empty</testcaseB>
|
|
<testcaseA id="testcase5" class="foo baz bazoo" attribute2="value2" attribute3="value3">Not empty</testcaseA>
|
|
<testcaseB id="testcase6" attribute1="value1" class="foo bar baz" attribute3="value3">Not empty</testcaseB>
|
|
<testcaseA id="testcase7" attribute1="value1" class="bar baz bazoo">Not empty</testcaseA>
|
|
<testcaseB id="testcase8" attribute1="value1" class="foo baz bazoo">Not empty</testcaseB>
|
|
<testcaseA id="testcase9" class="foo bar bazoo" attribute2="value2" attribute3="value3"></testcaseA>
|
|
<testcaseB id="testcase10" attribute1="value1" class="foo bar bazoo" attribute3="value3">Not empty</testcaseB>
|
|
</div>
|
|
</body>
|
|
<script>
|
|
description('Check the basic features of the ":not(selectorList)" pseudo class.');
|
|
|
|
function testQuerySelector(selector, expectedIds) {
|
|
shouldBe("document.querySelectorAll('" + selector + "').length", '' + expectedIds.length);
|
|
for (var i = 0; i < expectedIds.length; ++i)
|
|
shouldBeEqualToString("document.querySelectorAll('" + selector + "')[" + i + "].id", expectedIds[i]);
|
|
}
|
|
|
|
function testStyling(selector, expectedIds) {
|
|
var stylingElement = document.getElementById("style");
|
|
stylingElement.innerHTML = '' + selector + ' { background-color: rgb(10, 100, 200); }';
|
|
|
|
var allTestCases = document.querySelectorAll("#test-root *");
|
|
for (var i = 0; i < allTestCases.length; ++i) {
|
|
var expectMatch = expectedIds.indexOf(allTestCases[i].id) >= 0;
|
|
shouldBeEqualToString('getComputedStyle(document.querySelectorAll("#test-root *")[' + i + ']).backgroundColor', expectMatch ? 'rgb(10, 100, 200)' : 'rgb(255, 0, 0)');
|
|
}
|
|
|
|
stylingElement.innerHTML = '';
|
|
}
|
|
|
|
function testSelector(selector, expectedIds) {
|
|
debug("Testing \"" + selector + "\"");
|
|
testQuerySelector("#test-root " + selector, expectedIds);
|
|
testStyling("#test-root " + selector, expectedIds);
|
|
debug("");
|
|
}
|
|
|
|
// Simple selectors.
|
|
testSelector(":not(testcaseA)", ["testcase2", "testcase4", "testcase6", "testcase8", "testcase10"]);
|
|
testSelector(":not(.bar)", ["testcase3", "testcase5", "testcase8"]);
|
|
testSelector(":not([attribute1])", ["testcase2", "testcase5", "testcase9"]);
|
|
testSelector(":not([attribute1=value1])", ["testcase2", "testcase5", "testcase9"]);
|
|
testSelector("[attribute1]:not([attribute1=value1])", []);
|
|
testSelector(":not(#testcase3)", ["testcase1", "testcase2", "testcase4", "testcase5", "testcase6", "testcase7", "testcase8", "testcase9", "testcase10"]);
|
|
testSelector(":not(:empty)", ["testcase1", "testcase3", "testcase4", "testcase5", "testcase6", "testcase7", "testcase8", "testcase10"]);
|
|
|
|
// Compound selectors.
|
|
testSelector(":not(testcaseB.bar)", ["testcase1", "testcase3", "testcase5", "testcase7", "testcase8", "testcase9"]);
|
|
testSelector(":not(.baz.foo.bar)", ["testcase1", "testcase2", "testcase3", "testcase4", "testcase5", "testcase7", "testcase8", "testcase9", "testcase10"]);
|
|
testSelector(":not([id][class])", []);
|
|
testSelector(":not(testcaseA[attribute1^=value])", ["testcase2", "testcase4", "testcase5", "testcase6", "testcase8", "testcase9", "testcase10"]);
|
|
testSelector(":not(.foo:empty)", ["testcase1", "testcase2", "testcase3", "testcase4", "testcase5", "testcase6", "testcase7", "testcase8", "testcase10"]);
|
|
|
|
// Complex selectors.
|
|
testSelector(":not(html>body testcaseB.bar)", ["testcase1", "testcase3", "testcase5", "testcase7", "testcase8", "testcase9"]);
|
|
testSelector(":not(html body div .baz.foo.bar)", ["testcase1", "testcase2", "testcase3", "testcase4", "testcase5", "testcase7", "testcase8", "testcase9", "testcase10"]);
|
|
testSelector(":not(html body > div [id][class])", []);
|
|
testSelector(":not(:root div>testcaseA[attribute1^=value])", ["testcase2", "testcase4", "testcase5", "testcase6", "testcase8", "testcase9", "testcase10"]);
|
|
testSelector(":not(body>div .foo:empty)", ["testcase1", "testcase2", "testcase3", "testcase4", "testcase5", "testcase6", "testcase7", "testcase8", "testcase10"]);
|
|
|
|
testSelector(":not(testcaseB + *)", ["testcase1", "testcase2", "testcase4", "testcase6", "testcase8", "testcase10"]);
|
|
testSelector(":not(:root body>div testcaseB + *)", ["testcase1", "testcase2", "testcase4", "testcase6", "testcase8", "testcase10"]);
|
|
testSelector(":not(testcaseA ~ *)", ["testcase1"]);
|
|
testSelector(":not(testcaseA + testcaseB ~ testcaseB)", ["testcase1", "testcase2", "testcase3", "testcase5", "testcase7", "testcase9"]);
|
|
|
|
</script>
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</html>
|