diff --git a/docshell/test/bug369814.zip b/docshell/test/bug369814.zip index b4791c6b6024..a6e9a68a8514 100644 Binary files a/docshell/test/bug369814.zip and b/docshell/test/bug369814.zip differ diff --git a/docshell/test/test_bug369814.html b/docshell/test/test_bug369814.html index 5aa4799762f7..0810cc4a34da 100644 --- a/docshell/test/test_bug369814.html +++ b/docshell/test/test_bug369814.html @@ -23,9 +23,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=369814 SimpleTest.waitForExplicitFinish(); // Because child scripts won't be able to run to tell us they're done, -// we need to just wait for them. Wait this amount of time before checking -// the results. -const gLoadTimeout = 3000; +// we need to just wait for them. Wait this many event loop spins before +// checking the results. +const gLoadEventLoopCount = 100; var Ci = Components.interfaces; @@ -68,10 +68,20 @@ function closeTestTarget() function loadErrorTest(test) { - gTestFrame.src = test['url']; - - // Give the frame a chance to fail at loading - setTimeout(function() { + // Give the frame a chance to fail at loading. + // How do detect failure to load? Error pages don't fire load + // events. But we can load another page before the error page and + // then use its unload handler to know when the error page is just + // about loaded; at that point a single trip through the event loop + // should do the trick. + loadEvent(gTestFrame, function() { + gTestFrame.src = test['url']; + }); + gTestFrame.unloading = function() { + gTestFrame.unloading = null; + // Go out to the event loop once so that unload processing finishes and + // the new document is set up. + setTimeout(function() { // XXX: There doesn't seem to be a reliable check for "got an error," // but reaching in to an error document will throw an exception var errorPage; @@ -84,7 +94,10 @@ function loadErrorTest(test) ok(errorPage, gCurrentTest["name"] + ": should block a suspicious JAR load."); finishTest(); - }, gLoadTimeout); + }, 0); + } + var unloadDetector = "data:text/html,