mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Added ParentNode's querySelectorAll content tests
This commit is contained in:
parent
95dcab66b2
commit
8c017d8830
1 changed files with 59 additions and 0 deletions
59
src/test/content/test_parentNode_querySelectorAll.html
Normal file
59
src/test/content/test_parentNode_querySelectorAll.html
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="harness.js"></script>
|
||||||
|
<script>
|
||||||
|
let foo = document.getElementById("foo");
|
||||||
|
let bar = document.getElementById("bar");
|
||||||
|
let baz = document.getElementById("baz");
|
||||||
|
|
||||||
|
{ // document.querySelector
|
||||||
|
let nodelist = document.querySelectorAll(".test");
|
||||||
|
is_a(nodelist, NodeList);
|
||||||
|
is(nodelist.length, 3);
|
||||||
|
is(nodelist.item(0), foo);
|
||||||
|
is(nodelist.item(1), bar);
|
||||||
|
is(nodelist.item(2), baz);
|
||||||
|
|
||||||
|
nodelist = document.querySelectorAll("div > .test");
|
||||||
|
is(nodelist.length, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // element.querySelector
|
||||||
|
let div = document.getElementById("parent");
|
||||||
|
let nodelist = div.querySelectorAll(".test");
|
||||||
|
is(nodelist.length, 3);
|
||||||
|
|
||||||
|
nodelist = div.querySelectorAll("div:nth-of-type(1)");
|
||||||
|
is(nodelist.item(0), div);
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // docfrag.querySelector
|
||||||
|
let docfrag = document.createDocumentFragment();
|
||||||
|
|
||||||
|
let div = document.createElement("div");
|
||||||
|
div.id = "foo";
|
||||||
|
div.className = "myClass";
|
||||||
|
|
||||||
|
let child = document.createElement("div");
|
||||||
|
div.appendChild(child);
|
||||||
|
docfrag.appendChild(div);
|
||||||
|
|
||||||
|
let nodelist = docfrag.querySelectorAll("#foo");
|
||||||
|
is(nodelist.item(0), div);
|
||||||
|
|
||||||
|
nodelist = docfrag.querySelectorAll("#foo:nth-child(1)");
|
||||||
|
is(nodelist.item(0), div);
|
||||||
|
}
|
||||||
|
|
||||||
|
finish();
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="parent">
|
||||||
|
<div id="foo" class="test"></div>
|
||||||
|
<div id="bar" class="test"></div>
|
||||||
|
<div id="baz" class="test"></div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue