gecko/browser/devtools/debugger/test/browser_dbg_listtabs-01.js
Victor Porof 9731aa38d8 Bug 876277 - Cleanup remaining debugger tests, r=past
--HG--
rename : browser/devtools/debugger/test/browser_dbg_createChrome.js => browser/devtools/debugger/test/browser_dbg_chrome-create.js
rename : browser/devtools/debugger/test/browser_dbg_cmd_blackbox.js => browser/devtools/debugger/test/browser_dbg_cmd-blackbox.js
rename : browser/devtools/debugger/test/browser_dbg_cmd_break.js => browser/devtools/debugger/test/browser_dbg_cmd-break.js
rename : browser/devtools/debugger/test/browser_dbg_cmd.js => browser/devtools/debugger/test/browser_dbg_cmd-dbg.js
rename : browser/devtools/debugger/test/browser_dbg_debuggerstatement.js => browser/devtools/debugger/test/browser_dbg_debugger-statement.js
rename : browser/devtools/debugger/test/browser_dbg_bug731394_editor-contextmenu.js => browser/devtools/debugger/test/browser_dbg_editor-contextmenu.js
rename : browser/devtools/debugger/test/browser_dbg_displayName.js => browser/devtools/debugger/test/browser_dbg_function-display-name.js
rename : browser/devtools/debugger/test/browser_dbg_globalactor-01.js => browser/devtools/debugger/test/browser_dbg_globalactor.js
rename : browser/devtools/debugger/test/browser_dbg_pane-collapse.js => browser/devtools/debugger/test/browser_dbg_instruments-pane-collapse.js
rename : browser/devtools/debugger/test/browser_dbg_nav-01.js => browser/devtools/debugger/test/browser_dbg_navigation.js
rename : browser/devtools/debugger/test/browser_dbg_bug868163_highight_on_pause.js => browser/devtools/debugger/test/browser_dbg_on-pause-highlight.js
rename : browser/devtools/debugger/test/browser_dbg_bug883220_raise_on_pause.js => browser/devtools/debugger/test/browser_dbg_on-pause-raise.js
rename : browser/devtools/debugger/test/browser_dbg_panesize-inner.js => browser/devtools/debugger/test/browser_dbg_panel-size.js
rename : browser/devtools/debugger/test/browser_dbg_pause-exceptions.js => browser/devtools/debugger/test/browser_dbg_pause-exceptions-01.js
rename : browser/devtools/debugger/test/browser_dbg_pause-exceptions-reload.js => browser/devtools/debugger/test/browser_dbg_pause-exceptions-02.js
rename : browser/devtools/debugger/test/browser_dbg_reload-preferred-script.js => browser/devtools/debugger/test/browser_dbg_reload-preferred-script-01.js
rename : browser/devtools/debugger/test/browser_dbg_bug727429_watch-expressions-01.js => browser/devtools/debugger/test/browser_dbg_watch-expressions-01.js
rename : browser/devtools/debugger/test/browser_dbg_bug727429_watch-expressions-02.js => browser/devtools/debugger/test/browser_dbg_watch-expressions-02.js
2013-09-13 16:23:19 +03:00

102 lines
2.6 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Make sure the listTabs request works as specified.
*/
const TAB1_URL = EXAMPLE_URL + "doc_empty-tab-01.html";
const TAB2_URL = EXAMPLE_URL + "doc_empty-tab-02.html";
let gTab1, gTab1Actor, gTab2, gTab2Actor, gClient;
function test() {
if (!DebuggerServer.initialized) {
DebuggerServer.init(() => true);
DebuggerServer.addBrowserActors();
}
let transport = DebuggerServer.connectPipe();
gClient = new DebuggerClient(transport);
gClient.connect((aType, aTraits) => {
is(aType, "browser",
"Root actor should identify itself as a browser.");
promise.resolve(null)
.then(testFirstTab)
.then(testSecondTab)
.then(testRemoveTab)
.then(testAttachRemovedTab)
.then(closeConnection)
.then(finish)
.then(null, aError => {
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
});
});
}
function testFirstTab() {
return addTab(TAB1_URL).then(aTab => {
gTab1 = aTab;
return getTabActorForUrl(gClient, TAB1_URL).then(aGrip => {
ok(aGrip, "Should find a tab actor for the first tab.");
gTab1Actor = aGrip.actor;
});
});
}
function testSecondTab() {
return addTab(TAB2_URL).then(aTab => {
gTab2 = aTab;
return getTabActorForUrl(gClient, TAB1_URL).then(aFirstGrip => {
return getTabActorForUrl(gClient, TAB2_URL).then(aSecondGrip => {
is(aFirstGrip.actor, gTab1Actor, "First tab's actor shouldn't have changed.");
ok(aSecondGrip, "Should find a tab actor for the second tab.");
gTab2Actor = aSecondGrip.actor;
});
});
});
}
function testRemoveTab() {
return removeTab(gTab1).then(() => {
return getTabActorForUrl(gClient, TAB1_URL).then(aGrip => {
ok(!aGrip, "Shouldn't find a tab actor for the first tab anymore.");
});
});
}
function testAttachRemovedTab() {
return removeTab(gTab2).then(() => {
let deferred = promise.defer();
gClient.addListener("paused", (aEvent, aPacket) => {
ok(false, "Attaching to an exited tab actor shouldn't generate a pause.");
deferred.reject();
});
gClient.request({ to: gTab2Actor, type: "attach" }, aResponse => {
is(aResponse.type, "exited", "Tab should consider itself exited.");
deferred.resolve();
});
return deferred.promise;
});
}
function closeConnection() {
let deferred = promise.defer();
gClient.close(deferred.resolve);
return deferred.promise;
}
registerCleanupFunction(function() {
gTab1 = null;
gTab1Actor = null;
gTab2 = null;
gTab2Actor = null;
gClient = null;
});