| Index: third_party/WebKit/LayoutTests/intersection-observer/multiple-targets.html
|
| diff --git a/third_party/WebKit/LayoutTests/intersection-observer/multiple-targets.html b/third_party/WebKit/LayoutTests/intersection-observer/multiple-targets.html
|
| index 91b03e1c6f73a54d27028573c2604695b8f41389..6c75d6e6f0c1de685105d9cd7861e12a1151edfb 100644
|
| --- a/third_party/WebKit/LayoutTests/intersection-observer/multiple-targets.html
|
| +++ b/third_party/WebKit/LayoutTests/intersection-observer/multiple-targets.html
|
| @@ -1,7 +1,17 @@
|
| <!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>
|
| +<script src="./resources/intersection-observer-test-utils.js"></script>
|
| +
|
| <style>
|
| +pre, #log {
|
| + position: absolute;
|
| + top: 0;
|
| + left: 200px;
|
| +}
|
| +.spacer {
|
| + height: 700px;
|
| +}
|
| .target {
|
| width: 100px;
|
| height: 100px;
|
| @@ -9,57 +19,62 @@
|
| background-color: green;
|
| }
|
| </style>
|
| -<div style="width:100%; height:700px;"></div>
|
| +
|
| +<div class="spacer"></div>
|
| <div id="target1" class="target"></div>
|
| <div id="target2" class="target"></div>
|
| <div id="target3" class="target"></div>
|
|
|
| <script>
|
| -description("Verify that notifications for multiple targets are sorted by the order in which observe() was called on each target.");
|
| -var target1 = document.getElementById("target1");
|
| -var target2 = document.getElementById("target2");
|
| -var target3 = document.getElementById("target3");
|
| var entries = [];
|
| -var observer = new IntersectionObserver(
|
| - changes => { entries.push(...changes); }
|
| -);
|
| +var target1, target2, target3;
|
| +
|
| +runTestCycle(function() {
|
| + assert_equals(window.innerWidth, 800, "Window must be 800 pixels wide.");
|
| + assert_equals(window.innerHeight, 600, "Window must be 600 pixels high.");
|
|
|
| -onload = function() {
|
| + target1 = document.getElementById("target1");
|
| + assert_true(!!target1, "target1 exists.");
|
| + target2 = document.getElementById("target2");
|
| + assert_true(!!target2, "target2 exists.");
|
| + target3 = document.getElementById("target3");
|
| + assert_true(!!target3, "target3 exists.");
|
| + var observer = new IntersectionObserver(function(changes) {
|
| + entries = entries.concat(changes)
|
| + });
|
| observer.observe(target1);
|
| observer.observe(target2);
|
| observer.observe(target3);
|
| entries = entries.concat(observer.takeRecords());
|
| - shouldBeEqualToNumber("entries.length", 0);
|
| + assert_equals(entries.length, 0, "No initial notifications.");
|
| + runTestCycle(step0, "No notifications after first rAF.");
|
| +}, "One observer with multiple targets.");
|
| +
|
| +function step0() {
|
| document.scrollingElement.scrollTop = 150;
|
| - waitForNotification(step0);
|
| + runTestCycle(step1, "document.scrollingElement.scrollTop = 150");
|
| + assert_equals(entries.length, 0, "No notifications.");
|
| }
|
|
|
| -function step0() {
|
| - shouldBeEqualToNumber("entries.length", 1);
|
| - if (entries.length > 0)
|
| - shouldBeEqualToString("entries[0].target.id", "target1");
|
| +function step1() {
|
| document.scrollingElement.scrollTop = 10000;
|
| - waitForNotification(step1);
|
| + runTestCycle(step2, "document.scrollingElement.scrollTop = 10000");
|
| + assert_equals(entries.length, 1, "One notification.");
|
| + assert_equals(entries[0].target, target1, "entries[0].target === target1");
|
| }
|
|
|
| -function step1() {
|
| - shouldBeEqualToNumber("entries.length", 3);
|
| - if (entries.length > 1)
|
| - shouldBeEqualToString("entries[1].target.id", "target2");
|
| - if (entries.length > 2)
|
| - shouldBeEqualToString("entries[2].target.id", "target3");
|
| +function step2() {
|
| document.scrollingElement.scrollTop = 0;
|
| - waitForNotification(step2);
|
| + runTestCycle(step3, "document.scrollingElement.scrollTop = 0");
|
| + assert_equals(entries.length, 3, "Three notifications.");
|
| + assert_equals(entries[1].target, target2, "entries[1].target === target2");
|
| + assert_equals(entries[2].target, target3, "entries[2].target === target3");
|
| }
|
|
|
| -function step2() {
|
| - shouldBeEqualToNumber("entries.length", 6);
|
| - if (entries.length > 3)
|
| - shouldBeEqualToString("entries[3].target.id", "target1");
|
| - if (entries.length > 4)
|
| - shouldBeEqualToString("entries[4].target.id", "target2");
|
| - if (entries.length > 5)
|
| - shouldBeEqualToString("entries[5].target.id", "target3");
|
| - finishJSTest();
|
| +function step3() {
|
| + assert_equals(entries.length, 6, "Six notifications.");
|
| + assert_equals(entries[3].target, target1, "entries[3].target === target1");
|
| + assert_equals(entries[4].target, target2, "entries[4].target === target2");
|
| + assert_equals(entries[5].target, target3, "entries[5].target === target3");
|
| }
|
| </script>
|
|
|