Index: third_party/WebKit/LayoutTests/intersection-observer/unclipped-root.html |
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/unclipped-root.html b/third_party/WebKit/LayoutTests/intersection-observer/unclipped-root.html |
index c11ae11ee565e5d6642f9580e35b6aa9a0ccf768..40d39ca4bd9250591c250b87ae2bd3a05633dd5a 100644 |
--- a/third_party/WebKit/LayoutTests/intersection-observer/unclipped-root.html |
+++ b/third_party/WebKit/LayoutTests/intersection-observer/unclipped-root.html |
@@ -1,11 +1,18 @@ |
<!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; |
+} |
#root { |
overflow: visible; |
height: 200px; |
- width: 200px; |
+ width: 160px; |
border: 7px solid black; |
} |
#target { |
@@ -14,51 +21,37 @@ |
background-color: green; |
} |
</style> |
+ |
<div id="root"> |
<div id="target" style="transform: translateY(300px)"></div> |
</div> |
<script> |
-description("Test that border bounding box is used to calculate intersection with a non-scrolling root."); |
-var target = document.getElementById("target"); |
-var root = document.getElementById("root"); |
var entries = []; |
-var observer = new IntersectionObserver( |
- changes => { entries.push(...changes) }, |
- { root: document.getElementById("root") } |
-); |
+var target; |
-onload = function() { |
+runTestCycle(function() { |
+ target = document.getElementById("target"); |
+ assert_true(!!target, "target exists"); |
+ var root = document.getElementById("root"); |
+ assert_true(!!root, "root exists"); |
+ var observer = new IntersectionObserver(function(changes) { |
+ entries = entries.concat(changes) |
+ }, {root: root}); |
observer.observe(target); |
- entries.push(...observer.takeRecords()); |
- shouldBeEqualToNumber("entries.length", 0); |
- waitForNotification(step0); |
-} |
+ entries = entries.concat(observer.takeRecords()); |
+ assert_equals(entries.length, 0, "No initial notifications."); |
+ runTestCycle(step0, "First rAF should not generate notifications."); |
+}, "Test that border bounding box is used to calculate intersection with a non-scrolling root."); |
function step0() { |
- shouldBeEqualToNumber("entries.length", 0); |
target.style.transform = "translateY(195px)"; |
- waitForNotification(step1); |
+ runTestCycle(step1, "target.style.transform = 'translateY(195px)'"); |
+ assert_equals(entries.length, 0, "No notifications after first rAF."); |
} |
function step1() { |
- shouldBeEqualToNumber("entries.length", 1); |
- if (entries.length > 0) { |
- shouldBeEqualToNumber("entries[0].boundingClientRect.left", 15); |
- shouldBeEqualToNumber("entries[0].boundingClientRect.right", 115); |
- shouldBeEqualToNumber("entries[0].boundingClientRect.top", 210); |
- shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 310); |
- shouldBeEqualToNumber("entries[0].intersectionRect.left", 15); |
- shouldBeEqualToNumber("entries[0].intersectionRect.right", 115); |
- shouldBeEqualToNumber("entries[0].intersectionRect.top", 210); |
- shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 222); |
- shouldBeEqualToNumber("entries[0].rootBounds.left", 8); |
- shouldBeEqualToNumber("entries[0].rootBounds.right", 222); |
- shouldBeEqualToNumber("entries[0].rootBounds.top", 8); |
- shouldBeEqualToNumber("entries[0].rootBounds.bottom", 222); |
- shouldEvaluateToSameObject("entries[0].target", target); |
- } |
- |
- finishJSTest(); |
+ target.style.transform = ""; |
+ checkLastEntry(entries, 0, [15, 115, 210, 310, 15, 115, 210, 222, 8, 182, 8, 222, target]); |
} |
</script> |