Bug 1298084 - Manually tick the refresh driver to ensure the interrupted reflow happens when we want it to. r?tnikkel
MozReview-Commit-ID: 2q9hdZPjrPt
--- 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