LEFT | RIGHT |
(no file at all) | |
| 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 |
| 6 <style> |
| 7 pre, #log { |
| 8 position: absolute; |
| 9 top: 0; |
| 10 left: 200px; |
| 11 } |
| 12 .spacer { |
| 13 height: calc(100vh + 100px); |
| 14 } |
| 15 #target { |
| 16 width: 100px; |
| 17 height: 100px; |
| 18 background-color: green; |
| 19 } |
| 20 </style> |
| 21 |
| 22 <div class="spacer"></div> |
| 23 <div id="target"></div> |
| 24 <div class="spacer"></div> |
| 25 |
| 26 <script> |
| 27 var entries = []; |
| 28 var observer; |
| 29 var target; |
| 30 |
| 31 runTestCycle(function() { |
| 32 target = document.getElementById("target"); |
| 33 assert_true(!!target, "target exists"); |
| 34 observer = new IntersectionObserver(function(changes) { |
| 35 entries = entries.concat(changes) |
| 36 }); |
| 37 observer.observe(target); |
| 38 entries = entries.concat(observer.takeRecords()); |
| 39 assert_equals(entries.length, 0, "No initial notifications."); |
| 40 runTestCycle(step0, "First rAF."); |
| 41 }, "IntersectionObserver should not deliver pending notifications after disconne
ct()."); |
| 42 |
| 43 function step0() { |
| 44 runTestCycle(step1, "observer.disconnect()"); |
| 45 document.scrollingElement.scrollTop = 300; |
| 46 observer.disconnect(); |
| 47 assert_equals(entries.length, 1, "Initial notification."); |
| 48 } |
| 49 |
| 50 function step1() { |
| 51 assert_equals(entries.length, 1, "No new notifications."); |
| 52 } |
| 53 </script> |
LEFT | RIGHT |