OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <div id="root"></div> |
| 3 <script src="../resources/js-test.js"></script> |
| 4 <script src="../resources/gc.js"></script> |
| 5 <script> |
| 6 description("Test for observer exceptions."); |
| 7 let rootDiv = document.getElementById("root"); |
| 8 var exc; |
| 9 |
| 10 try { |
| 11 new IntersectionObserver(e => {}, {threshold: [1.1]}); |
| 12 testFailed("IntersectionObserver constructor did not throw due to invalid th
reshold."); |
| 13 } catch(e) { |
| 14 exc = e; |
| 15 shouldBeType("exc", "RangeError"); |
| 16 } |
| 17 |
| 18 try { |
| 19 new IntersectionObserver(e => {}, {rootMargin: "1"}); |
| 20 testFailed("IntersectionObserver constructor did not throw due to invalid ro
otMargin."); |
| 21 } catch(e) { |
| 22 exc = e; |
| 23 shouldBeType("exc", "DOMException"); |
| 24 shouldBe("exc.code", "DOMException.SYNTAX_ERR"); |
| 25 } |
| 26 |
| 27 try { |
| 28 new IntersectionObserver(e => {}, {rootMargin: "2em"}); |
| 29 testFailed("IntersectionObserver constructor did not throw due to invalid ro
otMargin."); |
| 30 } catch(e) { |
| 31 exc = e; |
| 32 shouldBeType("exc", "DOMException"); |
| 33 shouldBe("exc.code", "DOMException.SYNTAX_ERR"); |
| 34 } |
| 35 |
| 36 try { |
| 37 new IntersectionObserver(e => {}, {rootMargin: "auto"}); |
| 38 testFailed("IntersectionObserver constructor did not throw due to invalid ro
otMargin."); |
| 39 } catch(e) { |
| 40 exc = e; |
| 41 shouldBeType("exc", "DOMException"); |
| 42 shouldBe("exc.code", "DOMException.SYNTAX_ERR"); |
| 43 } |
| 44 |
| 45 let observer = new IntersectionObserver(c => {}, {}); |
| 46 try { |
| 47 observer.observe("foo"); |
| 48 testFailed("IntersectionObserver.observe with a bad target argument did not
throw."); |
| 49 } catch(e) { |
| 50 exc = e; |
| 51 shouldBeType("exc", "TypeError"); |
| 52 } |
| 53 </script> |
OLD | NEW |