From 6a2fcb969fd51a5e72bc7c711c04f9522ef33641 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Fri, 1 Jun 2012 20:52:37 +0200 Subject: [PATCH] Bug 759789 - Don't move on to the next test (or finishing) until we get all expected non-optional 'loadend' events. r=smaug --- content/base/test/test_bug435425.html | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/content/base/test/test_bug435425.html b/content/base/test/test_bug435425.html index 8226699955a6..b26e231eeda0 100644 --- a/content/base/test/test_bug435425.html +++ b/content/base/test/test_bug435425.html @@ -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); } }