Bug 1468545 - Add a test for dragging the scrollbar on an inactive scrollframe. r?botond draft
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 15 Jun 2018 18:13:48 -0400
changeset 807871 ec9cdb186b2731107e3a806b56089ac8efc3d679
parent 807870 b6fab497f7ec3a61ff84188a68ddd247a9926bc3
child 807872 3d0532f6d70d3318e7a85a28a1eb21742618c72c
push id113233
push userkgupta@mozilla.com
push dateFri, 15 Jun 2018 22:25:59 +0000
reviewersbotond
bugs1468545, 1348321, 1326290
milestone62.0a1
Bug 1468545 - Add a test for dragging the scrollbar on an inactive scrollframe. r?botond I had originally planned to land this as part of bug 1348321, with it exercising the case from bug 1326290. However it exposed the issue that I fixed in this bug, so it seems reasonable to land this test as part of this bug. MozReview-Commit-ID: EL1N9EmMXaC
gfx/layers/apz/test/mochitest/helper_bug1326290.html
gfx/layers/apz/test/mochitest/test_group_mouseevents.html
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_bug1326290.html
@@ -0,0 +1,76 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width; initial-scale=1.0">
+  <title>Dragging the mouse on a inactive scrollframe'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 type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
+  <style>
+    #scrollable {
+      overflow: scroll;
+      height: 200px;
+      width: 200px;
+    }
+    .content {
+      width: 1000px;
+      height: 2000px;
+    }
+  </style>
+  <script type="text/javascript">
+
+function* test(testDriver) {
+  var scrollableDiv = document.getElementById('scrollable');
+  var boundingClientRect = scrollableDiv.getBoundingClientRect();
+  var verticalScrollbarWidth = boundingClientRect.width - scrollableDiv.clientWidth;
+  if (verticalScrollbarWidth == 0) {
+    ok(true, "No scrollbar, can't do this test");
+    return;
+  }
+  var upArrowHeight = verticalScrollbarWidth; // assume square scrollbar buttons
+  var mouseX = scrollableDiv.clientWidth + (verticalScrollbarWidth / 2);
+  var mouseY = upArrowHeight + 5; // start dragging somewhere in the thumb
+
+  scrollableDiv.addEventListener('scroll', () => setTimeout(testDriver, 0), {once: true});
+
+  dump("Starting drag at " + mouseX + ", " + mouseY + " from top-left of scrollableDiv\n");
+
+  // Move the mouse to the scrollbar thumb and drag it down
+  yield synthesizeNativeMouseEvent(scrollableDiv, mouseX, mouseY, nativeMouseMoveEventMsg(), testDriver);
+  // mouse down
+  yield synthesizeNativeMouseEvent(scrollableDiv, mouseX, mouseY, nativeMouseDownEventMsg(), testDriver);
+  // drag vertically by 20px, in 5px increments
+  yield synthesizeNativeMouseEvent(scrollableDiv, mouseX, mouseY + 5, nativeMouseMoveEventMsg(), testDriver);
+  yield synthesizeNativeMouseEvent(scrollableDiv, mouseX, mouseY + 10, nativeMouseMoveEventMsg(), testDriver);
+  yield synthesizeNativeMouseEvent(scrollableDiv, mouseX, mouseY + 15, nativeMouseMoveEventMsg(), testDriver);
+  yield synthesizeNativeMouseEvent(scrollableDiv, mouseX, mouseY + 20, nativeMouseMoveEventMsg(), testDriver);
+  // and release
+  yield synthesizeNativeMouseEvent(scrollableDiv, mouseX, mouseY + 20, nativeMouseUpEventMsg());
+
+  // 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. We do this by not passing testDriver to the mouse-up synth
+  // function above.
+
+  yield flushApzRepaints(testDriver);
+
+  // After dragging the scrollbar 20px on a 200px-high scrollable div, we should
+  // have scrolled approx 10% of the 2000px high content. There might have been
+  // scroll arrows and such so let's just have a minimum bound of 50px to be safe.
+  ok(scrollableDiv.scrollTop > 50, "Scrollbar drag resulted in a scroll position of " + scrollableDiv.scrollTop);
+}
+
+waitUntilApzStable()
+.then(runContinuation(test))
+.then(subtestDone);
+
+  </script>
+</head>
+<body>
+  <div id="scrollable">
+    <div class="content">Some content inside the inactive scrollframe</div>
+  </div>
+  <div class="content">Some content to ensure the root scrollframe is scrollable and the overflow:scroll div remains inactive</div>
+</body>
+</html>
--- a/gfx/layers/apz/test/mochitest/test_group_mouseevents.html
+++ b/gfx/layers/apz/test/mochitest/test_group_mouseevents.html
@@ -14,17 +14,19 @@ var subtests = [
   // 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 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'}
+  {'file': 'helper_bug1346632.html'},
+  // Test for scrollbar-dragging on a scrollframe that's inactive
+  {'file': 'helper_bug1326290.html'}
 ];
 
 if (isApzEnabled()) {
   SimpleTest.waitForExplicitFinish();
   window.onload = function() {
     runSubtestsSeriallyInFreshWindows(subtests)
     .then(SimpleTest.finish, SimpleTest.finish);
   };