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 <div class="spacer"></div> |
| 22 <div id="target"></div> |
| 23 <div class="spacer"></div> |
| 24 |
| 25 <script> |
| 26 var entries = []; |
| 27 |
| 28 runTestCycle(function() { |
| 29 var target = document.getElementById("target"); |
| 30 assert_true(!!target, "Target exists"); |
| 31 function createObserver() { |
| 32 new IntersectionObserver(function(changes) { |
| 33 entries = entries.concat(changes) |
| 34 }).observe(target); |
| 35 } |
| 36 createObserver(); |
| 37 runTestCycle(step0, "First rAF"); |
| 38 }, "IntersectionObserver that is unreachable in js should still generate notific
ations."); |
| 39 |
| 40 function step0() { |
| 41 document.scrollingElement.scrollTop = 300; |
| 42 runTestCycle(step1, "document.scrollingElement.scrollTop = 300"); |
| 43 assert_equals(entries.length, 1, "One notification."); |
| 44 } |
| 45 |
| 46 function step1() { |
| 47 document.scrollingElement.scrollTop = 0; |
| 48 assert_equals(entries.length, 2, "Two notifications."); |
| 49 } |
| 50 </script> |
LEFT | RIGHT |