Bug 1298084 - Manually tick the refresh driver to ensure the interrupted reflow happens when we want it to. r?tnikkel draft
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 29 Aug 2016 16:22:57 -0400
changeset 406882 ef8936e01ca695de766c2c3bfc15fcdaff9d9080
parent 406838 acfb2c3ac6ae0a704e2756184815296ac1314f89
child 529777 ffe1d9f30acc71bdd9db0db43b251f9f36029b18
push id27859
push userkgupta@mozilla.com
push dateMon, 29 Aug 2016 20:23:35 +0000
reviewerstnikkel
bugs1298084
milestone51.0a1
Bug 1298084 - Manually tick the refresh driver to ensure the interrupted reflow happens when we want it to. r?tnikkel MozReview-Commit-ID: 2q9hdZPjrPt
gfx/layers/apz/test/mochitest/test_interrupted_reflow.html
--- a/gfx/layers/apz/test/mochitest/test_interrupted_reflow.html
+++ b/gfx/layers/apz/test/mochitest/test_interrupted_reflow.html
@@ -608,27 +608,42 @@ function* test(testDriver) {
   utils.setDisplayPortMarginsForElement(0, 0, 0, 0, elm, 0);
 
   var maxScroll = elm.scrollTopMax;
   elm.scrollTop = maxScroll;
   yield waitForAllPaints(function() {
     flushApzRepaints(testDriver);
   });
 
+  // Take control of the refresh driver
+  utils.advanceTimeAndRefresh(0);
+
+  // Force the next reflow to get interrupted
   utils.forceReflowInterrupt();
-  // Trigger the frame reconstruction. The reflow that results will be
-  // interrupted, and we should end up with a transient 0,0 scroll offset.
+
+  // Make a change that triggers frame reconstruction, and then tick the refresh
+  // driver so that layout processes the pending restyles and then runs an
+  // interruptible reflow. That reflow *will* be interrupted (because of the flag
+  // we set above), and we should end up with a transient 0,0 scroll offset
+  // being sent to the compositor.
   elm.parentNode.classList.add('contentBefore');
-  yield waitForAllPaints(function() {
-    flushApzRepaints(testDriver);
-  });
+  utils.advanceTimeAndRefresh(0);
+  // On android, and maybe non-e10s platforms generally, we need to manually
+  // kick the paint to send the layer transaction to the compositor.
+  yield waitForAllPaints(function() { setTimeout(testDriver, 0) });
 
+  // Read the main-thread scroll offset; although this is temporarily 0,0 that
+  // temporary value is never exposed to content - instead reading this value
+  // will finish doing the interrupted reflow from above and then report the
+  // correct scroll offset.
   is(elm.scrollTop, maxScroll, "Main-thread scroll position was restored");
 
-  // Ensure the interrupted reflow finished and got pushed to the APZ
+  // .. and now flush everything to make sure the state gets pushed over to the
+  // compositor and APZ as well.
+  utils.restoreNormalRefresh();
   yield waitForApzFlushedRepaints(testDriver);
 
   // Now we pull the compositor data and check it. What we expect to see is that
   // the scroll position goes to maxScroll, then drops to 0 and then goes back
   // to maxScroll. This test is specifically testing that last bit - that it
   // properly gets restored from 0 to maxScroll.
   // The one hitch is that on Android this page is loaded with some amount of
   // zoom, and the async scroll is in ParentLayerPixel coordinates, so it will