Chromium Code Reviews| 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..a05684dd5fd0615fc9db735600b87372a5e64fd0 |
| --- /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("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')"); |
|
hayato
2015/05/26 02:29:18
This should match, shouldn't this?
rune
2015/05/26 05:26:04
querySelector(All) would traverse descendants of h
|
| +}); |
| +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> |