| OLD | NEW |
| (Empty) |
| 1 All of the IntersectionObserver tests feature the following idiom: | |
| 2 | |
| 3 <script> | |
| 4 var observer = new IntersectionObserver(...) | |
| 5 function test_function() { | |
| 6 var entries = observer.takeRecords(); | |
| 7 // Verify entries | |
| 8 } | |
| 9 onload = function() { | |
| 10 observer.observe(target); | |
| 11 requestAnimationFrame(() => { requestAnimationFrame(test_function) }); | |
| 12 } | |
| 13 | |
| 14 | |
| 15 Subsequent steps in the test use a single RAF to give the observer a chance to | |
| 16 generate notifications, but the double RAF is required in the onload handler. | |
| 17 Here's the chain of events: | |
| 18 | |
| 19 - onload | |
| 20 - observer.observe() | |
| 21 - First RAF handler is registered | |
| 22 - BeginFrame | |
| 23 - RAF handlers run | |
| 24 - Second RAF handler is registered | |
| 25 - UpdateAllLifecyclePhases | |
| 26 - IntersectionObserver generates notifications | |
| 27 - BeginFrame | |
| 28 - RAF handlers run | |
| 29 - Second RAF handler verifies observer notifications. | |
| OLD | NEW |