From db29d2914242468d4db9310b30ddc05f6b63fde0 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Thu, 15 Jul 2010 22:38:03 +0200 Subject: [PATCH] Bug 576151 - Better message for leftover tabs and windows on timed out browser-chrome tests. r=gavin --- testing/mochitest/browser-test.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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);