Bug 576151 - Better message for leftover tabs and windows on timed out browser-chrome tests. r=gavin

This commit is contained in:
Marco Bonardo 2010-07-15 22:38:03 +02:00
parent 7dc17cbb3f
commit db29d29142

View File

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