Bug 1561726 - Add a test to exercise dragging the viewport scrollbar. r=kats

Differential Revision: https://phabricator.services.mozilla.com/D34259

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2019-06-28 20:23:36 +00:00
parent 5a017eafd4
commit 969a60d6a2
2 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,57 @@
<!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</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">
function* test(testDriver) {
window.addEventListener("scroll", () => setTimeout(testDriver, 0), {once: true});
var dragFinisher = yield* dragVerticalScrollbar(window, testDriver);
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.
yield;
yield* dragFinisher();
// Flush everything just to be safe
yield flushApzRepaints(testDriver);
// 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 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(runContinuation(test))
.then(subtestDone);
</script>
</head>
<body>
<div class="content">Some content to ensure the root scrollframe is scrollable</div>
</body>
</html>

View File

@ -16,6 +16,12 @@ var subtests = [
{"file": "helper_click.html?dtc=true"},
// Sanity test for click but with some mouse movement between the down and up
{"file": "helper_drag_click.html"},
// Test for dragging on the scrollbar of the root scrollable element works.
// This takes different codepaths with async zooming support enabled and
// disabled, and so needs to be tested separately for both.
// TODO(bug 1556556): Once we get this working with zooming enabled,
// add an entry to run this with apz.allow_zooming=true as well.
{"file": "helper_drag_root_scrollbar.html", "prefs": [["apz.allow_zooming", false]]},
// Test for dragging on a fake-scrollbar element that scrolls the page
{"file": "helper_drag_scroll.html"},
// Test for dragging the scrollbar with a fixed-pos element overlaying it