| Index: third_party/WebKit/LayoutTests/intersection-observer/helper-functions.js
|
| diff --git a/third_party/WebKit/LayoutTests/intersection-observer/helper-functions.js b/third_party/WebKit/LayoutTests/intersection-observer/helper-functions.js
|
| index 7e2612d49f5806c2244c5d96c295b16c54ef6a02..6fd2361eef0914b9ca25690730aef02da71e29ce 100644
|
| --- a/third_party/WebKit/LayoutTests/intersection-observer/helper-functions.js
|
| +++ b/third_party/WebKit/LayoutTests/intersection-observer/helper-functions.js
|
| @@ -8,6 +8,47 @@ function rectArea(rect) {
|
| return (rect.left - rect.right) * (rect.bottom - rect.top);
|
| }
|
|
|
| +// waitForNotification is a requestIdleCallback wrapped in a setTimeout wrapped in a
|
| +// requestAnimationFrame. What in the wide, wide world of sports is going on here?
|
| +//
|
| +// Here's the order of events:
|
| +//
|
| +// - firstTestFunction
|
| +// - Change layout to generate new IntersectionObserver notifications.
|
| +// - waitForNotification(secondTestFunction)
|
| +// - requestAnimationFrame
|
| +// - BeginFrame
|
| +// - requestAnimationFrame handler runs.
|
| +// - setTimeout
|
| +// - FrameView::updateAllLifecyclePhases
|
| +// - IntersectionObserver generates notification based on the new layout.
|
| +// - Post idle task to deliver notification.
|
| +// - setTimeout handler runs.
|
| +// - testRunner.runIdleTasks or requestIdleCallback.
|
| +// - Idle tasks run -- more or less immediately if (self.testRunner),
|
| +// possibly delayed if (!self.testRunner).
|
| +// - IntersectionObserver notifications are delivered.
|
| +// - secondTestFunction
|
| +// - Verify notifications generated by firstTestFunction.
|
| +// - Change layout to generate new IntersectionObserver notifications.
|
| +// - waitForNotification(thirdTestFunction)
|
| +//
|
| +// Note that this should work equally well in these operation conditions:
|
| +//
|
| +// - layout test using single-threaded compositing (the default)
|
| +// - layout test using multi-threaded compositing (virtual/threaded/)
|
| +// - Not in a layout test and using multi-threaded compositing (the only configuration we ship)
|
| +function waitForNotification(f) {
|
| + requestAnimationFrame(() => {
|
| + setTimeout(() => {
|
| + if (self.testRunner)
|
| + testRunner.runIdleTasks(f);
|
| + else
|
| + requestIdleCallback(f);
|
| + })
|
| + })
|
| +}
|
| +
|
| function rectToString(rect) {
|
| return "[" + rect.left + ", " + rect.right + ", " + rect.top + ", " + rect.bottom + "]";
|
| }
|
|
|