Bug 1229250 - Auto-extend the reftest timeout - r=kats

This commit is contained in:
Edwin Flores 2016-02-16 14:46:56 +00:00
parent 9e6a5653e4
commit 7d1d94d936

View File

@ -119,6 +119,24 @@ function OnInitialLoad()
LogWarning("Using browser remote="+ gBrowserIsRemote +"\n");
}
function SetFailureTimeout(cb, timeout)
{
var targetTime = Date.now() + timeout;
var wrapper = function() {
// Timeouts can fire prematurely in some cases (e.g. in chaos mode). If this
// happens, set another timeout for the remaining time.
let remainingMs = targetTime - Date.now();
if (remainingMs > 0) {
SetFailureTimeout(cb, remainingMs);
} else {
cb();
}
}
gFailureTimeout = setTimeout(wrapper, timeout);
}
function StartTestURI(type, uri, timeout)
{
// Reset gExplicitPendingPaintCount in case there was a timeout or
@ -136,7 +154,7 @@ function StartTestURI(type, uri, timeout)
if (gFailureTimeout != null) {
SendException("program error managing timeouts\n");
}
gFailureTimeout = setTimeout(LoadFailed, timeout);
SetFailureTimeout(LoadFailed, timeout);
LoadURI(gCurrentURL);
}