| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <div id="root"></div> | 2 <div id="root"></div> |
| 3 <div id="target"></div> | 3 <div id="target"></div> |
| 4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
| 5 <script src="../resources/gc.js"></script> | 5 <script src="../resources/gc.js"></script> |
| 6 <script> | 6 <script> |
| 7 description("Test for observer exceptions."); | 7 description("Test for observer exceptions."); |
| 8 var exc; | 8 var exc; |
| 9 | 9 |
| 10 try { | 10 try { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // (http://crbug.com/595672/). | 73 // (http://crbug.com/595672/). |
| 74 function initializeObserverThenRemoveRootDiv() { | 74 function initializeObserverThenRemoveRootDiv() { |
| 75 let rootDiv = document.getElementById("root"); | 75 let rootDiv = document.getElementById("root"); |
| 76 let observer = new IntersectionObserver(c => {}, {root: rootDiv}); | 76 let observer = new IntersectionObserver(c => {}, {root: rootDiv}); |
| 77 rootDiv.parentNode.removeChild(rootDiv); | 77 rootDiv.parentNode.removeChild(rootDiv); |
| 78 return observer; | 78 return observer; |
| 79 } | 79 } |
| 80 | 80 |
| 81 observer = initializeObserverThenRemoveRootDiv(); | 81 observer = initializeObserverThenRemoveRootDiv(); |
| 82 gc(); | 82 gc(); |
| 83 | 83 observer.observe(target); |
| 84 try { | 84 observer.unobserve(target); |
| 85 observer.observe(target); | 85 observer.disconnect(); |
| 86 testFailed("IntersectionObserver.observe() with a deleted root did not throw
."); | 86 shouldBeEqualToNumber("0", observer.takeRecords().length); |
| 87 } catch(e) { | |
| 88 exc = e; | |
| 89 shouldBeType("exc", "DOMException"); | |
| 90 shouldBe("exc.code", "DOMException.INVALID_STATE_ERR"); | |
| 91 } | |
| 92 | |
| 93 try { | |
| 94 observer.unobserve(target); | |
| 95 testFailed("IntersectionObserver.unobserve() with a deleted root did not thr
ow."); | |
| 96 } catch(e) { | |
| 97 exc = e; | |
| 98 shouldBeType("exc", "DOMException"); | |
| 99 shouldBe("exc.code", "DOMException.INVALID_STATE_ERR"); | |
| 100 } | |
| 101 | |
| 102 try { | |
| 103 observer.disconnect(); | |
| 104 testFailed("IntersectionObserver.disconnect() with a deleted root did not th
row."); | |
| 105 } catch(e) { | |
| 106 exc = e; | |
| 107 shouldBeType("exc", "DOMException"); | |
| 108 shouldBe("exc.code", "DOMException.INVALID_STATE_ERR"); | |
| 109 } | |
| 110 | |
| 111 try { | |
| 112 observer.takeRecords(); | |
| 113 testFailed("IntersectionObserver.takeRecords() with a deleted root did not t
hrow."); | |
| 114 } catch(e) { | |
| 115 exc = e; | |
| 116 shouldBeType("exc", "DOMException"); | |
| 117 shouldBe("exc.code", "DOMException.INVALID_STATE_ERR"); | |
| 118 } | |
| 119 </script> | 87 </script> |
| OLD | NEW |