Bug 1374790 - Wait until APZ is ready before sending it a wheel event. r=mats, a=test-only
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 23 Oct 2018 18:58:10 +0000
changeset 500811 162f30523a121ecc86ec9f4da668f2321fb2d6bf
parent 500810 e8cd0248b93cab0e1377389da0a00e7223542748
child 500812 0c7b395eedb4b03e90bd2b0ac909582f37f77677
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats, test-only
bugs1374790
milestone64.0
Bug 1374790 - Wait until APZ is ready before sending it a wheel event. r=mats, a=test-only Differential Revision: https://phabricator.services.mozilla.com/D9567
layout/generic/test/mochitest.ini
layout/generic/test/test_bug784410.html
--- a/layout/generic/test/mochitest.ini
+++ b/layout/generic/test/mochitest.ini
@@ -12,16 +12,17 @@ support-files =
   plugin_focus_helper.html
   file_BrokenImageReference.png
   file_Dolske.png
   file_IconTestServer.sjs
   file_LoadingImageReference.png
   file_SlowImage.sjs
   file_SlowPage.sjs
   bug1174521.html
+  !/gfx/layers/apz/test/mochitest/apz_test_utils.js
 
 [test_bug240933.html]
 [test_bug263683.html]
 [test_bug288789.html]
 [test_bug290397.html]
 [test_bug323656.html]
 [test_bug344830.html]
 support-files = bug344830_testembed.svg
--- a/layout/generic/test/test_bug784410.html
+++ b/layout/generic/test/test_bug784410.html
@@ -1,15 +1,16 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test bug 784410</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   <script src="/tests/SimpleTest/paint_listener.js"></script>
+  <script src="/tests/gfx/layers/apz/test/mochitest/apz_test_utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <p id="display"></p>
 <div id="outer" style="overflow:auto; height:200px; border:2px dotted black; transform: translateY(1px)" onscroll="doneScroll()">
   <div id="d" style="overflow:auto; height:102px;" onscroll="doneScroll()">
     <div id="inner" style="height:100.1px; border:1px solid black; background:yellow;">Hello</div>
   </div>
@@ -35,23 +36,26 @@ function doneScroll() {
   switch (step) {
   case 1:
     is(innerScrollOffset(), innerStartScrollOffset, "Inner element should not have scrolled down");
     ok(outer.scrollTop > 0, "Outer element should have scrolled down");
 
     outer.scrollTop = 0;
     break;
   case 2:
-    // Wait for paints to flush, so APZ is notified of the new scroll offset.
-    sendWheelAndPaint(inner, 4, 4,
-      { deltaMode: WheelEvent.DOM_DELTA_LINE, deltaY: 1 },
-      function() {
-          wheelAndPaintDone = true;
-          doneTest();
-      });
+    // wait until APZ is ready to handle the wheel event, then send it
+    waitForApzFlushedRepaints(() => {
+      // Wait for paints to flush, so APZ is notified of the new scroll offset.
+      sendWheelAndPaint(inner, 4, 4,
+        { deltaMode: WheelEvent.DOM_DELTA_LINE, deltaY: 1 },
+        function() {
+            wheelAndPaintDone = true;
+            doneTest();
+        });
+    });
     break;
   case 3:
     is(innerScrollOffset(), innerStartScrollOffset, "Inner element should not have scrolled down");
     ok(outer.scrollTop > 0, "Outer element should have scrolled down");
     
     doneTest();
     break;
   }