Bug 1328065 - Add a mochitest for scrolling over the scrollbar of a subframe. r=kats draft
authorBotond Ballo <botond@mozilla.com>
Fri, 17 Feb 2017 16:40:08 -0500
changeset 488223 c5649183c584e6dae558a9216a4120f7ab298e5b
parent 486361 e8a7aa5a1ccc813d220769bfe1c3e945e6fe81f4
child 546673 0264e29b28a176d2a6541c9f7ba7f318b31ee8ac
push id46462
push userbballo@mozilla.com
push dateWed, 22 Feb 2017 20:01:18 +0000
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);
   };