diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /gfx/layers/apz/test/mochitest/helper_scroll_snap_resnap_after_async_scroll.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/layers/apz/test/mochitest/helper_scroll_snap_resnap_after_async_scroll.html')
-rw-r--r-- | gfx/layers/apz/test/mochitest/helper_scroll_snap_resnap_after_async_scroll.html | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/mochitest/helper_scroll_snap_resnap_after_async_scroll.html b/gfx/layers/apz/test/mochitest/helper_scroll_snap_resnap_after_async_scroll.html new file mode 100644 index 0000000000..ff1c78bef5 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_scroll_snap_resnap_after_async_scroll.html @@ -0,0 +1,81 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Re-snapping to the last snapped element on APZ</title> + <script src="apz_test_utils.js"></script> + <script src="apz_test_native_event_utils.js"></script> + <script src="/tests/SimpleTest/paint_listener.js"></script> + <style> + body { + margin: 0; + } + div { + position: absolute; + } + #scroller { + width: 100%; + height: 500px; + overflow-y: scroll; + scroll-snap-type: y proximity; /* to escape from the last snap point */ + } + .child { + width: 100%; + height: 100px; + background-color: blue; + scroll-snap-align: start; + } + </style> +</head> +<body> + <div id="scroller"> + <div class="child" style="top: 0px;"></div> + <div class="child" style="top: 200px;"></div> + <div id="spacer" style="width: 100%; height: 2000px;"></div> + </div> + <script type="application/javascript"> + async function test() { + const proximityThreshold = + SpecialPowers.getIntPref("layout.css.scroll-snap.proximity-threshold"); + + let transformEndPromise = promiseTransformEnd(); + await promiseMoveMouseAndScrollWheelOver(scroller, 100, 100); + + await transformEndPromise; + await promiseApzFlushedRepaints(); + + is(scroller.scrollTop, 200, "snap to 200px"); + + document.querySelectorAll(".child")[1].style.top = "400px"; + is(scroller.scrollTop, 400, "re-snap to 400px"); + + // Make sure the new snap position has been reflected in APZ side. + await promiseApzFlushedRepaints(); + + // Now trigger another wheel scroll to escape from the last snap point. + transformEndPromise = promiseTransformEnd(); + // With a small `layout.css.scroll-behavior.spring-constant` preference + // value (it's set in test_group_scroll_snap.html), an async scroll + // operation, e.g. a wheel scroll operation, fires multiple scroll events + // so that here we wait the first scroll event here by specifying + // `waitForScroll=true`, there should be other scroll events after the + // first one. + await promiseMoveMouseAndScrollWheelOver(scroller, 100, 100, + true /* waitForScroll */, proximityThreshold + 1000); + + // Expand the scrollable region during the wheel scroll. + spacer.style.height = "2200px"; + + await transformEndPromise; + await promiseApzFlushedRepaints(); + + isnot(scroller.scrollTop, 400, "Do not re-snap to the original 400px point"); + } + + waitUntilApzStable() + .then(test) + .then(subtestDone, subtestFailed); + </script> +</body> +</html> |