212 lines
11 KiB
HTML
212 lines
11 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">
|
|
<aa>
|
|
<aa>
|
|
<aa>
|
|
<bb>
|
|
<aa>
|
|
<aa>
|
|
<bb>
|
|
<cc></cc>
|
|
<cc></cc>
|
|
<cc></cc>
|
|
<cc></cc>
|
|
<dd></dd>
|
|
<cc></cc>
|
|
<cc></cc>
|
|
<cc></cc>
|
|
<dd></dd>
|
|
<cc></cc>
|
|
<cc></cc>
|
|
<dd></dd>
|
|
<cc></cc>
|
|
<dd></dd>
|
|
<testcase id="testcase1">
|
|
<ee>
|
|
<ee>
|
|
<ee>
|
|
<ff>
|
|
<ee>
|
|
<ee>
|
|
<ff>
|
|
<gg>
|
|
<testcase id="testcase2"></testcase>
|
|
</gg>
|
|
</ff>
|
|
</ee>
|
|
</ee>
|
|
</ff>
|
|
</ee>
|
|
</ee>
|
|
</ee>
|
|
</testcase>
|
|
</bb>
|
|
</aa>
|
|
</aa>
|
|
</bb>
|
|
</aa>
|
|
</aa>
|
|
</aa>
|
|
<bb>
|
|
<aa>
|
|
<aa>
|
|
<bb>
|
|
<aa>
|
|
<aa>
|
|
<bb>
|
|
<dd></dd>
|
|
<dd></dd>
|
|
<dd></dd>
|
|
<cc></cc>
|
|
<dd></dd>
|
|
<dd></dd>
|
|
<dd></dd>
|
|
<cc></cc>
|
|
<dd></dd>
|
|
<dd></dd>
|
|
<cc></cc>
|
|
<dd></dd>
|
|
<cc></cc>
|
|
<testcase id="testcase3">
|
|
<ee>
|
|
<ee>
|
|
<ff>
|
|
<ee>
|
|
<ee>
|
|
<ff>
|
|
<gg>
|
|
<testcase id="testcase4"></testcase>
|
|
</gg>
|
|
</ff>
|
|
</ee>
|
|
</ee>
|
|
</ff>
|
|
</ee>
|
|
</ee>
|
|
</testcase>
|
|
</bb>
|
|
</aa>
|
|
</aa>
|
|
</bb>
|
|
</aa>
|
|
</aa>
|
|
</bb>
|
|
</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("");
|
|
}
|
|
|
|
// Internal backtracking, backtracking inside :not().
|
|
testSelector("testcase:not(bb > aa > aa > bb testcase)", []);
|
|
testSelector("testcase:not(bb > aa > aa > bb > aa testcase)", ["testcase1", "testcase2"]);
|
|
testSelector("testcase:not(bb > * > aa > bb > aa testcase)", ["testcase1", "testcase2"]);
|
|
testSelector("testcase:not(bb > aa > * > bb > aa testcase)", ["testcase1", "testcase2"]);
|
|
testSelector("testcase:not(bb > * > * > bb > aa testcase)", ["testcase1", "testcase2"]);
|
|
testSelector("testcase:not(* > * > * > bb > aa testcase)", []);
|
|
|
|
testSelector("testcase:not(aa > aa > aa > bb testcase)", ["testcase3", "testcase4"]);
|
|
testSelector("testcase:not(aa > aa > * > bb testcase)", ["testcase3", "testcase4"]);
|
|
testSelector("testcase:not(aa > * > * > bb testcase)", ["testcase3", "testcase4"]);
|
|
testSelector("testcase:not(aa > aa > aa > * testcase)", ["testcase3", "testcase4"]);
|
|
|
|
testSelector("testcase:not(aa > * > * > * testcase)", []);
|
|
testSelector("testcase:not(* > * > * > bb testcase)", []);
|
|
testSelector("testcase:not(* > * > * > * testcase)", []);
|
|
|
|
testSelector("testcase:not(dd + dd + cc + dd ~ testcase)", ["testcase1", "testcase2", "testcase4"]);
|
|
testSelector("testcase:not(dd + dd + cc + * ~ testcase)", ["testcase1", "testcase2", "testcase4"]);
|
|
testSelector("testcase:not(dd + dd + * + dd ~ testcase)", ["testcase1", "testcase2", "testcase4"]);
|
|
testSelector("testcase:not(dd + dd + * + * ~ testcase)", ["testcase1", "testcase2", "testcase4"]);
|
|
testSelector("testcase:not(dd + * + cc + dd ~ testcase)", ["testcase2", "testcase4"]);
|
|
testSelector("testcase:not(* + dd + cc + dd ~ testcase)", ["testcase2", "testcase4"]);
|
|
testSelector("testcase:not(* + * + cc + dd ~ testcase)", ["testcase2", "testcase4"]);
|
|
|
|
testSelector("testcase:not(cc + cc + cc + cc + dd ~ testcase)", ["testcase2", "testcase3", "testcase4"]);
|
|
testSelector("testcase:not(cc + cc + cc + cc + * ~ testcase)", ["testcase2", "testcase3", "testcase4"]);
|
|
testSelector("testcase:not(cc + cc + cc + * + dd ~ testcase)", ["testcase2", "testcase3", "testcase4"]);
|
|
testSelector("testcase:not(cc + cc + cc + * + * ~ testcase)", ["testcase2", "testcase3", "testcase4"]);
|
|
testSelector("testcase:not(cc + cc + * + * + * ~ testcase)", ["testcase2", "testcase3", "testcase4"]);
|
|
testSelector("testcase:not(cc + * + * + * + * ~ testcase)", ["testcase2", "testcase4"]);
|
|
testSelector("testcase:not(* + cc + * + * + * ~ testcase)", ["testcase2", "testcase4"]);
|
|
testSelector("testcase:not(* + * + * + * + * ~ testcase)", ["testcase2", "testcase4"]);
|
|
|
|
// External backtracking, backtracking outside :not().
|
|
testSelector(":not(ee) > ee > ee > ee > ff testcase", ["testcase2"]);
|
|
testSelector(":not(ee, foo, bar, baz) > ee > ee > ee > ff testcase", ["testcase2"]);
|
|
|
|
testSelector(":not(ee) > ee > * > ee > ff testcase", ["testcase2"]);
|
|
testSelector(":not(ee, foo, bar, baz) > ee > * > ee > ff testcase", ["testcase2"]);
|
|
|
|
testSelector(":not(ee) > ee > ee > * > ff testcase", ["testcase2"]);
|
|
testSelector(":not(ee, foo, bar, baz) > ee > ee > * > ff testcase", ["testcase2"]);
|
|
|
|
testSelector(":not(ee) > * > ee > ee > ff testcase", ["testcase2", "testcase4"]);
|
|
testSelector(":not(ee, foo, bar, baz) > * > ee > ee > ff testcase", ["testcase2", "testcase4"]);
|
|
|
|
testSelector(":not(ee) > * > * > ee > ff testcase", ["testcase2", "testcase4"]);
|
|
testSelector(":not(ee, foo, bar, baz) > * > * > ee > ff testcase", ["testcase2", "testcase4"]);
|
|
|
|
testSelector(":not(ee) > * > * > ee > * testcase", ["testcase2", "testcase4"]);
|
|
testSelector(":not(ee, foo, bar, baz) > * > * > ee > * testcase", ["testcase2", "testcase4"]);
|
|
|
|
testSelector(":not(ee) > * > * > * > * testcase", ["testcase1", "testcase2", "testcase3", "testcase4"]);
|
|
testSelector(":not(ee, foo, bar, baz) > * > * > * > * testcase", ["testcase1", "testcase2", "testcase3", "testcase4"]);
|
|
|
|
// Both external and internal backtracking.
|
|
testSelector(":not(bb > * > * > bb > aa testcase, foo, bar, baz) > ee > ee > ee > ff testcase", ["testcase2"]);
|
|
testSelector(":not(bb > * > * > bb > aa testcase, foo, bar, baz) > ee > * > ee > ff testcase", ["testcase2"]);
|
|
testSelector(":not(bb > * > * > bb > aa testcase, foo, bar, baz) > ee > ee > * > ff testcase", ["testcase2"]);
|
|
|
|
testSelector(":not(bb > * > * > bb > aa * + * + cc + dd ~ testcase, foo, bar, baz) > ee > ee > ee > ff testcase", ["testcase2"]);
|
|
testSelector(":not(bb > * > * > bb > aa * + * + cc + dd ~ testcase, foo, bar, baz) > ee > * > ee > ff testcase", ["testcase2"]);
|
|
testSelector(":not(bb > * > * > bb > aa * + * + cc + dd ~ testcase, foo, bar, baz) > ee > ee > * > ff testcase", ["testcase2"]);
|
|
|
|
testSelector(":not(bb > * > * > bb > aa dd + dd + * + * ~ testcase, foo, bar, baz) > ee > ee > ee > ff testcase", ["testcase2"]);
|
|
testSelector(":not(bb > * > * > bb > aa dd + dd + * + * ~ testcase, foo, bar, baz) > ee > * > ee > ff testcase", ["testcase2"]);
|
|
testSelector(":not(bb > * > * > bb > aa dd + dd + * + * ~ testcase, foo, bar, baz) > ee > ee > * > ff testcase", ["testcase2"]);
|
|
|
|
testSelector(":not(* > * > * > * testcase, foo, bar, baz) > * > * > * > * testcase", ["testcase1", "testcase2", "testcase3", "testcase4"]);
|
|
testSelector(":not(* > * > * > bb testcase, foo, bar, baz) > * > * > * > * testcase", ["testcase1", "testcase2", "testcase3", "testcase4"]);
|
|
testSelector("bb > :not(* > * > * > * testcase, foo, bar, baz) > * > * > * > * testcase", ["testcase2", "testcase3", "testcase4"]);
|
|
</script>
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</html>
|