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

Unified Diff: third_party/WebKit/LayoutTests/intersection-observer/same-document-root.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/same-document-root.html
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/same-document-root.html b/third_party/WebKit/LayoutTests/intersection-observer/same-document-root.html
index 05a808b3c73091db5105513d8030f2bbd5d2843d..d96f6d1f09007dd2a565cce24a2a26bd3d7bb260 100644
--- a/third_party/WebKit/LayoutTests/intersection-observer/same-document-root.html
+++ b/third_party/WebKit/LayoutTests/intersection-observer/same-document-root.html
@@ -9,107 +9,105 @@
<div style="width:100%;height:700px;"></div>
<script>
-description("Simple intersection observer test with explicit root and target in the same document.");
-var target = document.getElementById("target");
-var root = document.getElementById("root");
-var entries = [];
-var observer = new IntersectionObserver(
- changes => { entries = entries.concat(changes) },
- { root: document.getElementById("root") }
-);
+ description("Simple intersection observer test with explicit root and target in the same document.");
+ var target = document.getElementById("target");
+ var root = document.getElementById("root");
+ var entries = [];
-onload = function() {
+ observer_callback = function(changes) {
+ for (var i in changes)
+ entries.push(changes[i]);
+ };
+ var observer = new IntersectionObserver(observer_callback, {"root": document.getElementById("root")});
observer.observe(target);
- entries = entries.concat(observer.takeRecords());
- shouldBeEqualToNumber("entries.length", 0);
- requestAnimationFrame(() => { requestAnimationFrame(step0) });
-}
-// Test that notifications are not generated when the target is overflow clipped by the root.
-function step0() {
- entries = entries.concat(observer.takeRecords());
- shouldBeEqualToNumber("entries.length", 0);
- document.scrollingElement.scrollTop = 600;
- requestAnimationFrame(step1);
-}
+ // Test that notifications are not generated when the target is overflow clipped by the root.
+ function step0() {
+ setTimeout(function() {
+ shouldBeEqualToNumber("entries.length", 0);
+ document.scrollingElement.scrollTop = 600;
+ requestAnimationFrame(step1);
+ });
+ }
-function step1() {
- entries = entries.concat(observer.takeRecords());
- shouldBeEqualToNumber("entries.length", 0);
- root.scrollTop = 150;
- requestAnimationFrame(step2);
-}
+ function step1() {
+ setTimeout(function() {
+ shouldBeEqualToNumber("entries.length", 0);
+ root.scrollTop = 150;
+ requestAnimationFrame(step2);
+ });
+ }
-function step2() {
- entries = entries.concat(observer.takeRecords());
- shouldBeEqualToNumber("entries.length", 1);
- if (entries.length > 0) {
- shouldBeEqualToNumber("entries[0].boundingClientRect.left", 11);
- shouldBeEqualToNumber("entries[0].boundingClientRect.right", 111);
- shouldBeEqualToNumber("entries[0].boundingClientRect.top", 261);
- shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 361);
- shouldBeEqualToNumber("entries[0].intersectionRect.left", 11);
- shouldBeEqualToNumber("entries[0].intersectionRect.right", 111);
- shouldBeEqualToNumber("entries[0].intersectionRect.top", 261);
- shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 311);
- shouldBeEqualToNumber("entries[0].rootBounds.left", 11);
- shouldBeEqualToNumber("entries[0].rootBounds.right", 111);
- shouldBeEqualToNumber("entries[0].rootBounds.top", 111);
- shouldBeEqualToNumber("entries[0].rootBounds.bottom", 311);
- shouldEvaluateToSameObject("entries[0].target", target);
+ function step2() {
+ setTimeout(function() {
+ shouldBeEqualToNumber("entries.length", 1);
+ shouldBeEqualToNumber("entries[0].boundingClientRect.left", 11);
+ shouldBeEqualToNumber("entries[0].boundingClientRect.right", 111);
+ shouldBeEqualToNumber("entries[0].boundingClientRect.top", 261);
+ shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 361);
+ shouldBeEqualToNumber("entries[0].intersectionRect.left", 11);
+ shouldBeEqualToNumber("entries[0].intersectionRect.right", 111);
+ shouldBeEqualToNumber("entries[0].intersectionRect.top", 261);
+ shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 311);
+ shouldBeEqualToNumber("entries[0].rootBounds.left", 11);
+ shouldBeEqualToNumber("entries[0].rootBounds.right", 111);
+ shouldBeEqualToNumber("entries[0].rootBounds.top", 111);
+ shouldBeEqualToNumber("entries[0].rootBounds.bottom", 311);
+ shouldEvaluateToSameObject("entries[0].target", target);
+ document.scrollingElement.scrollTop = 0;
+ requestAnimationFrame(step3);
+ });
}
- document.scrollingElement.scrollTop = 0;
- requestAnimationFrame(step3);
-}
-function step3() {
- entries = entries.concat(observer.takeRecords());
- shouldBeEqualToNumber("entries.length", 1);
- root.scrollTop = 0;
- requestAnimationFrame(step4);
-}
+ function step3() {
+ setTimeout(function() {
+ shouldBeEqualToNumber("entries.length", 1);
+ root.scrollTop = 0;
+ requestAnimationFrame(step4);
+ });
+ }
-function step4() {
- entries = entries.concat(observer.takeRecords());
- shouldBeEqualToNumber("entries.length", 2);
- if (entries.length > 1) {
- shouldBeEqualToNumber("entries[1].boundingClientRect.left", 11);
- shouldBeEqualToNumber("entries[1].boundingClientRect.right", 111);
- shouldBeEqualToNumber("entries[1].boundingClientRect.top", 1011);
- shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 1111);
- shouldBeEqualToNumber("entries[1].intersectionRect.left", 0);
- shouldBeEqualToNumber("entries[1].intersectionRect.right", 0);
- shouldBeEqualToNumber("entries[1].intersectionRect.top", 0);
- shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0);
- shouldBeEqualToNumber("entries[1].rootBounds.left", 11);
- shouldBeEqualToNumber("entries[1].rootBounds.right", 111);
- shouldBeEqualToNumber("entries[1].rootBounds.top", 711);
- shouldBeEqualToNumber("entries[1].rootBounds.bottom", 911);
- shouldEvaluateToSameObject("entries[1].target", target);
+ function step4() {
+ setTimeout(function() {
+ shouldBeEqualToNumber("entries.length", 2);
+ shouldBeEqualToNumber("entries[1].boundingClientRect.left", 11);
+ shouldBeEqualToNumber("entries[1].boundingClientRect.right", 111);
+ shouldBeEqualToNumber("entries[1].boundingClientRect.top", 1011);
+ shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 1111);
+ shouldBeEqualToNumber("entries[1].intersectionRect.left", 0);
+ shouldBeEqualToNumber("entries[1].intersectionRect.right", 0);
+ shouldBeEqualToNumber("entries[1].intersectionRect.top", 0);
+ shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0);
+ shouldBeEqualToNumber("entries[1].rootBounds.left", 11);
+ shouldBeEqualToNumber("entries[1].rootBounds.right", 111);
+ shouldBeEqualToNumber("entries[1].rootBounds.top", 711);
+ shouldBeEqualToNumber("entries[1].rootBounds.bottom", 911);
+ shouldEvaluateToSameObject("entries[1].target", target);
+ root.scrollTop = 150;
+ requestAnimationFrame(step5);
+ });
}
- root.scrollTop = 150;
- requestAnimationFrame(step5);
-}
-// This tests that notifications are generated even when the root element is off screen.
-function step5() {
- entries = entries.concat(observer.takeRecords());
- shouldBeEqualToNumber("entries.length", 3);
- if (entries.length > 2) {
- shouldBeEqualToNumber("entries[2].boundingClientRect.left", 11);
- shouldBeEqualToNumber("entries[2].boundingClientRect.right", 111);
- shouldBeEqualToNumber("entries[2].boundingClientRect.top", 861);
- shouldBeEqualToNumber("entries[2].boundingClientRect.bottom", 961);
- shouldBeEqualToNumber("entries[2].intersectionRect.left", 11);
- shouldBeEqualToNumber("entries[2].intersectionRect.right", 111);
- shouldBeEqualToNumber("entries[2].intersectionRect.top", 861);
- shouldBeEqualToNumber("entries[2].intersectionRect.bottom", 911);
- shouldBeEqualToNumber("entries[2].rootBounds.left", 11);
- shouldBeEqualToNumber("entries[2].rootBounds.right", 111);
- shouldBeEqualToNumber("entries[2].rootBounds.top", 711);
- shouldBeEqualToNumber("entries[2].rootBounds.bottom", 911);
- shouldEvaluateToSameObject("entries[2].target", target);
+ // This tests that notifications are generated even when the root element is off screen.
+ function step5() {
+ setTimeout(function() {
+ shouldBeEqualToNumber("entries.length", 3);
+ shouldBeEqualToNumber("entries[2].boundingClientRect.left", 11);
+ shouldBeEqualToNumber("entries[2].boundingClientRect.right", 111);
+ shouldBeEqualToNumber("entries[2].boundingClientRect.top", 861);
+ shouldBeEqualToNumber("entries[2].boundingClientRect.bottom", 961);
+ shouldBeEqualToNumber("entries[2].intersectionRect.left", 11);
+ shouldBeEqualToNumber("entries[2].intersectionRect.right", 111);
+ shouldBeEqualToNumber("entries[2].intersectionRect.top", 861);
+ shouldBeEqualToNumber("entries[2].intersectionRect.bottom", 911);
+ shouldBeEqualToNumber("entries[2].rootBounds.left", 11);
+ shouldBeEqualToNumber("entries[2].rootBounds.right", 111);
+ shouldBeEqualToNumber("entries[2].rootBounds.top", 711);
+ shouldBeEqualToNumber("entries[2].rootBounds.bottom", 911);
+ shouldEvaluateToSameObject("entries[2].target", target);
+ finishJSTest();
+ });
}
- finishJSTest();
-}
+
+ step0();
</script>

Powered by Google App Engine
This is Rietveld 408576698