OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../resources/js-test.js"></script> | 2 <script src="../resources/testharness.js"></script> |
3 <script src="../resources/gc.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
4 <script src="../resources/intersection-observer-helper-functions.js"></script> | 4 <script src="./resources/intersection-observer-test-utils.js"></script> |
5 <div style="width:100%; height:700px;"></div> | 5 |
6 <div id="target" style="background-color: green; width:100px; height:100px"></di
v> | 6 <style> |
7 <div style="width:100%; height:700px;"></div> | 7 pre, #log { |
| 8 position: absolute; |
| 9 top: 0; |
| 10 left: 200px; |
| 11 } |
| 12 .spacer { |
| 13 height: 700px; |
| 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> |
8 | 24 |
9 <script> | 25 <script> |
10 description("IntersectionObserver continues to produce notifications when it has
no javascript references."); | |
11 var target = document.getElementById("target"); | |
12 var entries = []; | 26 var entries = []; |
13 new IntersectionObserver(function(changes) { | 27 |
14 entries.push(...changes); | 28 runTestCycle(function() { |
15 }).observe(target); | 29 assert_equals(window.innerWidth, 800, "Window must be 800 pixels wide."); |
16 gc(); | 30 assert_equals(window.innerHeight, 600, "Window must be 600 pixels high."); |
17 document.scrollingElement.scrollTop = 300; | 31 |
18 waitForNotification(() => { | 32 var target = document.getElementById("target"); |
19 shouldBeEqualToNumber("entries.length", 1); | 33 assert_true(!!target, "Target exists"); |
20 finishJSTest(); | 34 function createObserver() { |
21 }); | 35 new IntersectionObserver(function(changes) { |
| 36 entries = entries.concat(changes) |
| 37 }).observe(target); |
| 38 } |
| 39 createObserver(); |
| 40 runTestCycle(step0, "First rAF"); |
| 41 }, "IntersectionObserver that is unreachable in js should still generate notific
ations."); |
| 42 |
| 43 function step0() { |
| 44 document.scrollingElement.scrollTop = 300; |
| 45 runTestCycle(step1, "document.scrollingElement.scrollTop = 300"); |
| 46 assert_equals(entries.length, 0, "No notifications after first rAF."); |
| 47 } |
| 48 |
| 49 function step1() { |
| 50 document.scrollingElement.scrollTop = 0; |
| 51 assert_equals(entries.length, 1, "One notification."); |
| 52 } |
22 </script> | 53 </script> |
OLD | NEW |