diff --git a/testing/mochitest/tests/SimpleTest/SimpleTest.js b/testing/mochitest/tests/SimpleTest/SimpleTest.js index 889492537df..deec90bb82e 100644 --- a/testing/mochitest/tests/SimpleTest/SimpleTest.js +++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js @@ -298,15 +298,22 @@ SimpleTest.waitForFocus = function (callback, targetWindow, expectBlankPage) { } function waitForEvent(event) { - // Check to make sure that this isn't a load event for a blank or - // non-blank page that wasn't desired. - if (event.type == "load" && (expectBlankPage != (event.target.location == "about:blank"))) - return; + try { + debugFocusLog("waitForEvent called "); - SimpleTest["waitForFocus_" + event.type + "ed"] = true; - var win = (event.type == "load") ? targetWindow : childTargetWindow; - win.removeEventListener(event.type, waitForEvent, true); - maybeRunTests(); + // Check to make sure that this isn't a load event for a blank or + // non-blank page that wasn't desired. + if (event.type == "load" && (expectBlankPage != (event.target.location == "about:blank"))) + return; + + SimpleTest["waitForFocus_" + event.type + "ed"] = true; + var win = (event.type == "load") ? targetWindow : childTargetWindow; + win.removeEventListener(event.type, waitForEvent, true); + maybeRunTests(); + } catch (e) { + SimpleTest.ok(false, "Exception caught in waitForEvent: " + e.message + + ", at: " + e.fileName + " (" + e.lineNumber + ")"); + } } // If the current document is about:blank and we are not expecting a blank