Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: third_party/WebKit/LayoutTests/intersection-observer/timestamp.html

Issue 1780163002: Revert of IntersectionObserver: use an idle callback to send notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/intersection-observer/timestamp.html
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/timestamp.html b/third_party/WebKit/LayoutTests/intersection-observer/timestamp.html
index fa967660c955e23c89cd5aa59c2eebc1c56b2d3e..47f1dcc5cef50b539b05b8a32e2801154e17682c 100644
--- a/third_party/WebKit/LayoutTests/intersection-observer/timestamp.html
+++ b/third_party/WebKit/LayoutTests/intersection-observer/timestamp.html
@@ -8,8 +8,6 @@
description("Test that intersection observer time is relative to time in the callback context.");
var topWindowEntries = [];
var iframeWindowEntries = [];
-var topWindowObserver;
-var iframeWindowObserver;
var targetIframe;
var iframeScroller;
var topWindowTime;
@@ -17,36 +15,36 @@
var timestampTolerance = 24; // 1.5 times frame duration.
function step0() {
- // Test results are only significant if there's a sufficient gap between
- // top window time and iframe window time.
- topWindowTime = performance.now();
- iframeWindowTime = targetIframe.contentWindow.performance.now();
- shouldBeGreaterThan("topWindowTime - iframeWindowTime", "2 * timestampTolerance");
+ setTimeout(function() {
+ // Test results are only significant if there's a sufficient gap between
+ // top window time and iframe window time.
+ topWindowTime = performance.now();
+ iframeWindowTime = targetIframe.contentWindow.performance.now();
+ shouldBeGreaterThan("topWindowTime - iframeWindowTime", "2 * timestampTolerance");
- topWindowEntries = topWindowEntries.concat(topWindowObserver.takeRecords());
- iframeWindowEntries = iframeWindowEntries.concat(iframeWindowObserver.takeRecords());
- shouldBeEqualToNumber("topWindowEntries.length", 0);
- shouldBeEqualToNumber("iframeWindowEntries.length", 0);
- document.scrollingElement.scrollTop = 200;
- iframeScroller.scrollTop = 250;
- requestAnimationFrame(step1);
+ shouldBeEqualToNumber("topWindowEntries.length", 0);
+ shouldBeEqualToNumber("iframeWindowEntries.length", 0);
+ document.scrollingElement.scrollTop = 200;
+ iframeScroller.scrollTop = 250;
+ requestAnimationFrame(step1);
+ });
}
function step1() {
- topWindowEntries = topWindowEntries.concat(topWindowObserver.takeRecords());
- iframeWindowEntries = iframeWindowEntries.concat(iframeWindowObserver.takeRecords());
- topWindowTime = performance.now();
- iframeWindowTime = targetIframe.contentWindow.performance.now();
- shouldBeEqualToNumber("topWindowEntries.length", 1);
- if (topWindowEntries.length) {
- shouldBeCloseTo("topWindowEntries[0].time", "topWindowTime", timestampTolerance);
- }
- shouldBeEqualToNumber("iframeWindowEntries.length", 1);
- if (iframeWindowEntries.length) {
- shouldBeCloseTo("iframeWindowEntries[0].time", "iframeWindowTime", timestampTolerance);
- }
- finishJSTest();
- document.scrollingElement.scrollTop = 0;
+ setTimeout(function() {
+ topWindowTime = performance.now();
+ iframeWindowTime = targetIframe.contentWindow.performance.now();
+ shouldBeEqualToNumber("topWindowEntries.length", 1);
+ if (topWindowEntries.length) {
+ shouldBeCloseTo("topWindowEntries[0].time", "topWindowTime", timestampTolerance);
+ }
+ shouldBeEqualToNumber("iframeWindowEntries.length", 1);
+ if (iframeWindowEntries.length) {
+ shouldBeCloseTo("iframeWindowEntries[0].time", "iframeWindowTime", timestampTolerance);
+ }
+ finishJSTest();
+ document.scrollingElement.scrollTop = 0;
+ });
}
function runTest() {
@@ -55,19 +53,18 @@
// Observer created here, callback created in iframe context. Timestamps should be
// from this window.
- topWindowObserver = new IntersectionObserver(targetIframe.contentDocument.createObserverCallback(topWindowEntries), {});
- topWindowObserver.observe(target);
+ var observer = new IntersectionObserver(targetIframe.contentDocument.createObserverCallback(topWindowEntries), {});
+ observer.observe(target);
// Callback created here, observer created in iframe. Timestamps should be
// from iframe window.
- iframeWindowObserver = targetIframe.contentDocument.createObserver(function(newEntries) {
+ observer = targetIframe.contentDocument.createObserver(function(newEntries) {
for (var i = 0; i < newEntries.length; i++)
iframeWindowEntries.push(newEntries[i]);
});
- iframeWindowObserver.observe(target);
+ observer.observe(target);
- // See README for explanation of double RAF.
- requestAnimationFrame(() => { requestAnimationFrame(step0) });
+ step0();
}
window.onload = function() {

Powered by Google App Engine
This is Rietveld 408576698