OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script src="./resources/intersection-observer-test-utils.js"></script> |
| 5 <script src="../resources/gc.js"></script> |
| 6 |
| 7 <div id="root"> |
| 8 <div id="target"></div> |
| 9 </div> |
| 10 |
| 11 <script> |
| 12 async_test(function(t) { |
| 13 // Initialize observer and remove root in an inner function to avoid |
| 14 // references to rootDiv remaining live on this function's stack frame |
| 15 // (http://crbug.com/595672/). |
| 16 function initializeObserverThenRemoveRootDiv() { |
| 17 let rootDiv = document.getElementById("root"); |
| 18 let observer = new IntersectionObserver(c => {}, {root: rootDiv}); |
| 19 rootDiv.parentNode.removeChild(rootDiv); |
| 20 return observer; |
| 21 } |
| 22 |
| 23 var target = document.getElementById("target"); |
| 24 var observer = initializeObserverThenRemoveRootDiv(); |
| 25 gc(); |
| 26 |
| 27 runTestCycle(step0, "IntersectionObserver.observe with deleted root."); |
| 28 |
| 29 function step0() { |
| 30 runTestCycle(step1, "IntersectionObserver.unobserve with deleted root."); |
| 31 observer.observe(target); |
| 32 } |
| 33 |
| 34 function step1() { |
| 35 runTestCycle(step2, "IntersectionObserver.disconnect with deleted root."); |
| 36 observer.unobserve(target); |
| 37 } |
| 38 |
| 39 function step2() { |
| 40 runTestCycle(step3, "IntersectionObserver.takeRecords with deleted root."); |
| 41 observer.disconnect(); |
| 42 } |
| 43 |
| 44 function step3() { |
| 45 observer.takeRecords(); |
| 46 t.done(); |
| 47 } |
| 48 }); |
| 49 </script> |
OLD | NEW |