| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <div id="root"></div> | 2 <div id="root"></div> |
| 3 <div id="target"></div> |
| 3 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
| 4 <script src="../resources/gc.js"></script> | 5 <script src="../resources/gc.js"></script> |
| 5 <script> | 6 <script> |
| 6 description("Test for observer exceptions."); | 7 description("Test for observer exceptions."); |
| 7 let rootDiv = document.getElementById("root"); | 8 let rootDiv = document.getElementById("root"); |
| 8 var exc; | 9 var exc; |
| 9 | 10 |
| 10 try { | 11 try { |
| 11 new IntersectionObserver(e => {}, {threshold: [1.1]}); | 12 new IntersectionObserver(e => {}, {threshold: [1.1]}); |
| 12 testFailed("IntersectionObserver constructor did not throw due to invalid th
reshold."); | 13 testFailed("IntersectionObserver constructor did not throw due to invalid th
reshold."); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 43 } | 44 } |
| 44 | 45 |
| 45 let observer = new IntersectionObserver(c => {}, {}); | 46 let observer = new IntersectionObserver(c => {}, {}); |
| 46 try { | 47 try { |
| 47 observer.observe("foo"); | 48 observer.observe("foo"); |
| 48 testFailed("IntersectionObserver.observe with a bad target argument did not
throw."); | 49 testFailed("IntersectionObserver.observe with a bad target argument did not
throw."); |
| 49 } catch(e) { | 50 } catch(e) { |
| 50 exc = e; | 51 exc = e; |
| 51 shouldBeType("exc", "TypeError"); | 52 shouldBeType("exc", "TypeError"); |
| 52 } | 53 } |
| 54 |
| 55 observer = new IntersectionObserver(c => {}, {root: rootDiv}); |
| 56 rootDiv.parentNode.removeChild(rootDiv); |
| 57 rootDiv = null; |
| 58 gc(); |
| 59 |
| 60 try { |
| 61 observer.observe(target); |
| 62 testFailed("IntersectionObserver.observe() with a deleted root did not throw
."); |
| 63 } catch(e) { |
| 64 exc = e; |
| 65 shouldBeType("exc", "DOMException"); |
| 66 shouldBe("exc.code", "DOMException.INVALID_STATE_ERR"); |
| 67 } |
| 68 |
| 69 try { |
| 70 observer.unobserve(target); |
| 71 testFailed("IntersectionObserver.unobserve() with a deleted root did not thr
ow."); |
| 72 } catch(e) { |
| 73 exc = e; |
| 74 shouldBeType("exc", "DOMException"); |
| 75 shouldBe("exc.code", "DOMException.INVALID_STATE_ERR"); |
| 76 } |
| 77 |
| 78 try { |
| 79 observer.disconnect(); |
| 80 testFailed("IntersectionObserver.disconnect() with a deleted root did not th
row."); |
| 81 } catch(e) { |
| 82 exc = e; |
| 83 shouldBeType("exc", "DOMException"); |
| 84 shouldBe("exc.code", "DOMException.INVALID_STATE_ERR"); |
| 85 } |
| 86 |
| 87 try { |
| 88 observer.takeRecords(); |
| 89 testFailed("IntersectionObserver.takeRecords() with a deleted root did not t
hrow."); |
| 90 } catch(e) { |
| 91 exc = e; |
| 92 shouldBeType("exc", "DOMException"); |
| 93 shouldBe("exc.code", "DOMException.INVALID_STATE_ERR"); |
| 94 } |
| 53 </script> | 95 </script> |
| OLD | NEW |