Bug 1389492 - Ensure the helper_key_scroll waits for repaints from the main-thread scroll to finish before triggering the async scroll. r=rhunt
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 11 Aug 2017 10:37:25 -0400
changeset 374293 eeb77c809dc04e99135c656a6cb2a2f0702200ba
parent 374292 d959eb7903fd5d5ecbc48aa3aef0f7655c7dd0fb
child 374294 5a5bf9b4754a949de374028f5519a13b6095c6fa
push id32320
push userarchaeopteryx@coole-files.de
push dateSat, 12 Aug 2017 21:35:10 +0000
treeherdermozilla-central@6062341662fc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhunt
bugs1389492
milestone57.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 1389492 - Ensure the helper_key_scroll waits for repaints from the main-thread scroll to finish before triggering the async scroll. r=rhunt MozReview-Commit-ID: EsYz5LSc83Q
gfx/layers/apz/test/mochitest/helper_key_scroll.html
--- a/gfx/layers/apz/test/mochitest/helper_key_scroll.html
+++ b/gfx/layers/apz/test/mochitest/helper_key_scroll.html
@@ -38,31 +38,44 @@ https://bugzilla.mozilla.org/show_bug.cg
       window.addEventListener("scroll", waitForScrollBottom);
       window.synthesizeKey("VK_END", {});
     };
 
     function waitForScrollBottom() {
       if (window.scrollY < window.scrollYMax) {
         return;
       }
+      SimpleTest.info("Reached final scroll position of sync VK_END scroll");
       window.removeEventListener("scroll", waitForScrollBottom);
 
-      // Wait for scrolling to finish before dispatching the next key input or
-      // the default action won't occur.
+      // Spin the refresh driver a few times, so that the AsyncScroll instance
+      // that was running the main-thread scroll animation finishes up and
+      // triggers any repaints that it needs to.
+      var utils = SpecialPowers.DOMWindowUtils;
+      for (var i = 0; i < 10; i++) {
+        utils.advanceTimeAndRefresh(50);
+      }
+      utils.restoreNormalRefresh();
+
+      // Wait for the APZ to reach a stable state as well, before dispatching
+      // the next key input or the default action won't occur.
       waitForApzFlushedRepaints(function () {
+        SimpleTest.is(checkHasAsyncKeyScrolled(false), false, "expected no async key scrolling before VK_HOME dispatch");
+
         // This scroll should be asynchronous now that the focus state is up to date.
         window.addEventListener("scroll", waitForScrollTop);
         window.synthesizeKey("VK_HOME", {});
       });
     };
 
     function waitForScrollTop() {
       if (window.scrollY > 0) {
         return;
       }
+      SimpleTest.info("Reached final scroll position of async VK_HOME scroll");
       window.removeEventListener("scroll", waitForScrollTop);
 
       // Wait for APZ to settle and then check that async scrolling happened.
       waitForApzFlushedRepaints(function () {
         SimpleTest.is(checkHasAsyncKeyScrolled(true), true, "expected async key scrolling after test");
         window.opener.finishTest();
       });
     };