Index: LayoutTests/fast/selectors/query-update-distribution.html |
diff --git a/LayoutTests/fast/selectors/query-update-distribution.html b/LayoutTests/fast/selectors/query-update-distribution.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1e099cb65d248c06ac4d87b44d08779a5c3443ad |
--- /dev/null |
+++ b/LayoutTests/fast/selectors/query-update-distribution.html |
@@ -0,0 +1,67 @@ |
+<!DOCTYPE html> |
+<script src="../../resources/js-test.js"></script> |
+ |
+<div id="sandbox"></div> |
+ |
+<script> |
+description("Should update distribution when needed for querySelector and related methods."); |
+ |
+function test(fn) |
+{ |
+ var sandbox = document.getElementById("sandbox"); |
+ |
+ sandbox.innerHTML = "<div id=host><div id=a><div id=b></div></div>"; |
+ host = document.getElementById("host"); |
+ hostRoot = host.createShadowRoot(); |
+ hostRoot.innerHTML = "<div id=c><content></content></div>"; |
+ |
+ a = document.getElementById("a"); |
+ b = document.getElementById("a"); |
kochi
2015/05/26 00:59:05
nit: getElementById("b");
?
|
+ |
+ aRoot = a.createShadowRoot(); |
+ aRoot.innerHTML = "<div id=d><div id=e></div></div>"; |
+ |
+ c = hostRoot.getElementById("c"); |
+ d = aRoot.getElementById("d"); |
+ e = aRoot.getElementById("e"); |
+ |
+ sandbox.appendChild(host); |
+ |
+ fn(); |
+ |
+ sandbox.innerHTML = ""; |
+} |
+ |
+function toArray(list) |
+{ |
+ return Array.prototype.slice.call(list); |
+} |
+ |
+test(function() { |
+ shouldBe("aRoot.querySelector(':host-context(#c) #d')", "d"); |
+}); |
+test(function() { |
+ shouldBe("toArray(aRoot.querySelectorAll(':host-context(#c) #d'))", "[d]"); |
+}); |
+test(function() { |
+ shouldBeNull("hostRoot.querySelector('::content #a')"); |
+}); |
+test(function() { |
+ shouldBe("toArray(hostRoot.querySelectorAll('::content #a'))", "[]"); |
+}); |
+test(function() { |
+ shouldBeFalse("a.matches('::content #a')"); |
+}); |
+test(function() { |
+ shouldBeTrue("d.matches(':host-context(#host) #d')"); |
+}); |
+test(function() { |
+ shouldBeTrue("d.matches(':host-context(#c) #d')"); |
+}); |
+test(function() { |
+ shouldBeNull("b.closest('::content #a')"); |
+}); |
+test(function() { |
+ shouldBe("e.closest(':host-context(#host) #d')", "d"); |
+}); |
+</script> |