Bug 1415217 - Try to replace reftest error 'load failed with unknown reason' with informative messages. r=dholbert

If the reftest harness times out the load of a URL before the 'load' event
has even fired then the error message that we get is 'load failed with unknown
reason'.  This isn't very helpful for people unfamiliar with the harness.  This
change sets an initial error message that notes that we're waiting on the
'load' event, what the timeout delay is, and what URL we are/were waiting on
loading.  This will allow the timeout delay to be compared to log timestamps
and will make it clear whether the timeout occurred for some other URL than
the one we were expecting to load (which would be an error in the harness
logic).

It should now be impossible for the 'load failed with unknown reason' to occur,
but if there is a logic error in the harness code (some race condition?) then
it may still happen.

MozReview-Commit-ID: JOb1kYBpLro
This commit is contained in:
Jonathan Watt 2017-10-19 16:59:32 +01:00
Родитель 11b689fe45
Коммит 64c37f30fa
2 изменённых файлов: 14 добавлений и 5 удалений

Просмотреть файл

@ -124,7 +124,7 @@ function OnInitialLoad()
LogInfo("Using browser remote="+ gBrowserIsRemote +"\n");
}
function SetFailureTimeout(cb, timeout)
function SetFailureTimeout(cb, timeout, uri)
{
var targetTime = Date.now() + timeout;
@ -139,6 +139,11 @@ function SetFailureTimeout(cb, timeout)
}
}
// Once OnDocumentLoad is called to handle the 'load' event it will update
// this error message to reflect what stage of the processing it has reached
// as it advances to each stage in turn.
gFailureReason = "timed out after " + timeout +
" ms waiting for 'load' event for " + uri;
gFailureTimeout = setTimeout(wrapper, timeout);
}
@ -164,7 +169,7 @@ function StartTestURI(type, uri, timeout)
if (gFailureTimeout != null) {
SendException("program error managing timeouts\n");
}
SetFailureTimeout(LoadFailed, timeout);
SetFailureTimeout(LoadFailed, timeout, uri);
LoadURI(gCurrentURL);
}

Просмотреть файл

@ -1172,10 +1172,14 @@ function RecordResult(testRunTime, errorMsg, typeSpecificResults)
function LoadFailed(why)
{
++g.testResults.FailedLoad;
// Once bug 896840 is fixed, this can go away, but for now it will give log
// output that is TBPL starable for bug 789751 and bug 720452.
if (!why) {
logger.error("load failed with unknown reason");
// reftest-content.js sets an initial reason before it sets the
// timeout that will call us with the currently set reason, so we
// should never get here. If we do then there's a logic error
// somewhere. Perhaps tests are somehow running overlapped and the
// timeout for one test is not being cleared before the timeout for
// another is set? Maybe there's some sort of race?
logger.error("load failed with unknown reason (we should always have a reason!)");
}
logger.testStatus(g.urls[0].identifier, "load failed: " + why, "FAIL", "PASS");
FlushTestBuffer();