Bug 1374790 - Wait until APZ is ready before sending it a wheel event. r=mats
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 23 Oct 2018 18:58:10 +0000
changeset 490958 4e9062d05672fe1494fb5562ba3726fa57d269ff
parent 490957 f5f7adca7a89585b6bf4b0a481724bd9aa9b87a7
child 490959 aa716a3cae86d41a1e40b1068549de2f303d2be8
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersmats
bugs1374790
milestone65.0a1
Bug 1374790 - Wait until APZ is ready before sending it a wheel event. r=mats 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;
   }