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_zoomToFocusedInput_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.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/layers/apz/test/mochitest/helper_zoomToFocusedInput_scroll.html')
-rw-r--r-- | gfx/layers/apz/test/mochitest/helper_zoomToFocusedInput_scroll.html | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/mochitest/helper_zoomToFocusedInput_scroll.html b/gfx/layers/apz/test/mochitest/helper_zoomToFocusedInput_scroll.html new file mode 100644 index 0000000000..4054b51657 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_zoomToFocusedInput_scroll.html @@ -0,0 +1,51 @@ +<!DOCTYPE> +<html> + <head> + <title>Checking zoomToFocusedInput scrolls that focused input element is visible position</title> + <script type="application/javascript" src="apz_test_utils.js"></script> + <script type="application/javascript" src="apz_test_native_event_utils.js"></script> + <script src="/tests/SimpleTest/paint_listener.js"></script> + </head> +<body> +<div style="height: 8000px;">ABC</div> +<input id="input1"> +<!-- Leave additional room below the element so it can be scrolled to the center --> +<div style="height: 1000px;">ABC</div> +<script type="application/javascript"> +async function test() { + is(0, window.scrollY, "scroll position starts at zero"); + input1.focus(); + await waitToClearOutAnyPotentialScrolls(window); + isnot(0, window.scrollY, "scroll position isn't top"); + window.scrollTo(0, 0); + await waitToClearOutAnyPotentialScrolls(window); + is(0, window.scrollY, "scroll position is top"); + + let utils = SpecialPowers.getDOMWindowUtils(window); + let transformEndPromise = promiseTransformEnd(); + utils.zoomToFocusedInput(); + isnot(0, window.scrollY, "scroll position isn't top"); + + // Test for bug 1669588: check that the zoom animation did not get + // cancelled by a main thread scroll position update triggered by + // the ScrollContentIntoView() operation performed by zoomToFocusedInput(). + + await transformEndPromise; + await promiseApzFlushedRepaints(); + + // Check that the zoom animation performed additional scrolling + // beyond the ScrollContentIntoView(). The ScrollContentIntoView() + // just scrolls enough to bring `input1` into the viewport, while + // the zoom animation will scroll further to center it. To + // distinguish the two cases, check that we scrolled enough that + // the element's top is above the middle of the visual viewport. + let inputTop = input1.getBoundingClientRect().top; + inputTop -= window.visualViewport.offsetTop; + ok(inputTop < (window.visualViewport.height / 2), + "input was scrolled at least as far as the middle of the viewport"); +} + +waitUntilApzStable().then(test).then(subtestDone, subtestFailed); +</script> +</body> +</html> |