Bug 1298084 - Manually tick the refresh driver to ensure the interrupted reflow happens when we want it to. r=tnikkel a=test-only
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 29 Aug 2016 16:22:57 -0400
changeset 347905 a163da3582e35a2e58d844fc23c28193149891ee
parent 347904 f6d69919d05a774439b18fd0818fa927504289b9
child 347906 c819e284a13937fc955c2efb6da7fdf9c5bb8b88
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel, test-only
bugs1298084
milestone50.0a2
Bug 1298084 - Manually tick the refresh driver to ensure the interrupted reflow happens when we want it to. r=tnikkel a=test-only 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