Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: third_party/WebKit/LayoutTests/intersection-observer/cross-origin-iframe.html

Issue 2560253004: IntersectionObserver: convert tests to testharness.js (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/intersection-observer/cross-origin-iframe.html
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/cross-origin-iframe.html b/third_party/WebKit/LayoutTests/intersection-observer/cross-origin-iframe.html
new file mode 100644
index 0000000000000000000000000000000000000000..a9e0fe0788a1220dc216246dd2d82ad0b7c25832
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/intersection-observer/cross-origin-iframe.html
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<style>
+iframe {
+ height: 100px;
+ overflow-y: scroll;
+}
+</style>
+
+<div id="leading-space" style="width:100%; height:700px;"></div>
+<iframe src="resources/cross-origin-subframe.html" sandbox="allow-scripts"></iframe>
+<div id="trailing-space" style="width:100%; height:700px;"></div>
+
+<script>
+function waitForNotification(f) {
+ requestAnimationFrame(() => {
+ setTimeout(() => {
+ setTimeout(f);
+ });
+ });
+}
+
+function checkEntries(actual, expected) {
+ test(function() { assert_equals(actual.length, expected.length) }, String(actual.length) + " notification(s).");
+ for (var i = 0; i < actual.length && i < expected.length; i++) {
+ test(function() { assert_equals(actual[i].boundingClientRect.left, expected[i].boundingClientRect.left) },
+ "entries[" + i + "].boundingClientRect.left == " + expected[i].boundingClientRect.left);
+ test(function() { assert_equals(actual[i].boundingClientRect.right, expected[i].boundingClientRect.right) },
+ "entries[" + i + "].boundingClientRect.right == " + expected[i].boundingClientRect.right);
+ test(function() { assert_equals(actual[i].boundingClientRect.top, expected[i].boundingClientRect.top) },
+ "entries[" + i + "].boundingClientRect.top == " + expected[i].boundingClientRect.top);
+ test(function() { assert_equals(actual[i].boundingClientRect.bottom, expected[i].boundingClientRect.bottom) },
+ "entries[" + i + "].boundingClientRect.bottom == " + expected[i].boundingClientRect.bottom);
+ test(function() { assert_equals(actual[i].intersectionRect.left, expected[i].intersectionRect.left) },
+ "entries[" + i + "].intersectionRect.left == " + expected[i].intersectionRect.left);
+ test(function() { assert_equals(actual[i].intersectionRect.right, expected[i].intersectionRect.right) },
+ "entries[" + i + "].intersectionRect.right == " + expected[i].intersectionRect.right);
+ test(function() { assert_equals(actual[i].intersectionRect.top, expected[i].intersectionRect.top) },
+ "entries[" + i + "].intersectionRect.top == " + expected[i].intersectionRect.top);
+ test(function() { assert_equals(actual[i].intersectionRect.bottom, expected[i].intersectionRect.bottom) },
+ "entries[" + i + "].intersectionRect.bottom == " + expected[i].intersectionRect.bottom);
+ if (expected[i].rootBounds == "null") {
+ test(function() { assert_equals(actual[i].rootBounds, null) },
+ "actual[" + i + "].rootBonds == null");
+ } else if (actual[i].rootBounds == null) {
+ test(function() { assert_not_equals(actual[i].rootBounds, null) },
+ "actual[" + i + "].rootBonds != null");
+ } else {
+ test(function() { assert_equals(actual[i].rootBounds.left, expected[i].rootBounds.left) },
+ "entries[" + i + "].rootBounds.left == " + expected[i].rootBounds.left);
+ test(function() { assert_equals(actual[i].rootBounds.right, expected[i].rootBounds.right) },
+ "entries[" + i + "].rootBounds.right == " + expected[i].rootBounds.right);
+ test(function() { assert_equals(actual[i].rootBounds.top, expected[i].rootBounds.top) },
+ "entries[" + i + "].rootBounds.top == " + expected[i].rootBounds.top);
+ test(function() { assert_equals(actual[i].rootBounds.bottom, expected[i].rootBounds.bottom) },
+ "entries[" + i + "].rootBounds.bottom == " + expected[i].rootBounds.bottom);
+ }
+ test(function() { assert_equals(actual[i].target, expected[i].target) },
+ "entries[" + i + "].target.id == " + expected[i].target);
+ }
+}
+
+var iframe = document.querySelector("iframe");
+console.log("iframe =" + iframe);
+iframe.onload = (() => {
+ waitForNotification(() => { iframe.contentWindow.postMessage("", "*") });
+});
+
+onload = function() {
+ var t = async_test("Intersection observer test with no explicit root and target in a cross-origin iframe.");
+
+ 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.");
+
+ function handleMessage(event) {
+ console.log(event);
+ if (event.data.hasOwnProperty('scrollTo')) {
+ document.scrollingElement.scrollTop = event.data.scrollTo;
+ waitForNotification(() => { iframe.contentWindow.postMessage("", "*") });
+ } else if (event.data.hasOwnProperty('actual')) {
+ checkEntries(event.data.actual, event.data.expected);
+ } else if (event.data.hasOwnProperty('DONE')) {
+ document.getElementById("leading-space").style.height = "";
+ document.getElementById("trailing-space").style.height = "";
+ document.scrollingElement.scrollTop = 0;
+ t.done();
+ } else {
+ waitForNotification(() => { iframe.contentWindow.postMessage("", "*") });
+ }
+ }
+
+ window.addEventListener("message", handleMessage);
+};
+</script>

Powered by Google App Engine
This is Rietveld 408576698