Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (271233 => 271234)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-01-07 10:11:26 UTC (rev 271233)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-01-07 10:38:53 UTC (rev 271234)
@@ -1,3 +1,29 @@
+2021-01-07 Cathie Chen <[email protected]>
+
+ Update WPT test suite for intersection-observer
+ https://bugs.webkit.org/show_bug.cgi?id=220403
+
+ Reviewed by Rob Buis.
+
+ Sync WPT intersection-observer tests with 5a3a1b414d32952355eae7c949c109424979b988.
+
+ * web-platform-tests/intersection-observer/cross-document-root-expected.txt: Added.
+ * web-platform-tests/intersection-observer/cross-document-root.html: Added.
+ * web-platform-tests/intersection-observer/explicit-root-different-document.tentative-expected.txt: Added.
+ * web-platform-tests/intersection-observer/explicit-root-different-document.tentative.html: Added.
+ * web-platform-tests/intersection-observer/intersection-ratio-ib-split.html:
+ * web-platform-tests/intersection-observer/not-in-containing-block-chain.tentative-expected.txt: Added.
+ * web-platform-tests/intersection-observer/not-in-containing-block-chain.tentative.html: Added.
+ * web-platform-tests/intersection-observer/observer-attributes-expected.txt:
+ * web-platform-tests/intersection-observer/observer-attributes.html:
+ * web-platform-tests/intersection-observer/resources/cross-origin-child-iframe.sub.html:
+ * web-platform-tests/intersection-observer/resources/same-origin-grand-child-iframe.html:
+ * web-platform-tests/intersection-observer/same-document-with-document-root-expected.txt: Added.
+ * web-platform-tests/intersection-observer/same-document-with-document-root.html: Added.
+ * web-platform-tests/intersection-observer/same-origin-grand-child-iframe.sub.html:
+ * web-platform-tests/intersection-observer/target-in-different-window.html:
+ * web-platform-tests/intersection-observer/w3c-import.log:
+
2021-01-06 Youenn Fablet <[email protected]>
REGRESSION (r267227): imported/w3c/web-platform-tests/xhr/event-timeout.any.html is a flaky failure
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/cross-document-root-expected.txt (0 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/cross-document-root-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/cross-document-root-expected.txt 2021-01-07 10:38:53 UTC (rev 271234)
@@ -0,0 +1,4 @@
+
+PASS Observer with explicit root which is the document, observing a target in a same-origin iframe.
+PASS First rAF.
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/cross-document-root.html (0 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/cross-document-root.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/cross-document-root.html 2021-01-07 10:38:53 UTC (rev 271234)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<meta name="viewport" content="width=device-width,initial-scale=1">
+<link rel="author" href="" title="Stefan Zager">
+<link rel="help" href=""
+
+<script src=""
+<script src=""
+<script src=""
+
+<style>
+pre, #log {
+ position: absolute;
+ top: 0;
+ left: 200px;
+}
+iframe {
+ height: 250px;
+ width: 150px;
+ border: 0;
+}
+</style>
+<iframe id="target-iframe" src=""
+
+<script>
+var iframe = document.getElementById("target-iframe");
+var target;
+var root;
+var entries = [];
+
+iframe._onload_ = function() {
+ runTestCycle(function() {
+ assert_true(!!iframe, "iframe exists");
+
+ target = iframe.contentDocument.getElementById("target");
+ assert_true(!!target, "Target element exists.");
+ var observer = new IntersectionObserver(function(changes) {
+ entries = entries.concat(changes)
+ }, { root: document });
+ observer.observe(target);
+ entries = entries.concat(observer.takeRecords());
+ assert_equals(entries.length, 0, "No initial notifications.");
+ runTestCycle(step0, "First rAF.");
+ }, "Observer with explicit root which is the document, observing a target in a same-origin iframe.");
+};
+
+function step0() {
+ checkLastEntry(entries, 0, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false]);
+}
+</script>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/explicit-root-different-document.tentative-expected.txt (0 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/explicit-root-different-document.tentative-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/explicit-root-different-document.tentative-expected.txt 2021-01-07 10:38:53 UTC (rev 271234)
@@ -0,0 +1,3 @@
+
+PASS IntersectionObserver reports a (non-intersecting) entry if different-document from the doc
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/explicit-root-different-document.tentative.html (0 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/explicit-root-different-document.tentative.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/explicit-root-different-document.tentative.html 2021-01-07 10:38:53 UTC (rev 271234)
@@ -0,0 +1,27 @@
+<!doctype html>
+<meta name="viewport" content="width=device-width,initial-scale=1">
+<script src=""
+<script src=""
+<link rel="help" href=""
+<style>
+ div {
+ width: 100px;
+ height: 100px;
+ background: blue;
+ margin: 10px
+ }
+</style>
+<div id="root"></div>
+<script>
+let t = async_test("IntersectionObserver reports a (non-intersecting) entry if different-document from the doc");
+let doc = document.implementation.createHTMLDocument("");
+let target = doc.createElement("div");
+doc.body.appendChild(target);
+new IntersectionObserver(
+ t.step_func_done(function(records) {
+ assert_equals(records.length, 1);
+ assert_false(records[0].isIntersecting);
+ }),
+ { root: document.querySelector("#root") }
+).observe(target);
+</script>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/intersection-ratio-ib-split.html (271233 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/intersection-ratio-ib-split.html 2021-01-07 10:11:26 UTC (rev 271233)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/intersection-ratio-ib-split.html 2021-01-07 10:38:53 UTC (rev 271234)
@@ -26,6 +26,16 @@
assert_equals(entries.length, 1, element.nodeName + ": Should get an entry");
assert_true(entries[0].isIntersecting, element.nodeName + ": Should be intersecting");
assert_equals(entries[0].intersectionRatio, 1, element.nodeName + ": Should be fully intersecting");
+
+ function assert_rects_equal(r1, r2, label) {
+ assert_equals(r1.top, r2.top, label + ": top should be equal");
+ assert_equals(r1.right, r2.right, label + ": right should be equal");
+ assert_equals(r1.bottom, r2.bottom, label + ": bottom should be equal");
+ assert_equals(r1.left, r2.left, label + ": left should be equal");
+ }
+
+ assert_rects_equal(entries[0].boundingClientRect, element.getBoundingClientRect(), element.nodeName + ": boundingClientRect should match");
+ assert_rects_equal(entries[0].intersectionRect, entries[0].boundingClientRect, element.nodeName + ": intersectionRect should match entry.boundingClientRect");
}
}, "IntersectionObserver on an IB split gets the right intersection ratio");
</script>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/not-in-containing-block-chain.tentative-expected.txt (0 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/not-in-containing-block-chain.tentative-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/not-in-containing-block-chain.tentative-expected.txt 2021-01-07 10:38:53 UTC (rev 271234)
@@ -0,0 +1,3 @@
+
+PASS IntersectionObserver reports a (non-intersecting) entry even if not in the containing block chain
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/not-in-containing-block-chain.tentative.html (0 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/not-in-containing-block-chain.tentative.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/not-in-containing-block-chain.tentative.html 2021-01-07 10:38:53 UTC (rev 271234)
@@ -0,0 +1,25 @@
+<!doctype html>
+<meta name="viewport" content="width=device-width,initial-scale=1">
+<script src=""
+<script src=""
+<link rel="help" href=""
+<style>
+ div {
+ width: 100px;
+ height: 100px;
+ background: blue;
+ margin: 10px
+ }
+</style>
+<div id="target"></div>
+<div id="root"></div>
+<script>
+let t = async_test("IntersectionObserver reports a (non-intersecting) entry even if not in the containing block chain");
+new IntersectionObserver(
+ t.step_func_done(function(records) {
+ assert_equals(records.length, 1);
+ assert_false(records[0].isIntersecting);
+ }),
+ { root: document.querySelector("#root") }
+).observe(document.querySelector("#target"));
+</script>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-attributes-expected.txt (271233 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-attributes-expected.txt 2021-01-07 10:11:26 UTC (rev 271233)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-attributes-expected.txt 2021-01-07 10:38:53 UTC (rev 271234)
@@ -1,9 +1,6 @@
-PASS Observer attribute getters.
+FAIL Observer attribute getters. Failed to construct 'IntersectionObserver': rootMargin must be specified in pixels or percent.
PASS observer.root
PASS observer.thresholds
PASS observer.rootMargin
-PASS set observer.root
-PASS set observer.thresholds
-PASS set observer.rootMargin
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-attributes.html (271233 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-attributes.html 2021-01-07 10:11:26 UTC (rev 271233)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-attributes.html 2021-01-07 10:38:53 UTC (rev 271234)
@@ -15,6 +15,15 @@
test(function() { assert_equals(observer.rootMargin, "0px 0px 0px 0px") },
"observer.rootMargin");
+ observer = new IntersectionObserver(function(e) {}, {
+ rootMargin: " ",
+ threshold: []
+ });
+ test(function() { assert_array_equals(observer.thresholds, [0]) },
+ "empty observer.thresholds");
+ test(function() { assert_equals(observer.rootMargin, "0px 0px 0px 0px") },
+ "whitespace observer.rootMargin");
+
var rootDiv = document.getElementById("root");
observer = new IntersectionObserver(function(e) {}, {
root: rootDiv,
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/resources/cross-origin-child-iframe.sub.html (271233 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/resources/cross-origin-child-iframe.sub.html 2021-01-07 10:11:26 UTC (rev 271233)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/resources/cross-origin-child-iframe.sub.html 2021-01-07 10:38:53 UTC (rev 271234)
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<script src=""
-<iframe id="iframe"></iframe>
+<iframe scrolling="no" frameborder="0" id="iframe"></iframe>
<script>
iframe.src =
""> get_host_info().ORIGIN + "/intersection-observer/resources/same-origin-grand-child-iframe.html";
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/resources/same-origin-grand-child-iframe.html (271233 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/resources/same-origin-grand-child-iframe.html 2021-01-07 10:11:26 UTC (rev 271233)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/resources/same-origin-grand-child-iframe.html 2021-01-07 10:38:53 UTC (rev 271234)
@@ -1,8 +1,17 @@
<!DOCTYPE html>
-<div id="target"></div>
+<!--
+ target should be fully vertically in-viewport as 100px is way less than the
+ default iframe height.
+
+ right: 0 makes sure that we're occluded by 8px by the intermediate iframe.
+-->
+<div id="target" style="width: 100px; height: 100px; position: absolute; right: 0"></div>
<script>
const observer = new IntersectionObserver(records => {
- window.top.postMessage(records[0].rootBounds, "*");
+ if (records[0].isIntersecting) {
+ let { rootBounds, intersectionRect } = records[0];
+ window.top.postMessage({ rootBounds, intersectionRect }, "*");
+ }
}, {});
-observer.observe(target);
+observer.observe(document.getElementById("target"));
</script>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-with-document-root-expected.txt (0 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-with-document-root-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-with-document-root-expected.txt 2021-01-07 10:38:53 UTC (rev 271234)
@@ -0,0 +1,5 @@
+
+PASS IntersectionObserver in a single document using document as root.
+PASS First rAF.
+FAIL document.scrollingElement.scrollTop = 300 assert_equals: entries.length expected 2 but got 1
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-with-document-root.html (0 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-with-document-root.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-with-document-root.html 2021-01-07 10:38:53 UTC (rev 271234)
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<meta name="viewport" content="width=device-width,initial-scale=1">
+<script src=""
+<script src=""
+<script src=""
+
+<style>
+ pre,
+ #log {
+ position: absolute;
+ top: 0;
+ left: 200px;
+ }
+
+ .spacer {
+ height: calc(100vh + 100px);
+ }
+
+ #target {
+ width: 100px;
+ height: 100px;
+ background-color: green;
+ }
+</style>
+
+<div class="spacer"></div>
+<div id="target"></div>
+<div class="spacer"></div>
+
+<script>
+ var vw = document.documentElement.clientWidth;
+ var vh = document.documentElement.clientHeight;
+
+ var entries = [];
+ var target;
+
+ runTestCycle(function () {
+ target = document.getElementById("target");
+ assert_true(!!target, "target exists");
+ var observer = new IntersectionObserver(function (changes) {
+ entries = entries.concat(changes)
+ }, {root: document});
+ observer.observe(target);
+ entries = entries.concat(observer.takeRecords());
+ assert_equals(entries.length, 0, "No initial notifications.");
+ runTestCycle(step0, "First rAF.");
+ }, "IntersectionObserver in a single document using document as root.");
+
+ function step0() {
+ document.scrollingElement.scrollTop = 300;
+ runTestCycle(step1, "document.scrollingElement.scrollTop = 300");
+ checkLastEntry(entries, 0, [8, 108, vh + 108, vh + 208, 0, 0, 0, 0, 0, vw, 0, vh, false]);
+ }
+
+ function step1() {
+ document.scrollingElement.scrollTop = 0;
+ checkLastEntry(entries, 1, [8, 108, vh - 192, vh - 92, 8, 108, vh - 192, vh - 92, 0, vw, 0, vh, true]);
+ }
+</script>
+
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-origin-grand-child-iframe.sub.html (271233 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-origin-grand-child-iframe.sub.html 2021-01-07 10:11:26 UTC (rev 271233)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-origin-grand-child-iframe.sub.html 2021-01-07 10:38:53 UTC (rev 271234)
@@ -5,16 +5,25 @@
<script src=""
<script src=""
<script src=""
-<iframe id="iframe"></iframe>
+<iframe scrolling="no" frameborder="0" id="iframe"></iframe>
<script>
promise_test(async t => {
iframe.src =
""> get_host_info().HTTP_NOTSAMESITE_ORIGIN + "/intersection-observer/resources/cross-origin-child-iframe.sub.html";
- const rootBounds = await new Promise(resolve => {
+ const { rootBounds, intersectionRect } = await new Promise(resolve => {
window.addEventListener("message", event => resolve(event.data));
}, { once: true } );
+ // 300px = iframe viewport width
+ // 8px = default body margin
+ // (intersectionRect is in the coordinate space of the target iframe)
+ assert_equals(intersectionRect.top, 8);
+ assert_equals(intersectionRect.left, 200);
+ assert_equals(intersectionRect.right, 300 - 8);
+ assert_equals(intersectionRect.width, 100 - 8);
+ assert_equals(intersectionRect.height, 100);
+
assert_equals(rootBounds.left, 0);
assert_equals(rootBounds.top, 0);
assert_equals(rootBounds.right, document.documentElement.clientWidth);
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/target-in-different-window.html (271233 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/target-in-different-window.html 2021-01-07 10:11:26 UTC (rev 271233)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/target-in-different-window.html 2021-01-07 10:38:53 UTC (rev 271234)
@@ -1,5 +1,9 @@
<!DOCTYPE html>
<meta name="viewport" content="width=device-width,initial-scale=1">
+<!--
+ NOTE(emilio): This tests Chrome's behavior but it's not clear that's what the
+ spec asks for, see https://github.com/w3c/IntersectionObserver/issues/456
+-->
<script src=""
<script src=""
<script src=""
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/w3c-import.log (271233 => 271234)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/w3c-import.log 2021-01-07 10:11:26 UTC (rev 271233)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/w3c-import.log 2021-01-07 10:38:53 UTC (rev 271234)
@@ -18,6 +18,7 @@
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/bounding-box.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/client-rect.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/containing-block.html
+/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/cross-document-root.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/cross-origin-iframe.sub.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/disconnect.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/display-none.html
@@ -24,6 +25,7 @@
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/document-scrolling-element-root.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/edge-inclusive-intersection.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/empty-root-margin.html
+/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/explicit-root-different-document.tentative.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/idlharness.window.js
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/iframe-no-root-with-wrapping-scroller.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/iframe-no-root.html
@@ -36,6 +38,7 @@
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-thresholds.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/nested-cross-origin-iframe.sub.html
+/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/not-in-containing-block-chain.tentative.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-attributes.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-callback-arguments.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-exceptions.html
@@ -48,6 +51,7 @@
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/rtl-clipped-root.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-no-root.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-root.html
+/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-with-document-root.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-zero-size-target.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-origin-grand-child-iframe.sub.html
/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/shadow-content.html