Bug 1062609 - Make scroll-behaviour test work with APZ enabled. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 06 May 2019 17:50:14 +0000
changeset 531561 c705a64ce83c3e320529baf9527e7060ff2c7bcd
parent 531560 dc4761caa7d426bfcb76dfff7844129f13854ad9
child 531562 2d8bdc083e77da5b7b84589130d041d580319701
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1062609
milestone68.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 1062609 - Make scroll-behaviour test work with APZ enabled. r=botond The test itself is reasonable, except that it reads scroll positions from the main thread. With APZ enabled we need to flush any pending APZ repaints before reading these scroll positions. So changing the waitForAllPaints to the APZ-flushing variant makes that happen, and the test passes. Depends on D29921 Differential Revision: https://phabricator.services.mozilla.com/D29922
layout/generic/test/test_scroll_behavior.html
--- a/layout/generic/test/test_scroll_behavior.html
+++ b/layout/generic/test/test_scroll_behavior.html
@@ -14,37 +14,30 @@
       top: 10000px;
       width: 200px;
       height: 200px;
       background-color: rgb(0, 0, 255);
     }
   </style>
   <script src="/tests/SimpleTest/SimpleTest.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"/>
   <script type="application/javascript">
 
   SimpleTest.waitForExplicitFinish();
 
   function clamp(val, minVal, maxVal) {
     return Math.max(minVal, Math.min(maxVal, val));
   }
 
   window.addEventListener("load", function(event) {
     if (event.target != document)
       return;
 
-    // See bug 1062609 - these tests do not work with APZ yet. If APZ is
-    // enabled, end the tests early.
-    if (SpecialPowers.getBoolPref("layers.async-pan-zoom.enabled")) {
-      todo(false, "This test does not yet work with APZ.");
-      SimpleTest.finish();
-      return;
-    }
-
     SpecialPowers.pushPrefEnv(
       { 'set': [['layout.css.scroll-behavior.enabled', true]] },
       function () {
         testScrollBehaviorInterruption(function() {
           testScrollBehaviorFramerate(function() {
             window.scrollTo(0,0);
             SimpleTest.finish();
           });
@@ -52,48 +45,48 @@
       }
     );
   });
 
 
   function testScrollBehaviorInterruption(nextTest) {
     // Take control of refresh driver
     SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(0);
-    waitForAllPaintsFlushed(function() {
+    waitForApzFlushedRepaints(function() {
 
       window.scrollTo(10, 9);
       ok(window.scrollX == 10 && window.scrollY == 9,
         "instant scroll-behavior must be synchronous when setting initial position");
 
       window.scrollTo(15, 16);
       ok(window.scrollX == 15 && window.scrollY == 16,
         "instant scroll-behavior must be synchronous when setting new position");
 
       window.scrollTo({left: 100, top: 200, behavior: 'smooth'});
       ok(window.scrollX == 15 && window.scrollY == 16,
         "smooth scroll-behavior must be asynchronous");
 
       SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(100);
-      waitForAllPaintsFlushed(function() {
+      waitForApzFlushedRepaints(function() {
         ok(window.scrollX != 15 && window.scrollY != 16
            && window.scrollX != 100 && window.scrollY != 200,
           "smooth scroll-behavior must be triggered by window.scrollTo");
 
         window.scrollTo(50, 52);
         ok(window.scrollX == 50 && window.scrollY == 52,
           "instant scroll-behavior must interrupt smooth scroll-behavior animation");
 
         SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(100);
-        waitForAllPaintsFlushed(function() {
+        waitForApzFlushedRepaints(function() {
           ok(window.scrollX == 50 && window.scrollY == 52,
             "smooth scroll-behavior animation must stop after being interrupted");
 
           // Release control of refresh driver
           SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
-          waitForAllPaintsFlushed(nextTest);
+          waitForApzFlushedRepaints(nextTest);
         });
       });
     });
   }
 
   function testScrollBehaviorFramerate(nextTest) {
     /**
      *  CSSOM-View scroll-behavior smooth scroll animations must produce the
@@ -209,17 +202,17 @@
               });
 
               is(maxVariance, 0, 'Smooth scroll animated position must not be '
                  + 'framerate dependent at deltaX: ' + deltaX + ', deltaY: '
                  + deltaY + ', frameRate: ' + frameRate + 'fps');
               testFrameRate();
             });
           } else {
-            waitForAllPaintsFlushed(testDeltas);
+            waitForApzFlushedRepaints(testDeltas);
           }
         }
 
         testFrameRate();
 
       });
     }
 
@@ -239,31 +232,31 @@
 
     var positionSamples = [];
 
     var frameCountAtDestination = 0;
 
     // Take control of refresh driver so we can synthesize
     // various frame rates
     SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(0);
-    waitForAllPaintsFlushed(function() {
+    waitForApzFlushedRepaints(function() {
 
       window.scrollTo(startX, startY);
       window.scrollTo({left: endX, top: endY, behavior: 'smooth'});
 
       var currentTime = 0; // ms
 
       function advanceTime() {
         if(currentTime < maxTime && frameCountAtDestination < 15) {
 
           positionSamples.push([window.scrollX, window.scrollY]);
 
           currentTime += timeStep;
           SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(timeStep);
-          waitForAllPaintsFlushed(function() {
+          waitForApzFlushedRepaints(function() {
             if (window.scrollX == endX && window.scrollY == endY) {
               frameCountAtDestination++;
             } else {
               frameCountAtDestination = 0;
             }
 
             advanceTime();
           });
@@ -274,17 +267,17 @@
                 + 'unless they are interrupted, at deltaX: '
                 + (endX - startX) + ', deltaY: ' + (endY - startY));
 
           window.scrollTo(0, 0);
 
           // Release control of refresh driver
           SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
 
-          waitForAllPaintsFlushed(function() {
+          waitForApzFlushedRepaints(function() {
 
             // We must not include the duplicated frames at the animation
             // destination as the tests are dependant on the total duration of
             // the animation to be accurate.
             positionSamples.splice(1 - minStoppedFrames,
                                    minStoppedFrames - 1);
 
             callback(positionSamples);