Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: third_party/WebKit/LayoutTests/intersection-observer/deleted-root.html

Issue 2560253004: IntersectionObserver: convert tests to testharness.js (Closed)
Patch Set: Formatting tweaks and explicit resource paths Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698