2 <script src=
"../../resources/js-test.js"></script>
4 <div id=
"sandbox"></div>
7 description("Should update distribution when needed for querySelector and related methods.");
11 var sandbox
= document
.getElementById("sandbox");
13 sandbox
.innerHTML
= "<div id=host><div id=a><div id=b></div></div>";
14 host
= document
.getElementById("host");
15 hostRoot
= host
.createShadowRoot();
16 hostRoot
.innerHTML
= "<div id=c><content></content></div>";
18 a
= document
.getElementById("a");
19 b
= document
.getElementById("b");
21 aRoot
= a
.createShadowRoot();
22 aRoot
.innerHTML
= "<div id=d><div id=e></div></div>";
24 c
= hostRoot
.getElementById("c");
25 d
= aRoot
.getElementById("d");
26 e
= aRoot
.getElementById("e");
28 sandbox
.appendChild(host
);
32 sandbox
.innerHTML
= "";
35 function toArray(list
)
37 return Array
.prototype.slice
.call(list
);
41 shouldBe("aRoot.querySelector(':host-context(#c) #d')", "d");
44 shouldBe("toArray(aRoot.querySelectorAll(':host-context(#c) #d'))", "[d]");
47 shouldBeNull("hostRoot.querySelector('::content #a')");
50 shouldBe("toArray(hostRoot.querySelectorAll('::content #a'))", "[]");
53 shouldBeFalse("a.matches('::content #a')");
56 shouldBeTrue("d.matches(':host-context(#host) #d')");
59 shouldBeTrue("d.matches(':host-context(#c) #d')");
62 shouldBeNull("b.closest('::content #a')");
65 shouldBe("e.closest(':host-context(#host) #d')", "d");