Bug 1862306 - Add a test that checks that dragging from a starting position that's not on the thumb. r=botond

Differential Revision: https://phabricator.services.mozilla.com/D192409
This commit is contained in:
Razvan Cojocaru 2023-11-08 20:14:54 +00:00
parent 52c87462c7
commit 37dfc39ae2
2 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1,71 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>Dragging the mouse on the viewport's scrollbar beginning with mouse cursor not over the thumb</title>
<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>
.content {
width: 1000px;
height: 5000px;
}
</style>
<script type="text/javascript">
async function test() {
// Scroll to the bottom, so the thumb is not at the top of scrollbar track
// where we start the drag.
window.scrollTo(0, window.scrollMaxY);
await promiseApzFlushedRepaints();
let scrollPromise = new Promise(resolve => {
window.addEventListener("scroll", resolve, {once: true});
});
// Do the scroll in one increment so that when the scroll event fires
// we're done all the scrolling we're going to do.
var dragFinisher = await promiseVerticalScrollbarDrag(window, 20, 20);
if (!dragFinisher) {
ok(true, "No scrollbar, can't do this test");
return;
}
// the events above might be stuck in APZ input queue for a bit until the
// layer is activated, so we wait here until the scroll event listener is
// triggered.
await scrollPromise;
await dragFinisher();
// Flush everything just to be safe
await promiseOnlyApzControllerFlushed();
// After dragging the scrollbar 20px on a 1000px-high viewport, we should
// have scrolled approx 2% of the 5000px high content. There might have been
// scroll arrows and such so let's just have a minimum bound of 50px to be safe.
ok(window.scrollY > 50, "Scrollbar drag resulted in a vertical scroll position of " + window.scrollY);
// Check that the scroll thumb did no remain at the bottom of the page after the
// initial scroll.
ok(window.scrollY < (window.scrollMaxY / 2), "The thumb did not remain at the bottom of the page");
// Check that we did not get spurious horizontal scrolling, as we might if the
// drag gesture is mishandled by content as a select-drag rather than a scrollbar
// drag.
is(window.scrollX, 0, "Scrollbar drag resulted in a horizontal scroll position of " + window.scrollX);
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
</head>
<body>
<div class="content">Some content to ensure the root scrollframe is scrollable</div>
</body>
</html>

View file

@ -28,6 +28,7 @@ var subtests = [
// disabled, and so needs to be tested separately for both.
{"file": "helper_drag_root_scrollbar.html", "prefs": [["apz.allow_zooming", false]]},
{"file": "helper_drag_root_scrollbar.html", "prefs": [["apz.allow_zooming", true]]},
{"file": "helper_drag_root_scrollbar_mouse_not_over_thumb.html", "prefs": [["ui.scrollToClick", 1]]},
{"file": "helper_drag_scrollbar_hittest.html", "prefs": [
// The test applies a scaling zoom to the page.
["apz.allow_zooming", true],