Bug 1363829 P9 Make docshell chrome tests wait for next paint to avoid races. r=smaug

This commit is contained in:
Ben Kelly 2017-05-31 17:13:19 -07:00
parent 9a57bd14ec
commit e89c30f6c4
2 changed files with 7 additions and 3 deletions

View File

@ -58,7 +58,7 @@
0, 0, 0, 0,
false, false, false, false, 0, null);
TestWindow.getDocument().getElementById("link1").dispatchEvent(event);
setTimeout(nextTest, 0);
waitForNextPaint(nextTest);
yield undefined;
// Store the fragment url for later comparison.

View File

@ -283,7 +283,7 @@ function pageEventListener(event) {
// doPageNavigation() to return.
if ((typeof(gExpectedEvents) == "undefined") && event.type == "pageshow")
{
setTimeout(function() { gFinalEvent = true; }, 0);
waitForNextPaint(function() { gFinalEvent = true; });
return;
}
@ -332,7 +332,7 @@ function pageEventListener(event) {
// If we're out of expected events, let doPageNavigation() return.
if (gExpectedEvents.length == 0)
setTimeout(function() { gFinalEvent = true; }, 0);
waitForNextPaint(function() { gFinalEvent = true; });
}
/**
@ -417,6 +417,10 @@ function waitForTrue(fn, onWaitComplete, timeout) {
}, 20);
}
function waitForNextPaint(cb) {
requestAnimationFrame(_ => requestAnimationFrame(cb));
}
/**
* Enable or disable the bfcache.
*