Bug 759789 - Don't move on to the next test (or finishing) until we get all expected non-optional 'loadend' events. r=smaug

This commit is contained in:
Mats Palmgren 2012-06-01 20:52:37 +02:00
parent 549c88c013
commit a5de49366d

View File

@ -45,9 +45,20 @@ function logEvent(evt) {
}
}
function stop(evt) {
function hasPendingNonOptionalEvent(ev) {
var i = 0;
while (i < currentEvents.length) {
if (!currentEvents[i].optional && currentEvents[i].type == ev)
return true;
++i;
}
return false;
}
function maybeStop(evt) {
logEvent(evt);
nextTest();
if (!hasPendingNonOptionalEvent("loadend"))
nextTest();
}
function openXHR(xhr, method, url, privileged) {
@ -83,7 +94,7 @@ function start(obj) {
}
xhr.onloadend =
function (evt) {
stop(evt);
maybeStop(evt);
}
xhr.onloadstart =
function (evt) {
@ -121,7 +132,7 @@ function start(obj) {
}
xhr.upload.onloadend =
function (evt) {
logEvent(evt);
maybeStop(evt);
}
}