diff --git a/testing/mochitest/browser-test.js b/testing/mochitest/browser-test.js index ea4ec51e5ad..7e0d4d2ac38 100644 --- a/testing/mochitest/browser-test.js +++ b/testing/mochitest/browser-test.js @@ -71,11 +71,16 @@ Tester.prototype = { }, waitForWindowsState: function Tester_waitForWindowsState(aCallback) { + let timedOut = this.currentTest && this.currentTest.timedOut; + let baseMsg = timedOut ? "Found a {elt} after previous test timed out" + : this.currentTest ? "Found an unexpected {elt} at the end of test run" + : "Found an unexpected {elt}"; + if (this.currentTest && window.gBrowser && gBrowser.tabs.length > 1) { while (gBrowser.tabs.length > 1) { let lastTab = gBrowser.tabContainer.lastChild; - let msg = "Found an unexpected tab at the end of test run: " + - lastTab.linkedBrowser.currentURI.spec; + let msg = baseMsg.replace("{elt}", "tab") + + ": " + lastTab.linkedBrowser.currentURI.spec; this.currentTest.addResult(new testResult(false, msg, "", false)); gBrowser.removeTab(lastTab); } @@ -86,11 +91,9 @@ Tester.prototype = { while (windowsEnum.hasMoreElements()) { let win = windowsEnum.getNext(); if (win != window && !win.closed) { - let msg = "Found an unexpected browser window"; - if (this.currentTest) { - msg += " at the end of test run"; + let msg = baseMsg.replace("{elt}", "browser window"); + if (this.currentTest) this.currentTest.addResult(new testResult(false, msg, "", false)); - } else this.dumper.dump("TEST-UNEXPECTED-FAIL | (browser-test.js) | " + msg + "\n"); @@ -222,6 +225,7 @@ Tester.prototype = { return; } self.currentTest.addResult(new testResult(false, "Timed out", "", false)); + self.currentTest.timedOut = true; self.currentTest.scope.__waitTimer = null; self.nextTest(); }, TIMEOUT_SECONDS * 1000);