Index: third_party/WebKit/LayoutTests/intersection-observer/resources/cross-origin-subframe.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/intersection-observer/resources/cross-origin-subframe.html b/third_party/WebKit/LayoutTests/intersection-observer/resources/cross-origin-subframe.html |
similarity index 58% |
rename from third_party/WebKit/LayoutTests/http/tests/intersection-observer/resources/cross-origin-subframe.html |
rename to third_party/WebKit/LayoutTests/intersection-observer/resources/cross-origin-subframe.html |
index edf34dcd2a591c09c7d4cc213bf175104acaf8ad..74168340d4b9624c9bfceaa07c87482b2347a1dc 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/intersection-observer/resources/cross-origin-subframe.html |
+++ b/third_party/WebKit/LayoutTests/intersection-observer/resources/cross-origin-subframe.html |
@@ -1,8 +1,8 @@ |
<!DOCTYPE html> |
-<script src="/js-test-resources/intersection-observer-helper-functions.js"></script> |
<div style="height: 200px; width: 100px;"></div> |
<div id="target" style="background-color: green; width:100px; height:100px"></div> |
<div style="height: 200px; width: 100px;"></div> |
+ |
<script> |
var port; |
var entries = []; |
@@ -10,28 +10,64 @@ var target = document.getElementById('target'); |
var scroller = document.scrollingElement; |
var nextStep; |
+function clientRectToJson(rect) { |
+ if (!rect) |
+ return "null"; |
+ return { |
+ top: rect.top, |
+ right: rect.right, |
+ bottom: rect.bottom, |
+ left: rect.left |
+ }; |
+} |
+ |
+function entryToJson(entry) { |
+ return { |
+ boundingClientRect: clientRectToJson(entry.boundingClientRect), |
+ intersectionRect: clientRectToJson(entry.intersectionRect), |
+ rootBounds: clientRectToJson(entry.rootBounds), |
+ target: entry.target.id |
+ }; |
+} |
+ |
+function coordinatesToClientRectJson(top, right, bottom, left) { |
+ return { |
+ top: top, |
+ right: right, |
+ bottom: bottom, |
+ left: left |
+ }; |
+} |
+ |
// Note that we never use RAF in this code, because this frame might get render-throttled. |
// Instead of RAF-ing, we just post an empty message to the parent window, which will |
// RAF when it is received, and then send us a message to cause the next step to run. |
// Use a rootMargin here, and verify it does NOT get applied for the cross-origin case. |
-var observer = new IntersectionObserver( |
- changes => { entries = entries.concat(changes) }, |
- { rootMargin: "7px" } |
-); |
+var observer = new IntersectionObserver(function(changes) { |
+ entries = entries.concat(changes) |
+}, { rootMargin: "7px" }); |
observer.observe(target); |
function step0() { |
entries = entries.concat(observer.takeRecords()); |
nextStep = step1; |
- port.postMessage({actual: entries.map(entryToJson), expected: []}, "*"); |
+ port.postMessage({ |
+ actual: entries.map(entryToJson), |
+ expected: [], |
+ description: "First rAF" |
+ }, "*"); |
entries = []; |
port.postMessage({scrollTo: 200}, "*"); |
} |
function step1() { |
entries = entries.concat(observer.takeRecords()); |
- port.postMessage({actual: entries.map(entryToJson), expected: []}, "*"); |
+ port.postMessage({ |
+ actual: entries.map(entryToJson), |
+ expected: [], |
+ description: "topDocument.scrollingElement.scrollTop = 200" |
+ }, "*"); |
entries = []; |
scroller.scrollTop = 250; |
nextStep = step2; |
@@ -46,7 +82,11 @@ function step2() { |
rootBounds: "null", |
target: target.id |
}]; |
- port.postMessage({actual: entries.map(entryToJson), expected: expected}, "*"); |
+ port.postMessage({ |
+ actual: entries.map(entryToJson), |
+ expected: expected, |
+ description: "iframeDocument.scrollingElement.scrollTop = 250" |
+ }, "*"); |
entries = []; |
nextStep = step3; |
port.postMessage({scrollTo: 100}, "*"); |
@@ -60,7 +100,11 @@ function step3() { |
rootBounds: "null", |
target: target.id |
}]; |
- port.postMessage({actual: entries.map(entryToJson), expected: expected}, "*"); |
+ port.postMessage({ |
+ actual: entries.map(entryToJson), |
+ expected: expected, |
+ description: "topDocument.scrollingElement.scrollTop = 100" |
+ }, "*"); |
port.postMessage({DONE: 1}, "*"); |
} |