Bug 1561726 - Add a test to exercise dragging the viewport scrollbar. r=kats
authorBotond Ballo <botond@mozilla.com>
Fri, 28 Jun 2019 20:23:36 +0000
changeset 543438 76c526cf901b20b7383524e0c3d0bfa82855cd20
parent 543437 fdaf7d75ccc9f79ecf13af083a5764f57cdb6190
child 543439 9f687685a13cb1b0015cfb2f98821e624b42754a
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1561726
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1561726 - Add a test to exercise dragging the viewport scrollbar. r=kats Differential Revision: https://phabricator.services.mozilla.com/D34259
gfx/layers/apz/test/mochitest/helper_drag_root_scrollbar.html
gfx/layers/apz/test/mochitest/test_group_mouseevents.html
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_drag_root_scrollbar.html
@@ -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>
--- a/gfx/layers/apz/test/mochitest/test_group_mouseevents.html
+++ b/gfx/layers/apz/test/mochitest/test_group_mouseevents.html
@@ -11,16 +11,22 @@
 var subtests = [
   // Sanity test to synthesize a mouse click
   {"file": "helper_click.html?dtc=false"},
   // Same as above, but with a dispatch-to-content region that exercises the
   // main-thread notification codepaths for mouse events
   {"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
   {"file": "helper_bug1346632.html"},
   // Test for scrollbar-dragging on a scrollframe that's inactive
   {"file": "helper_bug1326290.html"},
   // Test for scrollbar-dragging on a scrollframe inside an SVGEffects
   {"file": "helper_bug1331693.html"},