Bug 1328065 - Add a mochitest for scrolling over the scrollbar of a subframe. r=kats
authorBotond Ballo <botond@mozilla.com>
Fri, 17 Feb 2017 16:40:08 -0500
changeset 373359 70da9e298571e401a5eca7fe01b1c686a876fbe0
parent 373358 2d924269745a8e81a0e0788fa0dce1f22fe7d385
child 373360 70fb9299aee568b0d41e75a772a281922a969b07
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1328065
milestone54.0a1
Bug 1328065 - Add a mochitest for scrolling over the scrollbar of a subframe. r=kats MozReview-Commit-ID: 6Cna9amPCno
gfx/layers/apz/test/mochitest/helper_scroll_over_scrollbar.html
gfx/layers/apz/test/mochitest/mochitest.ini
gfx/layers/apz/test/mochitest/test_group_wheelevents.html
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_scroll_over_scrollbar.html
@@ -0,0 +1,42 @@
+<head>
+  <meta name="viewport" content="width=device-width; initial-scale=1.0">
+  <title>Wheel-scrolling over 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>
+  <script type="application/javascript">
+
+function* test(testDriver) {
+  var subframe = document.getElementById('scroll');
+
+  // scroll over the scrollbar, and make sure the subframe scrolls
+  var scrollPos = subframe.scrollTop;
+  var scrollbarX = (200 + subframe.clientWidth) / 2;
+  yield moveMouseAndScrollWheelOver(subframe, scrollbarX, 100, testDriver);
+  ok(subframe.scrollTop > scrollPos, "subframe scrolled after wheeling over scrollbar");
+}
+
+waitUntilApzStable()
+.then(runContinuation(test))
+.then(subtestDone);
+
+  </script>
+  <style>
+    #scroll {
+      width: 200px;
+      height: 200px;
+      overflow: scroll;
+    }
+    #scrolled {
+      width: 200px;
+      height: 1000px; /* so the subframe has room to scroll */
+      will-change: transform; /* to force active layers */
+    }
+  </style>
+</head>
+<body>
+  <div id="scroll">
+    <div id="scrolled"></div>
+  </div>
+</body>
+</head>
--- a/gfx/layers/apz/test/mochitest/mochitest.ini
+++ b/gfx/layers/apz/test/mochitest/mochitest.ini
@@ -16,16 +16,17 @@
     helper_drag_scroll.html
     helper_iframe_pan.html
     helper_iframe1.html
     helper_iframe2.html
     helper_long_tap.html
     helper_scroll_inactive_perspective.html
     helper_scroll_inactive_zindex.html
     helper_scroll_on_position_fixed.html
+    helper_scroll_over_scrollbar.html
     helper_scrollto_tap.html
     helper_subframe_style.css
     helper_tall.html
     helper_tap.html
     helper_tap_fullzoom.html
     helper_tap_passive.html
     helper_touch_action.html
     helper_touch_action_regions.html
--- a/gfx/layers/apz/test/mochitest/test_group_wheelevents.html
+++ b/gfx/layers/apz/test/mochitest/test_group_wheelevents.html
@@ -14,21 +14,29 @@ var prefs = [
   ['general.smoothScroll', false],
   // ensure that any mouse movement will trigger a new wheel transaction,
   // because in this test we move the mouse a bunch and want to recalculate
   // the target APZC after each such movement.
   ['mousewheel.transaction.ignoremovedelay', 0],
   ['mousewheel.transaction.timeout', 0]
 ]
 
+// For helper_scroll_over_scrollbar, we need to set a pref to force
+// layerization of the scrollbar track to reproduce the bug being fixed.
+// Otherwise, the bug only manifests with overlay scrollbars on macOS,
+// or in a XUL RCD, both of which are hard to materialize in a test.
+var scrollbar_prefs = prefs.slice();  // make a copy
+scrollbar_prefs.push(["layout.scrollbars.always-layerize-track", true]);
+
 var subtests = [
   {'file': 'helper_scroll_on_position_fixed.html', 'prefs': prefs},
   {'file': 'helper_bug1271432.html', 'prefs': prefs},
   {'file': 'helper_scroll_inactive_perspective.html', 'prefs': prefs},
-  {'file': 'helper_scroll_inactive_zindex.html', 'prefs': prefs}
+  {'file': 'helper_scroll_inactive_zindex.html', 'prefs': prefs},
+  {'file': 'helper_scroll_over_scrollbar.html', 'prefs': scrollbar_prefs}
 ];
 
 if (isApzEnabled()) {
   SimpleTest.waitForExplicitFinish();
   window.onload = function() {
     runSubtestsSeriallyInFreshWindows(subtests)
     .then(SimpleTest.finish);
   };