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 340529 e20dac56cfb260f1fcbd2d6a8f1f9625cecdc201
parent 340528 4e78a1131df04cca842c7bf1fcb6b873f8a0a0e9
child 340530 312c81362c08343b006d3c97ace270a97f95f45e
push id6358
push userryanvm@gmail.com
push dateTue, 30 Aug 2016 22:07:49 +0000
treeherdermozilla-beta@c8383470a0c4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel, test-only
bugs1298084
milestone49.0
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