OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../resources/js-test.js"></script> | 2 <script src="../resources/js-test.js"></script> |
3 <script src="../resources/gc.js"></script> | 3 <script src="../resources/gc.js"></script> |
4 <div style="width:100%; height:700px;"></div> | 4 <div style="width:100%; height:700px;"></div> |
5 <div id="target" style="background-color: green; width:100px; height:100px"></di
v> | 5 <div id="target" style="background-color: green; width:100px; height:100px"></di
v> |
6 <div style="width:100%; height:700px;"></div> | 6 <div style="width:100%; height:700px;"></div> |
7 | 7 |
8 <script> | 8 <script> |
9 jsTestIsAsync = true; | 9 jsTestIsAsync = true; |
10 description("IntersectionObserver continues to produce notifications when it has
no javascript references."); | 10 description("IntersectionObserver continues to produce notifications when it h
as no javascript references."); |
11 var target = document.getElementById("target"); | 11 var target = document.getElementById("target"); |
12 var entries = []; | 12 var entries = []; |
13 new IntersectionObserver(function(changes) { | 13 new IntersectionObserver(function(changes) { |
14 entries.push(...changes); | 14 entries.push(...changes); |
15 }).observe(target); | 15 }).observe(target); |
16 gc(); | 16 gc(); |
17 document.scrollingElement.scrollTop = 300; | 17 document.scrollingElement.scrollTop = 300; |
18 // See README for explanation of double RAF. | 18 requestAnimationFrame(function () { |
19 requestAnimationFrame(() => { requestAnimationFrame(() => { | 19 setTimeout(function() { |
20 // In other IntersectionObserver tests, observer.takeRecords() is used to ensu
re that | 20 shouldBeEqualToNumber("entries.length", 1); |
21 // all pending notifications are taken. Because this test specifically tests
the | 21 finishJSTest(); |
22 // case where the observer object has no js references, it can't use takeRecor
ds(). | 22 }); |
23 // However, the IntersectionObserver spec mandates that all notifications must
be | 23 }); |
24 // sent within 100ms of being generated, so this timeout effectively tests con
formance | |
25 // with that requirement. | |
26 setTimeout(() => { | |
27 shouldBeEqualToNumber("entries.length", 1); | |
28 finishJSTest(); | |
29 }, 100) | |
30 }) }); | |
31 </script> | 24 </script> |
OLD | NEW |