Index: third_party/WebKit/LayoutTests/intersection-observer/deleted-root.html |
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/deleted-root.html b/third_party/WebKit/LayoutTests/intersection-observer/deleted-root.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..995b5a753d40116c003ab0e0d3da314d06543a17 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/intersection-observer/deleted-root.html |
@@ -0,0 +1,53 @@ |
+<!DOCTYPE html> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="../resources/gc.js"></script> |
+ |
+<div id="root"></div> |
+<div id="target"></div> |
+ |
+<script> |
+// Initialize observer and remove root in an inner function to avoid |
+// references to rootDiv remaining live on this function's stack frame |
+// (http://crbug.com/595672/). |
+function initializeObserverThenRemoveRootDiv() { |
+ let rootDiv = document.getElementById("root"); |
+ let observer = new IntersectionObserver(c => {}, {root: rootDiv}); |
+ rootDiv.parentNode.removeChild(rootDiv); |
foolip
2017/01/11 13:42:53
You can use rootDiv.remove() if you like.
szager1
2017/01/23 23:18:03
Done.
|
+ return observer; |
+} |
+ |
+var target = document.getElementById("target"); |
+var observer = initializeObserverThenRemoveRootDiv(); |
+gc(); |
+ |
+test(function() { |
+ assert_throws("INVALID_STATE_ERR", function() { |
foolip
2017/01/11 13:42:53
https://wicg.github.io/IntersectionObserver/#dom-i
szager1
2017/01/23 23:18:03
Yeah, there was a separate bug filed about the fac
|
+ observer.observe(target); |
+ }) |
+}, "IntersectionObserver.observe() with a deleted root did not throw."); |
foolip
2017/01/11 13:42:53
A bit of personal preference here, but the "did no
szager1
2017/01/23 23:18:03
Done.
|
+ |
+test(function() { |
+ assert_throws("INVALID_STATE_ERR", function() { |
+ observer.observe(target); |
+ }) |
+}, "IntersectionObserver.observe() with a deleted root did not throw."); |
+ |
+test(function() { |
+ assert_throws("INVALID_STATE_ERR", function() { |
+ observer.unobserve(target); |
+ }) |
+}, "IntersectionObserver.unobserve() with a deleted root did not throw."); |
+ |
+test(function() { |
+ assert_throws("INVALID_STATE_ERR", function() { |
+ observer.disconnect(); |
+ }) |
+}, "IntersectionObserver.disconnect() with a deleted root did not throw."); |
+ |
+test(function() { |
+ assert_throws("INVALID_STATE_ERR", function() { |
+ observer.takeRecords(); |
+ }) |
+}, "IntersectionObserver.takeRecords() with a deleted root did not throw."); |
+</script> |