Bug 729191 - Make debugger mochitests wait for debugger server shutdown before finishing; r=rcampbell

This commit is contained in:
Panos Astithas 2012-03-06 10:22:17 +02:00
parent 27aea514dd
commit 1a4d832c17
20 changed files with 186 additions and 89 deletions

View File

@ -7,7 +7,6 @@
var gPane = null;
var gTab = null;
var gDebuggee = null;
var gDebugger = null;
const DEBUGGER_TAB_URL = EXAMPLE_URL + "browser_dbg_debuggerstatement.html";
@ -15,7 +14,6 @@ const DEBUGGER_TAB_URL = EXAMPLE_URL + "browser_dbg_debuggerstatement.html";
function test() {
debug_tab_pane(DEBUGGER_TAB_URL, function(aTab, aDebuggee, aPane) {
gTab = aTab;
gDebuggee = aDebuggee;
gPane = aPane;
gDebugger = gPane.debuggerWindow;
@ -29,12 +27,16 @@ function testCleanExit() {
is(gDebugger.StackFrames.activeThread.paused, true,
"Should be paused after the debugger statement.");
gPane._client.addOneTimeListener("tabDetached", function () {
finish();
});
removeTab(gTab);
closeDebuggerAndFinish(gTab);
}}, 0);
});
gTab.linkedBrowser.contentWindow.wrappedJSObject.runDebuggerStatement();
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebugger = null;
});

View File

@ -55,10 +55,17 @@ function testLocationChange()
gPane._client.addOneTimeListener("tabAttached", function(aEvent, aPacket) {
ok(true, "Successfully reattached to the tab again.");
removeTab(gTab);
finish();
closeDebuggerAndFinish(gTab);
});
});
content.location = TAB1_URL;
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -6,13 +6,11 @@
var gPane = null;
var gTab = null;
var gDebuggee = null;
var gDebugger = null;
function test() {
debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
gTab = aTab;
gDebuggee = aDebuggee;
gPane = aPane;
gDebugger = gPane.debuggerWindow;
@ -63,8 +61,7 @@ function testResume() {
is(button.label, gDebugger.DebuggerView.getStr("pauseLabel"),
"Button label should be pause when running.");
removeTab(gTab);
finish();
closeDebuggerAndFinish(gTab);
}}, 0);
});
@ -72,3 +69,9 @@ function testResume() {
gDebugger.document.getElementById("resume"),
gDebugger);
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
});

View File

@ -134,9 +134,15 @@ function resumeAndFinish() {
is(vs._scripts.itemCount, 6,
"Got too many script items in the list!");
removeTab(gTab);
finish();
closeDebuggerAndFinish(gTab);
});
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -116,16 +116,19 @@ function testSimpleCall() {
ok(!testScope.expanded,
"Clicking again the testScope tilte should collapse it.");
resumeAndFinish();
gDebugger.StackFrames.activeThread.resume(function() {
closeDebuggerAndFinish(gTab);
});
}}, 0);
});
gDebuggee.simpleCall();
}
function resumeAndFinish() {
gDebugger.StackFrames.activeThread.resume(function() {
removeTab(gTab);
finish();
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -118,16 +118,19 @@ function testSimpleCall() {
is(gDebugger.DebuggerView.Properties._vars.childNodes.length, 4,
"The scope should have been removed from the parent container tree.");
resumeAndFinish();
gDebugger.StackFrames.activeThread.resume(function() {
closeDebuggerAndFinish(gTab);
});
}}, 0);
});
gDebuggee.simpleCall();
}
function resumeAndFinish() {
gDebugger.StackFrames.activeThread.resume(function() {
removeTab(gTab);
finish();
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -73,16 +73,19 @@ function testSimpleCall() {
is(testScope.querySelector(".details").childNodes.length, 0,
"The var should have been removed from the parent container tree.");
resumeAndFinish();
gDebugger.StackFrames.activeThread.resume(function() {
closeDebuggerAndFinish(gTab);
});
}}, 0);
});
gDebuggee.simpleCall();
}
function resumeAndFinish() {
gDebugger.StackFrames.activeThread.resume(function() {
removeTab(gTab);
finish();
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -81,16 +81,19 @@ function testSimpleCall() {
is(testScope.querySelector(".details").childNodes.length, 0,
"The var should have been removed from the parent container tree.");
resumeAndFinish();
gDebugger.StackFrames.activeThread.resume(function() {
closeDebuggerAndFinish(gTab);
});
}}, 0);
});
gDebuggee.simpleCall();
}
function resumeAndFinish() {
gDebugger.StackFrames.activeThread.resume(function() {
removeTab(gTab);
finish();
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -117,17 +117,19 @@ function testSimpleCall() {
is(localVar5.querySelector(".info").textContent, "[object Object]",
"The grip information for the localVar5 wasn't set correctly.");
resumeAndFinish();
gDebugger.StackFrames.activeThread.resume(function() {
closeDebuggerAndFinish(gTab);
});
}}, 0);
});
gDebuggee.simpleCall();
}
function resumeAndFinish() {
gDebugger.StackFrames.activeThread.resume(function() {
removeTab(gTab);
finish();
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -10,14 +10,12 @@ const TAB_URL = EXAMPLE_URL + "browser_dbg_frame-parameters.html";
var gPane = null;
var gTab = null;
var gDebuggee = null;
var gDebugger = null;
function test()
{
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
gTab = aTab;
gDebuggee = aDebuggee;
gPane = aPane;
gDebugger = gPane.debuggerWindow;
@ -87,10 +85,16 @@ function resumeAndFinish() {
is(frames.querySelectorAll(".dbg-stackframe").length, 0,
"Should have no frames.");
removeTab(gTab);
finish();
closeDebuggerAndFinish(gTab);
}}, 0);
});
gDebugger.StackFrames.activeThread.resume();
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebugger = null;
});

