| Index: third_party/WebKit/LayoutTests/intersection-observer/edge-inclusive-intersection.html
|
| diff --git a/third_party/WebKit/LayoutTests/intersection-observer/edge-inclusive-intersection.html b/third_party/WebKit/LayoutTests/intersection-observer/edge-inclusive-intersection.html
|
| index 10e9f3e55e4302fe3a8708d400b7ef5a9a033bd5..7d6f6e0a80d23251e52dce8d6877128712c8b9d5 100644
|
| --- a/third_party/WebKit/LayoutTests/intersection-observer/edge-inclusive-intersection.html
|
| +++ b/third_party/WebKit/LayoutTests/intersection-observer/edge-inclusive-intersection.html
|
| @@ -1,6 +1,6 @@
|
| <!DOCTYPE html>
|
| -<script src="../resources/js-test.js"></script>
|
| -<script src="../resources/intersection-observer-helper-functions.js"></script>
|
| +<script src="../resources/testharness.js"></script>
|
| +<script src="../resources/testharnessreport.js"></script>
|
| <style>
|
| #root {
|
| width: 200px;
|
| @@ -16,74 +16,86 @@
|
| </div>
|
|
|
| <script>
|
| -description("Verifies that IntersectionObserver detects edge-inclusive intersections.");
|
| -var root = document.getElementById('root');
|
| -var target = document.getElementById('target');
|
| -var entries = [];
|
| -var observer = new IntersectionObserver(
|
| - changes => { entries.push(...changes) },
|
| - { root: root }
|
| -);
|
| +function waitForNotification(f) {
|
| + requestAnimationFrame(() => {
|
| + setTimeout(() => {
|
| + setTimeout(f);
|
| + });
|
| + });
|
| +}
|
|
|
| onload = function() {
|
| + var t = async_test("Verifies that IntersectionObserver detects edge-inclusive intersections.");
|
| +
|
| + test(function() { assert_equals(window.innerWidth, 800) }, "Window must be 800 pixels wide.");
|
| + test(function() { assert_equals(window.innerHeight, 600) }, "Window must be 600 pixels high.");
|
| +
|
| + var root = document.getElementById('root');
|
| + var target = document.getElementById('target');
|
| + var entries = [];
|
| + var observer = new IntersectionObserver(function(changes) {
|
| + entries = entries.concat(changes);
|
| + }, { root: root });
|
| observer.observe(target);
|
| - entries.push(...observer.takeRecords());
|
| - shouldBeEqualToNumber("entries.length", 0);
|
| + entries = entries.concat(observer.takeRecords());
|
| + test(function() { assert_equals(entries.length, 0) }, "No initial notifications.");
|
| waitForNotification(step0);
|
| -};
|
|
|
| -function step0() {
|
| - shouldBeEqualToNumber("entries.length", 0);
|
| - waitForNotification(step1);
|
| - target.style.transform = "translateY(200px)";
|
| -}
|
| + function checkEntry(i, expected) {
|
| + test(function() { assert_equals(entries.length, i+1) }, String(i+1) + " notification(s).");
|
| + if (expected && entries.length > i) {
|
| + test(function() { assert_equals(entries[i].boundingClientRect.left, expected[0]) },
|
| + "entries[" + i + "].boundingClientRect.left == " + expected[0]);
|
| + test(function() { assert_equals(entries[i].boundingClientRect.right, expected[1]) },
|
| + "entries[" + i + "].boundingClientRect.right == " + expected[1]);
|
| + test(function() { assert_equals(entries[i].boundingClientRect.top, expected[2]) },
|
| + "entries[" + i + "].boundingClientRect.top == " + expected[2]);
|
| + test(function() { assert_equals(entries[i].boundingClientRect.bottom, expected[3]) },
|
| + "entries[" + i + "].boundingClientRect.bottom == " + expected[3]);
|
| + test(function() { assert_equals(entries[i].intersectionRect.left, expected[4]) },
|
| + "entries[" + i + "].intersectionRect.left == " + expected[4]);
|
| + test(function() { assert_equals(entries[i].intersectionRect.right, expected[5]) },
|
| + "entries[" + i + "].intersectionRect.right == " + expected[5]);
|
| + test(function() { assert_equals(entries[i].intersectionRect.top, expected[6]) },
|
| + "entries[" + i + "].intersectionRect.top == " + expected[6]);
|
| + test(function() { assert_equals(entries[i].intersectionRect.bottom, expected[7]) },
|
| + "entries[" + i + "].intersectionRect.bottom == " + expected[7]);
|
| + test(function() { assert_equals(entries[i].rootBounds.left, expected[8]) },
|
| + "entries[" + i + "].rootBounds.left == " + expected[8]);
|
| + test(function() { assert_equals(entries[i].rootBounds.right, expected[9]) },
|
| + "entries[" + i + "].rootBounds.right == " + expected[9]);
|
| + test(function() { assert_equals(entries[i].rootBounds.top, expected[10]) },
|
| + "entries[" + i + "].rootBounds.top == " + expected[10]);
|
| + test(function() { assert_equals(entries[i].rootBounds.bottom, expected[11]) },
|
| + "entries[" + i + "].rootBounds.bottom == " + expected[11]);
|
| + test(function() { assert_true(entries[i].target === expected[12]) },
|
| + "entries[" + i + "].target === " + expected[12]);
|
| + }
|
| + }
|
|
|
| -function step1() {
|
| - shouldBeEqualToNumber("entries.length", 1);
|
| - if (entries.length > 0) {
|
| - shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8);
|
| - shouldBeEqualToNumber("entries[0].boundingClientRect.right", 108);
|
| - shouldBeEqualToNumber("entries[0].boundingClientRect.top", 208);
|
| - shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 308);
|
| - shouldBeEqualToNumber("entries[0].intersectionRect.left", 8);
|
| - shouldBeEqualToNumber("entries[0].intersectionRect.right", 108);
|
| - shouldBeEqualToNumber("entries[0].intersectionRect.top", 208);
|
| - shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 208);
|
| - shouldBeEqualToNumber("entries[0].rootBounds.left", 8);
|
| - shouldBeEqualToNumber("entries[0].rootBounds.right", 208);
|
| - shouldBeEqualToNumber("entries[0].rootBounds.top", 8);
|
| - shouldBeEqualToNumber("entries[0].rootBounds.bottom", 208);
|
| - shouldEvaluateToSameObject("entries[0].target", target);
|
| + function step0() {
|
| + test(function() { assert_equals(entries.length, 0) }, "entries.length == 0");
|
| + target.style.transform = "translateY(200px)";
|
| + waitForNotification(step1);
|
| }
|
| - waitForNotification(step2);
|
| - target.style.transform = "translateY(201px)";
|
| -}
|
|
|
| -function step2() {
|
| - shouldBeEqualToNumber("entries.length", 2);
|
| - waitForNotification(step3);
|
| - target.style.height = "0px";
|
| - target.style.width = "300px";
|
| - target.style.transform = "translateY(185px)";
|
| -}
|
| + function step1() {
|
| + checkEntry(0, [8, 108, 208, 308, 8, 108, 208, 208, 8, 208, 8, 208, target]);
|
| + target.style.transform = "translateY(201px)";
|
| + waitForNotification(step2);
|
| + }
|
|
|
| -function step3() {
|
| - shouldBeEqualToNumber("entries.length", 3);
|
| - if (entries.length > 2) {
|
| - shouldBeEqualToNumber("entries[2].boundingClientRect.left", 8);
|
| - shouldBeEqualToNumber("entries[2].boundingClientRect.right", 308);
|
| - shouldBeEqualToNumber("entries[2].boundingClientRect.top", 193);
|
| - shouldBeEqualToNumber("entries[2].boundingClientRect.bottom", 193);
|
| - shouldBeEqualToNumber("entries[2].intersectionRect.left", 8);
|
| - shouldBeEqualToNumber("entries[2].intersectionRect.right", 208);
|
| - shouldBeEqualToNumber("entries[2].intersectionRect.top", 193);
|
| - shouldBeEqualToNumber("entries[2].intersectionRect.bottom", 193);
|
| - shouldBeEqualToNumber("entries[2].rootBounds.left", 8);
|
| - shouldBeEqualToNumber("entries[2].rootBounds.right", 208);
|
| - shouldBeEqualToNumber("entries[2].rootBounds.top", 8);
|
| - shouldBeEqualToNumber("entries[2].rootBounds.bottom", 208);
|
| - shouldEvaluateToSameObject("entries[2].target", target);
|
| + function step2() {
|
| + checkEntry(1);
|
| + target.style.height = "0px";
|
| + target.style.width = "300px";
|
| + target.style.transform = "translateY(185px)";
|
| + waitForNotification(step3);
|
| }
|
| - finishJSTest();
|
| -}
|
| +
|
| + function step3() {
|
| + checkEntry(2, [8, 308, 193, 193, 8, 208, 193, 193, 8, 208, 8, 208, target]);
|
| + t.done();
|
| + }
|
| +};
|
| </script>
|
|
|