| Index: third_party/WebKit/LayoutTests/intersection-observer/containing-block.html
|
| diff --git a/third_party/WebKit/LayoutTests/intersection-observer/containing-block.html b/third_party/WebKit/LayoutTests/intersection-observer/containing-block.html
|
| index f7db8fb8ee8d9878185571d268a8c5056a4582ad..1031b74b0440fd22da0367d412725c20286630f6 100644
|
| --- a/third_party/WebKit/LayoutTests/intersection-observer/containing-block.html
|
| +++ b/third_party/WebKit/LayoutTests/intersection-observer/containing-block.html
|
| @@ -19,81 +19,80 @@
|
| </div>
|
|
|
| <script>
|
| - description("Test that no notifications are generated when root is not in the containing block chain of target.");
|
| - var root = document.getElementById("root");
|
| - var target = document.getElementById("target");
|
| - var entries = [];
|
| +description("Test that no notifications are generated when root is not in the containing block chain of target.");
|
| +var root = document.getElementById("root");
|
| +var target = document.getElementById("target");
|
| +var entries = [];
|
|
|
| - function observer_callback(changes) {
|
| - changes.forEach(function(e) { entries.push(e) });
|
| - }
|
| - new IntersectionObserver(observer_callback, {root: root}).observe(target);
|
| +var observer = new IntersectionObserver(
|
| + changes => { entries = entries.concat(changes) },
|
| + { root: root }
|
| +);
|
|
|
| - function step0() {
|
| - setTimeout(function() {
|
| - shouldBeEqualToNumber("entries.length", 0);
|
| - target.style.top = "10px";
|
| - requestAnimationFrame(step1);
|
| - });
|
| - }
|
| +onload = function() {
|
| + observer.observe(target);
|
| + shouldBeEqualToNumber("entries.length", 0);
|
| + target.style.top = "10px";
|
| + // See README for explanation of double RAF.
|
| + requestAnimationFrame(() => { requestAnimationFrame(step1) });
|
| +};
|
|
|
| - function step1() {
|
| - setTimeout(function() {
|
| - shouldBeEqualToNumber("entries.length", 1);
|
| - shouldBeEqualToNumber("entries[0].boundingClientRect.left", 58);
|
| - shouldBeEqualToNumber("entries[0].boundingClientRect.right", 158);
|
| - shouldBeEqualToNumber("entries[0].boundingClientRect.top", 18);
|
| - shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 118);
|
| - shouldBeEqualToNumber("entries[0].intersectionRect.left", 58);
|
| - shouldBeEqualToNumber("entries[0].intersectionRect.right", 158);
|
| - shouldBeEqualToNumber("entries[0].intersectionRect.top", 18);
|
| - shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 118);
|
| - shouldBeEqualToNumber("entries[0].rootBounds.left", 8);
|
| - shouldBeEqualToNumber("entries[0].rootBounds.right", 193);
|
| - shouldBeEqualToNumber("entries[0].rootBounds.top", 8);
|
| - shouldBeEqualToNumber("entries[0].rootBounds.bottom", 208);
|
| - shouldEvaluateToSameObject("entries[0].target", target);
|
| - target.style.top = "250px";
|
| - requestAnimationFrame(step2);
|
| - });
|
| - }
|
| -
|
| - function step2() {
|
| - setTimeout(function() {
|
| - shouldBeEqualToNumber("entries.length", 2);
|
| - shouldBeEqualToNumber("entries[1].boundingClientRect.left", 58);
|
| - shouldBeEqualToNumber("entries[1].boundingClientRect.right", 158);
|
| - shouldBeEqualToNumber("entries[1].boundingClientRect.top", 258);
|
| - shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 358);
|
| - 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", 8);
|
| - shouldBeEqualToNumber("entries[1].rootBounds.right", 193);
|
| - shouldBeEqualToNumber("entries[1].rootBounds.top", 8);
|
| - shouldBeEqualToNumber("entries[1].rootBounds.bottom", 208);
|
| - shouldEvaluateToSameObject("entries[1].target", target);
|
| - root.style.position = "static";
|
| - target.style.top = "10px";
|
| - requestAnimationFrame(step3);
|
| - });
|
| +function step1() {
|
| + entries = entries.concat(observer.takeRecords());
|
| + shouldBeEqualToNumber("entries.length", 1);
|
| + if (entries.length > 0) {
|
| + shouldBeEqualToNumber("entries[0].boundingClientRect.left", 58);
|
| + shouldBeEqualToNumber("entries[0].boundingClientRect.right", 158);
|
| + shouldBeEqualToNumber("entries[0].boundingClientRect.top", 18);
|
| + shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 118);
|
| + shouldBeEqualToNumber("entries[0].intersectionRect.left", 58);
|
| + shouldBeEqualToNumber("entries[0].intersectionRect.right", 158);
|
| + shouldBeEqualToNumber("entries[0].intersectionRect.top", 18);
|
| + shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 118);
|
| + shouldBeEqualToNumber("entries[0].rootBounds.left", 8);
|
| + shouldBeEqualToNumber("entries[0].rootBounds.right", 193);
|
| + shouldBeEqualToNumber("entries[0].rootBounds.top", 8);
|
| + shouldBeEqualToNumber("entries[0].rootBounds.bottom", 208);
|
| + shouldEvaluateToSameObject("entries[0].target", target);
|
| }
|
| + target.style.top = "250px";
|
| + requestAnimationFrame(step2);
|
| +}
|
|
|
| - function step3() {
|
| - setTimeout(function() {
|
| - shouldBeEqualToNumber("entries.length", 2);
|
| - target.style.top = "250px";
|
| - requestAnimationFrame(step4);
|
| - });
|
| +function step2() {
|
| + entries = entries.concat(observer.takeRecords());
|
| + shouldBeEqualToNumber("entries.length", 2);
|
| + if (entries.length > 1) {
|
| + shouldBeEqualToNumber("entries[1].boundingClientRect.left", 58);
|
| + shouldBeEqualToNumber("entries[1].boundingClientRect.right", 158);
|
| + shouldBeEqualToNumber("entries[1].boundingClientRect.top", 258);
|
| + shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 358);
|
| + 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", 8);
|
| + shouldBeEqualToNumber("entries[1].rootBounds.right", 193);
|
| + shouldBeEqualToNumber("entries[1].rootBounds.top", 8);
|
| + shouldBeEqualToNumber("entries[1].rootBounds.bottom", 208);
|
| + shouldEvaluateToSameObject("entries[1].target", target);
|
| }
|
| + root.style.position = "static";
|
| + target.style.top = "10px";
|
| + requestAnimationFrame(step3);
|
| +}
|
|
|
| - function step4() {
|
| - setTimeout(function() {
|
| - shouldBeEqualToNumber("entries.length", 2);
|
| - finishJSTest();
|
| - });
|
| - }
|
| +function step3() {
|
| + entries = entries.concat(observer.takeRecords());
|
| + shouldBeEqualToNumber("entries.length", 2);
|
| + target.style.top = "250px";
|
| + requestAnimationFrame(step4);
|
| +}
|
|
|
| - step0();
|
| +function step4() {
|
| + entries = entries.concat(observer.takeRecords());
|
| + shouldBeEqualToNumber("entries.length", 2);
|
| + // See README for explanation of this requestIdleCallback.
|
| + requestIdleCallback(finishJSTest, {timeout: 100});
|
| +}
|
| </script>
|
|
|