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_into_view_bug1516056.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_into_view_bug1516056.html')
-rw-r--r-- | gfx/layers/apz/test/mochitest/helper_scroll_into_view_bug1516056.html | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/mochitest/helper_scroll_into_view_bug1516056.html b/gfx/layers/apz/test/mochitest/helper_scroll_into_view_bug1516056.html new file mode 100644 index 0000000000..99952dddd4 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_scroll_into_view_bug1516056.html @@ -0,0 +1,62 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width"> + <title>Test for bug 1516056: "scroll into view" respects bounds on layout scroll position</title> + <script type="application/javascript" src="apz_test_utils.js"></script> + <script src="/tests/SimpleTest/paint_listener.js"></script> + <style> + #target { + width: 100px; + height: 100px; + margin-left: 50%; + margin-right: 50%; + background: cyan; + } + </style> +</head> +<body> + <div id="target"></div> + <script> + let vv = window.visualViewport; + function getVisualScrollRange() { + let rootScroller = document.scrollingElement; + return { + width: rootScroller.scrollWidth - vv.width, + height: rootScroller.scrollHeight - vv.height, + }; + } + async function test() { + is(window.scrollMaxX, 0, "page should have a zero horizontal layout scroll range"); + is(window.scrollMaxY, 0, "page should have a zero vertical layout scroll range"); + let visualScrollRange = getVisualScrollRange(); + ok(visualScrollRange.width > 0, "page should have a nonzero horizontal visual scroll range"); + ok(visualScrollRange.height > 0, "page should have a nonzero vertical visual scroll range"); + let target = document.getElementById("target"); + + // Scroll target element into view. Wait until any visual scrolling is done before doing checks. + let scrollPromise = new Promise(resolve => { + vv.addEventListener("scroll", resolve, { once: true }); + }); + target.scrollIntoView(); + await scrollPromise; // wait for visual viewport "scroll" event + await promiseApzFlushedRepaints(); + + // Test that scrollIntoView() respected the layout scroll range. + is(window.scrollX, 0, "page should not layout-scroll with a zero layout scroll range"); + is(window.scrollY, 0, "page should not layout-scroll with a zero layout scroll range"); + + // Test that scrollIntoView() did perform visual scrolling. + let vvRect = getVisualViewportRect(vv); + let targetBounds = target.getBoundingClientRect(); + assertRectContainment(vvRect, "visual viewport", targetBounds, "target element bounding rect"); + } + SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(2.0); + + waitUntilApzStable() + .then(test) + .then(subtestDone, subtestFailed); + </script> +</body> +</html> |