Index: third_party/WebKit/LayoutTests/intersection-observer/shadow-content.html |
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/shadow-content.html b/third_party/WebKit/LayoutTests/intersection-observer/shadow-content.html |
index 7a990e30f803604f5774af20ae4425a5999ba42c..8c211b97f9d9aaefe4062329890e1ab95c12de91 100644 |
--- a/third_party/WebKit/LayoutTests/intersection-observer/shadow-content.html |
+++ b/third_party/WebKit/LayoutTests/intersection-observer/shadow-content.html |
@@ -1,44 +1,44 @@ |
<!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; |
+} |
+</style> |
+ |
<div id="host"></div> |
<script> |
-description("Tests that observations can be made across shadow DOM boundaries."); |
var entries = []; |
var target; |
-var observer = new IntersectionObserver(changes => { entries = entries.concat(changes) }); |
-onload = function() { |
- let shadowHost = document.getElementById("host"); |
- let shadowRoot = shadowHost.createShadowRoot(); |
- target = document.createElement('div'); |
- target.style.cssText = "background-color: green; width:100px; height:100px"; |
- shadowRoot.appendChild(target); |
- observer.observe(target); |
+runTestCycle(function() { |
+ assert_equals(window.innerWidth, 800, "Window must be 800 pixels wide."); |
+ assert_equals(window.innerHeight, 600, "Window must be 600 pixels high."); |
+ |
+ var shadowHost = document.getElementById("host"); |
+ assert_true(!!shadowHost, "Host exists"); |
+ var shadowRoot = shadowHost.createShadowRoot(); |
+ assert_true(!!shadowRoot, "Shadow root exists"); |
+ shadowRoot.innerHTML = "<div id='target' style='width: 100px; height: 100px; background-color: green;'></div>"; |
+ target = shadowRoot.getElementById("target"); |
+ assert_true(!!target, "target exists"); |
+ var observer = new IntersectionObserver(function(changes) { |
+ entries = entries.concat(changes) |
+ }); |
+ observer.observe(target); |
entries = entries.concat(observer.takeRecords()); |
- shouldBeEqualToNumber("entries.length", 0); |
- waitForNotification(step1); |
-}; |
+ assert_equals(entries.length, 0, "No initial notifications."); |
+ runTestCycle(step0, "First rAF after creating shadow DOM."); |
+}, "Observing a target inside shadow DOM."); |
-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", 8); |
- shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 108); |
- shouldBeEqualToNumber("entries[0].intersectionRect.left", 8); |
- shouldBeEqualToNumber("entries[0].intersectionRect.right", 108); |
- shouldBeEqualToNumber("entries[0].intersectionRect.top", 8); |
- shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 108); |
- shouldBeEqualToNumber("entries[0].rootBounds.left", 0); |
- shouldBeEqualToNumber("entries[0].rootBounds.right", 800); |
- shouldBeEqualToNumber("entries[0].rootBounds.top", 0); |
- shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600); |
- shouldEvaluateToSameObject("entries[0].target", target); |
- } |
- finishJSTest(); |
+function step0() { |
+ checkLastEntry(entries, 0, [8, 108, 8, 108, 8, 108, 8, 108, 0, 800, 0, 600, target]); |
} |
</script> |