diff options
Diffstat (limited to 'testing/web-platform/tests/css/css-scroll-anchoring/focused-element-nested-anchor.html')
-rw-r--r-- | testing/web-platform/tests/css/css-scroll-anchoring/focused-element-nested-anchor.html | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-scroll-anchoring/focused-element-nested-anchor.html b/testing/web-platform/tests/css/css-scroll-anchoring/focused-element-nested-anchor.html new file mode 100644 index 0000000000..727da4046e --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-anchoring/focused-element-nested-anchor.html @@ -0,0 +1,69 @@ +<!DOCTYPE html> +<link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring/"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> + +body { height: 4000px; } +div { height: 100px; } + +.scroller { + overflow: scroll; + position: fixed; + width: 300px; + height: 300px; + background-color: green; +} + +#posSticky { + top: 300px; + position: relative; + height: 50px; + width: 50px; + background-color: blue; +} + +#content { + background-color: #D3D3D3; + height: 50px; + width: 50px; + position: relative; + top: 500px; +} + +#anchor { + background-color: brown; + height: 50px; + width: 50px; + position: relative; + top: 200px; +} + +</style> +<div id="scroller" class="scroller"> + <div id="content" tabindex="-1"></div> + <div id="anchor" tabindex="-1"></div> +</div> + +<script> + +// Tests that a focused element doesn't become the +// priority candidate of the main frame if it is +// the anchor element of a subscroller + +promise_test(async function() { + var scroller = document.querySelector("#scroller"); + var focusElement = document.querySelector("#anchor"); + focusElement.focus(); + scroller.scrollBy(0,150); + document.scrollingElement.scrollBy(0,100); + + scroller.scrollBy(0, 50); + await new Promise(resolve => { + scroller.addEventListener("scroll", () => step_timeout(resolve, 0)); + }); + + assert_equals(document.scrollingElement.scrollTop, 100); +}, "Ensure there is no scroll anchoring adjustment in the main frame."); + +</script>
\ No newline at end of file |