Bug 1440118 - Mochitest for scrolling over unlayerized subframe with overscroll-behavior. r=kats draft
authorBotond Ballo <botond@mozilla.com>
Fri, 23 Feb 2018 16:11:50 -0500
changeset 759220 f82947aa3cd259880ba1013566421113d574238f
parent 759219 a75aa57831ec65f6390b445a24481900195e0441
push id100311
push userbballo@mozilla.com
push dateFri, 23 Feb 2018 21:53:16 +0000
reviewerskats
bugs1440118
milestone60.0a1
Bug 1440118 - Mochitest for scrolling over unlayerized subframe with overscroll-behavior. r=kats MozReview-Commit-ID: JbMpBQqBm2y
gfx/layers/apz/test/mochitest/helper_scroll_overscroll_behavior.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_overscroll_behavior.html
@@ -0,0 +1,54 @@
+<head>
+  <meta name="viewport" content="width=device-width; initial-scale=1.0">
+  <title>Wheel-scrolling over inactive subframe with overscroll-behavior</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 utils = SpecialPowers.getDOMWindowUtils(window);
+  var isWebRender = (utils.layerManagerType == 'WebRender');
+  if (!isWebRender) {
+    // After bug 1440112 is fixed, the test can be enabled
+    // for non-WebRender as well.
+    ok(true, "This test is only enabled for WebRender");
+    return;
+  }
+
+  var subframe = document.getElementById('scroll');
+
+  // scroll over the middle of the subframe, and make sure that the page
+  // does not scroll.
+  var scrollPos = subframe.scrollTop;
+  var waitForScroll = false;  // don't wait for a scroll event, it will never come
+  yield moveMouseAndScrollWheelOver(subframe, 100, 100, testDriver, waitForScroll);
+  ok(window.scrollY == 0, "overscroll-behavior was respected");
+}
+
+waitUntilApzStable()
+.then(runContinuation(test))
+.then(subtestDone);
+
+  </script>
+  <style>
+    #scroll {
+      width: 200px;
+      height: 200px;
+      overflow: scroll;
+      overscroll-behavior: contain;
+    }
+    #scrolled {
+      width: 200px;
+      height: 1000px; /* so the subframe has room to scroll */
+      background: linear-gradient(red, blue); /* so you can see it scroll */
+    }
+  </style>
+</head>
+<body>
+  <div id="scroll">
+    <div id="scrolled"></div>
+  </div>
+  <div style="height: 5000px;"></div><!-- So the page is scrollable as well -->
+</body>
+</head>
--- a/gfx/layers/apz/test/mochitest/mochitest.ini
+++ b/gfx/layers/apz/test/mochitest/mochitest.ini
@@ -24,16 +24,17 @@
     helper_key_scroll.html
     helper_long_tap.html
     helper_override_root.html
     helper_override_subdoc.html
     helper_scroll_inactive_perspective.html
     helper_scroll_inactive_zindex.html
     helper_scroll_on_position_fixed.html
     helper_scroll_over_scrollbar.html
+    helper_scroll_overscroll_behavior.html
     helper_scroll_tables_perspective.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
--- a/gfx/layers/apz/test/mochitest/test_group_wheelevents.html
+++ b/gfx/layers/apz/test/mochitest/test_group_wheelevents.html
@@ -21,23 +21,29 @@ var prefs = [
 
 // 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]);
 
+// For helper_scroll_overscroll_behavior, we need to set the APZ content
+// response timeout to 0, so we exercise the fallback codepath.
+var timeout_prefs = prefs.slice();  // make a copy
+timeout_prefs.push(["apz.content_response_timeout", 0]);
+
 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_over_scrollbar.html', 'prefs': scrollbar_prefs},
   {'file': 'helper_scroll_tables_perspective.html', 'prefs': prefs},
+  {'file': 'helper_scroll_overscroll_behavior.html', 'prefs': timeout_prefs},
 ];
 
 if (isApzEnabled()) {
   SimpleTest.waitForExplicitFinish();
   window.onload = function() {
     runSubtestsSeriallyInFreshWindows(subtests)
     .then(SimpleTest.finish);
   };