chromium/third_party/blink/web_tests/intersection-observer/README

All of the IntersectionObserver tests feature the following idiom:

<script>
var observer = new IntersectionObserver(...)
function test_function() {
  var entries = observer.takeRecords();
  // Verify entries
}
onload = function() {
  observer.observe(target);
  requestAnimationFrame(() => {
    setTimeout(() => {
      setTimeout(test_function);
    });
  });
}

Here's the chain of events:

- onload
  - observer.observe()
  - RAF handler is registered
- BeginFrame
  - RAF handler runs
    - First setTimeout is registered 
  - UpdateAllLifecyclePhases
    - IntersectionObserver generates notifications
  - First setTimeout runs
    - Second setTimeout is regsitered
  - Notifications that haven't be taken via takeRecords are delivered
  - Second setTimeout runs and queues another RAF handler
- BeginFrame
  - RAF handler runs
    - RAF handler verifies observer notifications via takeRecords or
      does the setTimeout dance to respond after they've been delivered.