View File

@ -10,14 +10,12 @@ const TAB_URL = EXAMPLE_URL + "browser_dbg_frame-parameters.html";
var gPane = null;
var gTab = null;
var gDebuggee = null;
var gDebugger = null;
function test()
{
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
gTab = aTab;
gDebuggee = aDebuggee;
gPane = aPane;
gDebugger = gPane.debuggerWindow;
@ -103,10 +101,16 @@ function resumeAndFinish() {
is(frames.querySelectorAll(".dbg-stackframe").length, 0,
"Should have no frames.");
removeTab(gTab);
finish();
closeDebuggerAndFinish(gTab);
}}, 0);
});
gDebugger.StackFrames.activeThread.resume();
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebugger = null;
});

View File

@ -103,6 +103,13 @@ function testSwitchRunning()
ok(gDebugger.editor.getText().search(/firstCall/) == -1,
"The first script is no longer displayed.");
removeTab(gTab);
finish();
closeDebuggerAndFinish(gTab);
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -68,8 +68,7 @@ function testSelectLine() {
"The correct line is selected.");
gDebugger.StackFrames.activeThread.resume(function() {
removeTab(gTab);
finish();
closeDebuggerAndFinish(gTab);
});
});
});
@ -83,3 +82,11 @@ function testSelectLine() {
gDebuggee.firstCall();
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -36,16 +36,19 @@ function testSimpleCall() {
is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length,
"All children should be frames.");
resumeAndFinish();
gDebugger.StackFrames.activeThread.resume(function() {
closeDebuggerAndFinish(gTab);
});
}}, 0);
});
gDebuggee.simpleCall();
}
function resumeAndFinish() {
gDebugger.StackFrames.activeThread.resume(function() {
removeTab(gTab);
finish();
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -67,17 +67,19 @@ function testEvalCall() {
ok(!frames.querySelector("#stackframe-1").classList.contains("selected"),
"Second frame should not be selected after click inside the first frame.");
resumeAndFinish();
gDebugger.StackFrames.activeThread.resume(function() {
closeDebuggerAndFinish(gTab);
});
}}, 0);
});
gDebuggee.evalCall();
}
function resumeAndFinish() {
gDebugger.StackFrames.activeThread.resume(function() {
removeTab(gTab);
finish();
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -47,7 +47,9 @@ function testRecurse() {
is(frames.querySelectorAll(".dbg-stackframe").length, recurseLimit,
"Should have reached the recurse limit.");
resumeAndFinish();
gDebugger.StackFrames.activeThread.resume(function() {
closeDebuggerAndFinish(gTab);
});
});
frames.scrollTop = frames.scrollHeight;
@ -60,9 +62,10 @@ function testRecurse() {
gDebuggee.recurse();
}
function resumeAndFinish() {
gDebugger.StackFrames.activeThread.resume(function() {
removeTab(gTab);
finish();
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -48,8 +48,7 @@ function testEvalCallResume() {
is(frames.querySelectorAll(".empty").length, 1,
"Should have the empty list explanation.");
removeTab(gTab);
finish();
closeDebuggerAndFinish(gTab);
});
gPane.activeThread.resume();
@ -58,3 +57,11 @@ function testEvalCallResume() {
gDebuggee.evalCall();
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -72,7 +72,15 @@ function testSwitchPaused()
"Found the expected editor mode.");
gDebugger.StackFrames.activeThread.resume(function() {
removeTab(gTab);
finish();
closeDebuggerAndFinish(gTab);
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
gScripts = null;
});

View File

@ -49,6 +49,14 @@ function removeTab(aTab) {
gBrowser.removeTab(aTab);
}
function closeDebuggerAndFinish(aTab) {
DebuggerUI.aWindow.addEventListener("Debugger:Shutdown", function cleanup() {
DebuggerUI.aWindow.removeEventListener("Debugger:Shutdown", cleanup, false);
finish();
}, false);
DebuggerUI.getDebugger(aTab).close();
}
function get_tab_actor_for_url(aClient, aURL, aCallback) {
aClient.listTabs(function(aResponse) {
for each (let tab in aResponse.tabs) {

View File

@ -97,6 +97,10 @@ BrowserRootActor.prototype = {
while (e.hasMoreElements()) {
let win = e.getNext();
this.unwatchWindow(win);
// Signal our imminent shutdown.
let evt = win.document.createEvent("Event");
evt.initEvent("Debugger:Shutdown", true, false);
win.document.documentElement.dispatchEvent(evt);
}
},
@ -415,6 +419,10 @@ BrowserTabActor.prototype = {
* Prepare to enter a nested event loop by disabling debuggee events.
*/
preNest: function BTA_preNest() {
if (!this.browser) {
// The tab is already closed.
return;
}
let windowUtils = this.browser.contentWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
@ -426,6 +434,10 @@ BrowserTabActor.prototype = {
* Prepare to exit a nested event loop by enabling debuggee events.
*/
postNest: function BTA_postNest(aNestData) {
if (!this.browser) {
// The tab is already closed.
return;
}
let windowUtils = this.browser.contentWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);