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

Unified Diff: third_party/WebKit/LayoutTests/intersection-observer/same-document-zero-size-target.html

Issue 1776493002: IntersectionObserver: use an idle callback to send notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: syntax error 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-zero-size-target.html
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/same-document-zero-size-target.html b/third_party/WebKit/LayoutTests/intersection-observer/same-document-zero-size-target.html
index 4a5b435016c2a41bbe4515c576c9bed59f46ddc0..d29df905ac82923c4e75ce3a8f4788c4c6bc10a0 100644
--- a/third_party/WebKit/LayoutTests/intersection-observer/same-document-zero-size-target.html
+++ b/third_party/WebKit/LayoutTests/intersection-observer/same-document-zero-size-target.html
@@ -6,68 +6,66 @@
<div style="width:100%; height:700px;"></div>
<script>
- description("Iintersection observer test with zero-size target element.");
- var target = document.getElementById("target");
- var entries = [];
- observer_callback = function(changes) {
- for (var i in changes)
- entries.push(changes[i]);
- };
- var observer = new IntersectionObserver(observer_callback, {});
- observer.observe(target);
-
- onload = function() {
- shouldBeEqualToNumber("entries.length", 0);
- document.scrollingElement.scrollTop = 300;
- requestAnimationFrame(step1);
- };
+description("Iintersection observer test with zero-size target element.");
+var target = document.getElementById("target");
+var entries = [];
+var observer = new IntersectionObserver(changes => { entries = entries.concat(changes) }, {});
- function step1() {
- setTimeout(function() {
- shouldBeEqualToNumber("entries.length", 1);
- shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8);
- shouldBeEqualToNumber("entries[0].boundingClientRect.right", 9);
- shouldBeEqualToNumber("entries[0].boundingClientRect.top", 408);
- shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 409);
- shouldBeEqualToNumber("entries[0].intersectionRect.left", 8);
- shouldBeEqualToNumber("entries[0].intersectionRect.right", 9);
- shouldBeEqualToNumber("entries[0].intersectionRect.top", 408);
- shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 409);
- shouldBeEqualToNumber("entries[0].rootBounds.left", 0);
- shouldBeEqualToNumber("entries[0].rootBounds.right", 785);
- shouldBeEqualToNumber("entries[0].rootBounds.top", 0);
- shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600);
- shouldEvaluateToSameObject("entries[0].target", target);
+onload = function() {
+ observer.observe(target);
+ entries = entries.concat(observer.takeRecords());
+ shouldBeEqualToNumber("entries.length", 0);
+ document.scrollingElement.scrollTop = 300;
+ // See README for explanation of double RAF.
+ requestAnimationFrame(() => { requestAnimationFrame(step1) });
+};
- // ClientRect members of IntersectionObserverEntry should be stable.
- shouldEvaluateToSameObject("entries[0].boundingClientRect", entries[0].boundingClientRect);
- shouldEvaluateToSameObject("entries[0].intersectionRect", entries[0].intersectionRect);
- shouldEvaluateToSameObject("entries[0].rootBounds", entries[0].rootBounds);
+function step1() {
+ entries = entries.concat(observer.takeRecords());
+ shouldBeEqualToNumber("entries.length", 1);
+ if (entries.length > 0) {
+ shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8);
+ shouldBeEqualToNumber("entries[0].boundingClientRect.right", 9);
+ shouldBeEqualToNumber("entries[0].boundingClientRect.top", 408);
+ shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 409);
+ shouldBeEqualToNumber("entries[0].intersectionRect.left", 8);
+ shouldBeEqualToNumber("entries[0].intersectionRect.right", 9);
+ shouldBeEqualToNumber("entries[0].intersectionRect.top", 408);
+ shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 409);
+ shouldBeEqualToNumber("entries[0].rootBounds.left", 0);
+ shouldBeEqualToNumber("entries[0].rootBounds.right", 785);
+ shouldBeEqualToNumber("entries[0].rootBounds.top", 0);
+ shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600);
+ shouldEvaluateToSameObject("entries[0].target", target);
- document.scrollingElement.scrollTop = 100;
- requestAnimationFrame(step2);
- });
+ // ClientRect members of IntersectionObserverEntry should be stable.
+ shouldEvaluateToSameObject("entries[0].boundingClientRect", entries[0].boundingClientRect);
+ shouldEvaluateToSameObject("entries[0].intersectionRect", entries[0].intersectionRect);
+ shouldEvaluateToSameObject("entries[0].rootBounds", entries[0].rootBounds);
}
+ document.scrollingElement.scrollTop = 100;
+ requestAnimationFrame(step2);
+}
- function step2() {
- setTimeout(function() {
- shouldBeEqualToNumber("entries.length", 2);
- shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8);
- shouldBeEqualToNumber("entries[1].boundingClientRect.right", 9);
- shouldBeEqualToNumber("entries[1].boundingClientRect.top", 608);
- shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 609);
- 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", 0);
- shouldBeEqualToNumber("entries[1].rootBounds.right", 785);
- shouldBeEqualToNumber("entries[1].rootBounds.top", 0);
- shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600);
- shouldEvaluateToSameObject("entries[1].target", target);
- finishJSTest();
- document.scrollingElement.scrollTop = 0;
- });
+function step2() {
+ entries = entries.concat(observer.takeRecords());
+ shouldBeEqualToNumber("entries.length", 2);
+ if (entries.length > 1) {
+ shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8);
+ shouldBeEqualToNumber("entries[1].boundingClientRect.right", 9);
+ shouldBeEqualToNumber("entries[1].boundingClientRect.top", 608);
+ shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 609);
+ 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", 0);
+ shouldBeEqualToNumber("entries[1].rootBounds.right", 785);
+ shouldBeEqualToNumber("entries[1].rootBounds.top", 0);
+ shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600);
+ shouldEvaluateToSameObject("entries[1].target", target);
}
-
+ finishJSTest();
+ document.scrollingElement.scrollTop = 0;
+}
</script>

Powered by Google App Engine
This is Rietveld 408576698