diff options
Diffstat (limited to 'testing/web-platform/tests/layout-instability/shift-scroll-anchoring-natural-scroll.html')
-rw-r--r-- | testing/web-platform/tests/layout-instability/shift-scroll-anchoring-natural-scroll.html | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/testing/web-platform/tests/layout-instability/shift-scroll-anchoring-natural-scroll.html b/testing/web-platform/tests/layout-instability/shift-scroll-anchoring-natural-scroll.html new file mode 100644 index 0000000000..1b146b05d7 --- /dev/null +++ b/testing/web-platform/tests/layout-instability/shift-scroll-anchoring-natural-scroll.html @@ -0,0 +1,65 @@ +<!DOCTYPE html> +<title>Layout Instability: shift offscreen with scroll anchoring and natural scroll</title> +<link rel="help" href="https://wicg.github.io/layout-instability/" /> +<style> +#scroller { + overflow: scroll; + left: 20px; + top: 20px; + width: 200px; + height: 200px; +} +#spacer { + height: 3000px; +} +#ch { + position: relative; + background: yellow; + left: 10px; + top: 100px; + width: 150px; + height: 150px; +} +#offscreenElement { + width: 300px; + height: 300px; + background: lightblue; +} +#onscreenElement { + width: 300px; + height: 300px; + background: lightgreen; +} +</style> +<div id="scroller"> + <div id="offscreenElement"></div> + <div id="spacer"></div> + <div id="onscreenElement"></div> +</div> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/util.js"></script> +<script> + +promise_test(async () => { + const watcher = new ScoreWatcher; + + // Wait for the initial render to complete. + await waitForAnimationFrames(2); + + // Scroll to show #onscreenElement. + scroller.scrollTop = 3250; + await waitForAnimationFrames(1); + + // Resize #offscreernElement and scroll a bit. + // Visually, #onscreenElement will move by 20px. + offscreenElement.style.height = '250px'; + scroller.scrollBy(0, 20); + + await waitForAnimationFrames(3); + // There should be no reported layout shift, because to the user it looks + // like a natural scroll by 20px. + assert_equals(watcher.score, 0); +}, "Offscreen shift with scroll annchoring and natural scroll not counted."); + +</script> |