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 /layout/base/tests/test_scroll_space_no_range_overflow_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 'layout/base/tests/test_scroll_space_no_range_overflow_scroll.html')
-rw-r--r-- | layout/base/tests/test_scroll_space_no_range_overflow_scroll.html | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/layout/base/tests/test_scroll_space_no_range_overflow_scroll.html b/layout/base/tests/test_scroll_space_no_range_overflow_scroll.html new file mode 100644 index 0000000000..deed8f4ced --- /dev/null +++ b/layout/base/tests/test_scroll_space_no_range_overflow_scroll.html @@ -0,0 +1,67 @@ +<!doctype html> +<title>Test for bug 1567237</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/tests/SimpleTest/EventUtils.js"></script> +<script type="text/javascript" src="/tests/gfx/layers/apz/test/mochitest/apz_test_utils.js"></script> +<style> + .spacer { height: 200vh; } + .scroller { height: 300px; overflow: scroll; } +</style> +<div id="unscrollable" class="scroller" tabindex=0></div> +<div id="scrollable" class="scroller" tabindex=0> + <div class="spacer"></div> +</div> +<div class="spacer"></div> +<script> +function waitForScrollEvent(target) { + return new Promise(resolve => { + target.addEventListener("scroll", resolve, { once: true }); + }); +} + +let selectionController = + SpecialPowers.wrap(window) + .docShell + .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) + .getInterface(SpecialPowers.Ci.nsISelectionDisplay) + .QueryInterface(SpecialPowers.Ci.nsISelectionController); + +function doPageDown(targetExpectedToScroll) { + let promise = waitForScrollEvent(targetExpectedToScroll); + selectionController.pageMove(true, false); + return promise; +} + +promise_test(async function() { + await SpecialPowers.pushPrefEnv({"set": [["general.smoothScroll", false]]}); + + const rootScroller = document.documentElement; + const scrollable = document.querySelector("#scrollable"); + const unscrollable = document.querySelector("#unscrollable"); + + assert_equals(rootScroller.scrollTop, 0, "Root should start unscrolled"); + assert_equals(scrollable.scrollTop, 0, "#scrollable should start unscrolled"); + assert_equals(unscrollable.scrollTop, 0, "#unscrollable should not be able to scroll at all"); + + assert_true(rootScroller.scrollTopMax > 0, "Should be able to scroll the document element"); + assert_true(scrollable.scrollTopMax > 0, "Should be able to scroll #scrollable"); + assert_equals(unscrollable.scrollTopMax, 0, "#unscrollable should not be able to scroll at all (checking scrollTopMax)"); + + scrollable.focus(); + await waitToClearOutAnyPotentialScrolls(window); + await doPageDown(scrollable); + assert_not_equals(scrollable.scrollTop, 0, "Should have scrolled when pressing space"); + + unscrollable.focus(); + await waitToClearOutAnyPotentialScrolls(window); + let rootScrollTop = rootScroller.scrollTop; // Could've scrolled to scroll `scrollable` into view before. + await doPageDown(window); + assert_equals(unscrollable.scrollTop, 0, "Should not be able to scroll the unscrollable div"); + assert_not_equals(rootScroller.scrollTop, rootScrollTop, "Root should be able to scroll"); + + // Null out the controller. Otherwise we leak the whole window because + // PresShell is not cycle-collectable. See bug 1567237. + selectionController = null; +}, "Overflow scroll without range doesn't block scrolling of the main document"); +</script> |