forked from mirrors/gecko-dev
Automatic update from web-platform-tests [IntersectionOptimization] Fix crash with fixed-position when viewport is scrolled A fixed-position element that is fixed to the viewport doesn't scroll with the viewport, so if the root is the containing LayoutView, we don't need to update intersection on viewport scroll. However, previously CachedRects::unscrolled_unclipped_intersection_rect was always in the scrolling contents coordinates making it depend on viewport scroll position, and caused crashes when IntersectionOptimization skipped intersection update on viewport scroll. Now let CachedRects::unscrolled_unclipped_intersection_rect be in the root's border box space (i.e. viewport coordinates if the root is the viewport) if the root doesn't scroll the target. Bug: 1508301 Change-Id: I94fa8e60610ceae2826cc560aa99f568d67be583 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5106931 Reviewed-by: Stefan Zager <szager@chromium.org> Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> Cr-Commit-Position: refs/heads/main@{#1237621} -- wpt-commits: 21ed5859fc60bc3ff0a8fa6eac5314c54af8bcd0 wpt-pr: 43617
37 lines
1.3 KiB
HTML
37 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>
|
|
<div id="target" style="width: 100px; height: 100px; position: fixed; top: 0; left: 0"></div>
|
|
<div id="log" style="height: 2000px"></div>
|
|
<script>
|
|
var entries = [];
|
|
|
|
runTestCycle(function() {
|
|
var observer = new IntersectionObserver(function(changes) {
|
|
entries = entries.concat(changes)
|
|
});
|
|
observer.observe(target);
|
|
entries = entries.concat(observer.takeRecords());
|
|
assert_equals(entries.length, 0, 'No initial notifications.');
|
|
runTestCycle(step0, 'First rAF.');
|
|
}, 'Fixed-position intersection observer on scroll');
|
|
|
|
function step0() {
|
|
window.scrollTo(0, 1000);
|
|
runTestCycle(step1, 'scrollTo(0, 1000)');
|
|
checkLastEntry(entries, 0,
|
|
[0, 100, 0, 100, 0, 100, 0, 100, 0,
|
|
document.documentElement.clientWidth, 0, document.documentElement.clientHeight,
|
|
true]);
|
|
}
|
|
|
|
function step1() {
|
|
window.scrollTo(0, 0);
|
|
checkLastEntry(entries, 0,
|
|
[0, 100, 0, 100, 0, 100, 0, 100, 0,
|
|
document.documentElement.clientWidth, 0, document.documentElement.clientHeight,
|
|
true]);
|
|
}
|
|
</script>
|