diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /gfx/layers/apz/test/mochitest/helper_scroll_snap_on_page_down_scroll.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/layers/apz/test/mochitest/helper_scroll_snap_on_page_down_scroll.html')
-rw-r--r-- | gfx/layers/apz/test/mochitest/helper_scroll_snap_on_page_down_scroll.html | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/mochitest/helper_scroll_snap_on_page_down_scroll.html b/gfx/layers/apz/test/mochitest/helper_scroll_snap_on_page_down_scroll.html new file mode 100644 index 0000000000..bca89aac42 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_scroll_snap_on_page_down_scroll.html @@ -0,0 +1,90 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Page scroll snaps a snap point in the same page rather than the one in the next page</title> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <script type="application/javascript" src="apz_test_native_event_utils.js"></script> + <script type="application/javascript" src="apz_test_utils.js"></script> + <script src="/tests/SimpleTest/paint_listener.js"></script> + <style> + div { + position: absolute; + margin: 0px; + } + body { + margin: 0px; + } + html { + overflow-y: scroll; + scroll-snap-type: y mandatory; + } + .snap { + scroll-snap-align: start; + background: green; + } + </style> +</head> +<body> + <div class="snap" style="top: 0vh; width: 100%; height: 20px;">1</div> + <div class="snap" style="top: 50vh; width: 100%; height: 20px;">2</div> + <div class="snap" style="top: 102vh; width: 100%; height: 20px;">3</div> + <div class="snap" style="top: 300vh; width: 100%; height: 20px;">4</div> + <div class="snap" style="top: 400vh; width: 100%; height: 20px;">5</div> + + <script type="application/javascript"> + async function test() { + const expectedPosition = + document.querySelectorAll(".snap")[1].getBoundingClientRect().top; + + const keyPromise = promiseOneEvent(window, "keydown", null); + window.synthesizeKey("KEY_PageDown"); + await keyPromise; + + let startedScroll = false; + let sameScrollPosition = false; + let prevScrollPos = window.scrollY; + while (true) { + // Flush APZ repaints to ensure that scroll offset changes from + // a compositor sample reach the content process. + await promiseApzFlushedRepaints(); + + let scrollPos = window.scrollY; + if (scrollPos == prevScrollPos) { + if (startedScroll) { + // If we had the same scroll position in two frames consecutively, + // we consider scroll has finished. + if (sameScrollPosition) { + break; + } + sameScrollPosition = true; + } + } else { + sameScrollPosition = false; + } + + if (!startedScroll && scrollPos > 0) { + startedScroll = true; + } + prevScrollPos = scrollPos; + } + + // Use a fuzzy comparison with epsilon=1, because expectedPosition + // can be fractional (e.g. if viewport height is an odd number of pixels, + // then 50vh will be fractional), and ClampAndAlignWithPixels can round + // the final scroll offset requested by APZ at the end of an animation, + // to an integer value. We plan to remove ClampAndAlignWithPixels in + // bug 1774315. + isfuzzy(window.scrollY, expectedPosition, 1, + "Snaps to the second snap point rather than the third snap point " + + "which was initially out of the scrollport even if it's closer to " + + "the top of the next page than the second snap point"); + } + + waitUntilApzStable() + .then(test) + .then(subtestDone, subtestFailed); + </script> +</body> +</html> |