Automatic update from web-platform-tests [IntersectionObserver] Allow Document argument to constructor This implements a behavioral change as described in: https://github.com/w3c/IntersectionObserver/issues/372 If the 'root' argument to the IntersectionObserver constructor is a Document, then the observer will clip to the Document's root scroller. For the top Document, this is the same behavior as the implicit root. For an iframe Document, this is new behavior which is unobtainable by other means. BUG=1015183 Change-Id: I234bfce28ab954bb15b8d157bc22ee2d2469d5e4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003750 Reviewed-by: Chris Harrelson <chrishtr@chromium.org> Reviewed-by: vmpstr <vmpstr@chromium.org> Commit-Queue: Stefan Zager <szager@chromium.org> Cr-Commit-Position: refs/heads/master@{#734268} -- wpt-commits: aebf5e72a429c448637c388512bcadd4d4e3fa65 wpt-pr: 21222
51 lines
1.5 KiB
HTML
51 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<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;
|
|
}
|
|
iframe {
|
|
height: 250px;
|
|
width: 150px;
|
|
border: 0;
|
|
}
|
|
</style>
|
|
<iframe id="target-iframe" src="resources/iframe-no-root-subframe.html"></iframe>
|
|
|
|
<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: iframe.contentDocument });
|
|
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.");
|
|
};
|
|
|
|
function step0() {
|
|
let vw = iframe.contentDocument.documentElement.clientWidth;
|
|
let vh = iframe.contentDocument.documentElement.clientHeight;
|
|
// The target element is partially clipped by the iframe's root scroller, so
|
|
// height of the intersection rect is (250 - 208) == 42.
|
|
checkLastEntry(entries, 0, [8, 108, 208, 308, 8, 108, 208, 250, 0, vw, 0, vh, true]);
|
|
}
|
|
</script>
|