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

Side by Side 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 3 years, 12 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/gc.js"></script>
5
6 <div id="root"></div>
7 <div id="target"></div>
8
9 <script>
10 // Initialize observer and remove root in an inner function to avoid
11 // references to rootDiv remaining live on this function's stack frame
12 // (http://crbug.com/595672/).
13 function initializeObserverThenRemoveRootDiv() {
14 let rootDiv = document.getElementById("root");
15 let observer = new IntersectionObserver(c => {}, {root: rootDiv});
16 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.
17 return observer;
18 }
19
20 var target = document.getElementById("target");
21 var observer = initializeObserverThenRemoveRootDiv();
22 gc();
23
24 test(function() {
25 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
26 observer.observe(target);
27 })
28 }, "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.
29
30 test(function() {
31 assert_throws("INVALID_STATE_ERR", function() {
32 observer.observe(target);
33 })
34 }, "IntersectionObserver.observe() with a deleted root did not throw.");
35
36 test(function() {
37 assert_throws("INVALID_STATE_ERR", function() {
38 observer.unobserve(target);
39 })
40 }, "IntersectionObserver.unobserve() with a deleted root did not throw.");
41
42 test(function() {
43 assert_throws("INVALID_STATE_ERR", function() {
44 observer.disconnect();
45 })
46 }, "IntersectionObserver.disconnect() with a deleted root did not throw.");
47
48 test(function() {
49 assert_throws("INVALID_STATE_ERR", function() {
50 observer.takeRecords();
51 })
52 }, "IntersectionObserver.takeRecords() with a deleted root did not throw.");
53 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698