Files
sousa-gecko/testing/web-platform/tests/intersection-observer/target-in-detached-document.html
T
Stefan Zager 2e6efd4b85 Bug 1994506 [wpt PR 55459] - Do not synchronously generate IntersectionObserver notifications, a=testonly
Automatic update from web-platform-tests
Do not synchronously generate IntersectionObserver notifications

Prior to this CL, we would synchronously generate a not-intersecting
notification when a target element was removed from the DOM. That
doesn't match the spec -- there is no affordance for generating
notifications outside of the "update the rendering" steps.

This CL removes all the synchronous forced computation of intersections.
It makes IntersectionObserverController continue tracking disconnected
targets until they have a chance to issue a "not-intersecting"
notification during a rendering update.

Bug: chromium:40914013
Change-Id: I332dc4e95dc9cffbe7d05ec63eb3cd6122c431a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7038511
Reviewed-by: Philip Rogers <pdr@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1531750}

--

wpt-commits: ca587879e05348d19e15627d9d5b6a2be0b5caf2
wpt-pr: 55459
2025-10-24 08:58:46 +00:00

49 lines
1.3 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;
}
#target {
width: 100px;
height: 100px;
background-color: green;
}
</style>
<script>
var vw = document.documentElement.clientWidth;
var vh = document.documentElement.clientHeight;
var entries = [];
var target;
runTestCycle(function() {
var detached_document = document.implementation.createHTMLDocument("test");
target = detached_document.createElement("div");
target.id = "target";
var observer = new IntersectionObserver(function(changes) {
entries = entries.concat(changes)
});
observer.observe(target);
runTestCycle(step0, "First rAF.");
}, "IntersectionObserver in a single document using the implicit root.");
function step0() {
document.adoptNode(target);
document.body.appendChild(target);
assert_equals(entries.length, 0, "No initial notification while in detached document.");
runTestCycle(step1, "Adopt target.");
}
function step1() {
checkLastEntry(entries, 0, [8, 108, 8, 108, 8, 108, 8, 108, 0, vw, 0, vh, true]);
}
</script>