Bug 1453425 - Add test for relative scroll offset updates. r=botond
authorRyan Hunt <rhunt@eqrion.net>
Tue, 23 Oct 2018 09:50:52 -0500
changeset 442910 ab584824a073d21864e6aa8d571c8c5624151c73
parent 442909 0b8e2732f2a52453c4450cc22dba292f1d2ce8b6
child 442911 fbb568aa121e33fedf00c3be48a04c1593af9591
push id34927
push userncsoregi@mozilla.com
push dateThu, 25 Oct 2018 04:45:44 +0000
treeherdermozilla-central@76d5b62fb151 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1453425
milestone65.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 1453425 - Add test for relative scroll offset updates. r=botond
gfx/layers/apz/test/mochitest/mochitest.ini
gfx/layers/apz/test/mochitest/test_relative_update.html
--- a/gfx/layers/apz/test/mochitest/mochitest.ini
+++ b/gfx/layers/apz/test/mochitest/mochitest.ini
@@ -31,16 +31,18 @@
 [test_group_wheelevents.html]
   skip-if = (toolkit == 'android') # wheel events not supported on mobile
 [test_group_zoom.html]
   skip-if = (os == 'win') || webrender # zooming is not supported yet on WebRender; see bug 1495580 for Windows
 [test_interrupted_reflow.html]
 [test_group_keyboard.html]
 [test_layerization.html]
   skip-if = (os == 'android') # wheel events not supported on mobile
+[test_relative_update.html]
+  skip-if = (os == 'android') # wheel events not supported on mobile
 [test_scroll_inactive_bug1190112.html]
   skip-if = (os == 'android') # wheel events not supported on mobile
 [test_scroll_inactive_flattened_frame.html]
   skip-if = (os == 'android') # wheel events not supported on mobile
 [test_scroll_subframe_scrollbar.html]
   skip-if = (os == 'android') # wheel events not supported on mobile
 [test_touch_listeners_impacting_wheel.html]
   skip-if = (toolkit == 'android') || (toolkit == 'cocoa') # wheel events not supported on mobile, and synthesized wheel smooth-scrolling not supported on OS X
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/test_relative_update.html
@@ -0,0 +1,92 @@
+<!DOCTYPE HTML>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1453425
+-->
+<html>
+<head>
+    <title>Test for relative scroll offset updates (Bug 1453425)</title>
+    <meta charset="utf-8">
+    <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+    <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+    <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
+    <script type="application/javascript" src="apz_test_utils.js"></script>
+    <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
+    <style type="text/css">
+        #frame {
+            width: 200px;
+            height: 400px;
+            overflow: scroll;
+            border: 1px solid black;
+        }
+        #first {
+            width: 200px;
+            height: 108px;
+            background-color: red;
+        }
+        #second {
+            width: 200px;
+            height: 692px;
+            background-color: green;
+        }
+    </style>
+</head>
+<body>
+    <div id="frame">
+        <div id="first"></div>
+        <div id="second"></div>
+    </div>
+<script type="application/javascript">
+function* test(testDriver) {
+  var utils = SpecialPowers.DOMWindowUtils;
+
+  var elm = document.querySelector('#frame');
+  // Set a zero-margin displayport to ensure that the element is async-scrollable
+  utils.setDisplayPortMarginsForElement(0, 0, 0, 0, elm, 0);
+  elm.scrollTop = 0;
+
+  // Take over control of the refresh driver and don't allow a layer
+  // transaction until the main thread and APZ have processed two different
+  // scrolls.
+  yield waitForApzFlushedRepaints(testDriver);
+  utils.advanceTimeAndRefresh(0);
+
+  // Scroll instantly on the main thread by (0, 100).
+  elm.scrollBy(0, 100);
+
+  // We are not using `scroll-behavior`
+  is(elm.scrollTop, 100, 'the main thread scroll should be instant');
+
+  // Dispatch a wheel event to have APZ scroll by (0, 8). Wait for the wheel
+  // event to ensure that the APZ has processed the scroll.
+  yield synthesizeNativeWheelAndWaitForWheelEvent(elm, 40, 40, 0, -8, testDriver);
+
+  // APZ should be handling the wheel scroll
+  is(elm.scrollTop, 100, 'the wheel scroll should be handled by APZ');
+
+  // Restore control of the refresh driver, allowing the main thread to send a
+  // layer transaction containing the (0, 100) scroll.
+  utils.restoreNormalRefresh();
+
+  // Wait for all paints to finish and for the main thread to receive pending
+  // repaint requests with the scroll offset from the wheel event.
+  yield waitForApzFlushedRepaints(testDriver);
+
+  // The main thread scroll should not have overidden the APZ scroll, and we
+  // should see the effects of both scrolls.
+  ok(elm.scrollTop > 100, `expected element.scrollTop > 100. got element.scrollTop = ${elm.scrollTop}`);
+}
+
+if (isApzEnabled()) {
+  SimpleTest.waitForExplicitFinish();
+  // Receiving a relative scroll offset update can cause scroll animations to
+  // be cancelled. This should be fixed, but for now we can still test this
+  // by disabling smooth scrolling.
+  pushPrefs([["apz.relative-update.enabled", true], ["general.smoothScroll", false]])
+  .then(waitUntilApzStable)
+  .then(runContinuation(test))
+  .then(SimpleTest.finish);
+}
+
+</script>
+</body>
+</html>