Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/intersection-observer/iframe-cross-origin.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/intersection-observer/iframe-cross-origin.html b/third_party/WebKit/LayoutTests/http/tests/intersection-observer/iframe-cross-origin.html |
| index 0132d6d54395c29b71f9ac6790f139d8ed5ea39a..ef4e39543e893e78c0f0f76a6b009adfa736eec0 100644 |
| --- a/third_party/WebKit/LayoutTests/http/tests/intersection-observer/iframe-cross-origin.html |
| +++ b/third_party/WebKit/LayoutTests/http/tests/intersection-observer/iframe-cross-origin.html |
| @@ -10,6 +10,17 @@ self.jsTestIsAsync = true; |
| description("Simple intersection observer test with no explicit root and target in a cross-origin iframe."); |
| +function waitForNotification(f) { |
| + requestAnimationFrame(() => { |
| + setTimeout(() => { |
| + if (self.testRunner) |
| + testRunner.runIdleTasks(f); |
| + else |
| + requestIdleCallback(f); |
| + }) |
|
Sami
2016/05/18 10:07:23
nit: missing ';' (in other copy too)
I guess ther
szager1
2016/05/18 21:25:27
Done.
|
| + }); |
| +} |
| + |
| var iframe = document.getElementById("target-iframe"); |
| var actual; |
| @@ -49,23 +60,20 @@ function checkData(actualData, expected) { |
| function handleMessage(event) { |
| if (event.data.hasOwnProperty('scrollTo')) { |
| document.scrollingElement.scrollTop = event.data.scrollTo; |
| - requestAnimationFrame(function () { iframe.contentWindow.postMessage("", "*") }); |
| + waitForNotification(() => { iframe.contentWindow.postMessage("", "*") }); |
| } else if (event.data.hasOwnProperty('actual')) { |
| checkData(event.data.actual, event.data.expected); |
| } else if (event.data.hasOwnProperty('DONE')) { |
| finishJSTest(); |
| document.scrollingElement.scrollTop = 0; |
| } else { |
| - requestAnimationFrame(function () { iframe.contentWindow.postMessage("", "*") }); |
| + waitForNotification(() => { iframe.contentWindow.postMessage("", "*") }); |
| } |
| } |
| window.addEventListener("message", handleMessage); |
| -iframe.onload = function() { |
| - // See LayoutTests/intersection-observer/README for explanation of double RAF. |
| - requestAnimationFrame(() => { |
| - requestAnimationFrame(() => { iframe.contentWindow.postMessage("", "*") }) |
| - }); |
| -} |
| +iframe.onload = (() => { |
| + waitForNotification(() => { iframe.contentWindow.postMessage("", "*") }); |
| +}); |
| </script> |