mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
9731aa38d8
--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
211 lines
6.1 KiB
JavaScript
211 lines
6.1 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
/**
|
|
* Make sure the root actor's live tab list implementation works as specified.
|
|
*/
|
|
|
|
let gTestPage = "data:text/html;charset=utf-8," + encodeURIComponent(
|
|
"<title>JS Debugger BrowserTabList test page</title><body>Yo.</body>");
|
|
|
|
// The tablist object whose behavior we observe.
|
|
let gTabList;
|
|
let gFirstActor, gActorA;
|
|
let gTabA, gTabB, gTabC;
|
|
let gNewWindow;
|
|
|
|
// Stock onListChanged handler.
|
|
let onListChangedCount = 0;
|
|
function onListChangedHandler() {
|
|
onListChangedCount++;
|
|
}
|
|
|
|
function test() {
|
|
if (!DebuggerServer.initialized) {
|
|
DebuggerServer.init(() => true);
|
|
DebuggerServer.addBrowserActors();
|
|
}
|
|
|
|
gTabList = new DebuggerServer.BrowserTabList("fake DebuggerServerConnection");
|
|
gTabList._testing = true;
|
|
gTabList.onListChanged = onListChangedHandler;
|
|
|
|
checkSingleTab()
|
|
.then(addTabA)
|
|
.then(testTabA)
|
|
.then(addTabB)
|
|
.then(testTabB)
|
|
.then(removeTabA)
|
|
.then(testTabClosed)
|
|
.then(addTabC)
|
|
.then(testTabC)
|
|
.then(removeTabC)
|
|
.then(testNewWindow)
|
|
.then(removeNewWindow)
|
|
.then(testWindowClosed)
|
|
.then(removeTabB)
|
|
.then(checkSingleTab)
|
|
.then(finish);
|
|
}
|
|
|
|
function checkSingleTab() {
|
|
return gTabList.getList().then(aTabActors => {
|
|
is(aTabActors.length, 1, "initial tab list: contains initial tab");
|
|
gFirstActor = aTabActors[0];
|
|
is(gFirstActor.url, "about:blank", "initial tab list: initial tab URL is 'about:blank'");
|
|
is(gFirstActor.title, "New Tab", "initial tab list: initial tab title is 'New Tab'");
|
|
});
|
|
}
|
|
|
|
function addTabA() {
|
|
return addTab(gTestPage).then(aTab => {
|
|
gTabA = aTab;
|
|
});
|
|
}
|
|
|
|
function testTabA() {
|
|
is(onListChangedCount, 1, "onListChanged handler call count");
|
|
|
|
return gTabList.getList().then(aTabActors => {
|
|
let tabActors = new Set(aTabActors);
|
|
is(tabActors.size, 2, "gTabA opened: two tabs in list");
|
|
ok(tabActors.has(gFirstActor), "gTabA opened: initial tab present");
|
|
|
|
info("actors: " + [a.url for (a of tabActors)]);
|
|
gActorA = [a for (a of tabActors) if (a !== gFirstActor)][0];
|
|
ok(gActorA.url.match(/^data:text\/html;/), "gTabA opened: new tab URL");
|
|
is(gActorA.title, "JS Debugger BrowserTabList test page", "gTabA opened: new tab title");
|
|
});
|
|
}
|
|
|
|
function addTabB() {
|
|
return addTab(gTestPage).then(aTab => {
|
|
gTabB = aTab;
|
|
});
|
|
}
|
|
|
|
function testTabB() {
|
|
is(onListChangedCount, 2, "onListChanged handler call count");
|
|
|
|
return gTabList.getList().then(aTabActors => {
|
|
let tabActors = new Set(aTabActors);
|
|
is(tabActors.size, 3, "gTabB opened: three tabs in list");
|
|
});
|
|
}
|
|
|
|
function removeTabA() {
|
|
let deferred = promise.defer();
|
|
|
|
once(gBrowser.tabContainer, "TabClose").then(aEvent => {
|
|
ok(!aEvent.detail, "This was a normal tab close");
|
|
|
|
// Let the actor's TabClose handler finish first.
|
|
executeSoon(deferred.resolve);
|
|
}, false);
|
|
|
|
removeTab(gTabA);
|
|
return deferred.promise;
|
|
}
|
|
|
|
function testTabClosed() {
|
|
is(onListChangedCount, 3, "onListChanged handler call count");
|
|
|
|
gTabList.getList().then(aTabActors => {
|
|
let tabActors = new Set(aTabActors);
|
|
is(tabActors.size, 2, "gTabA closed: two tabs in list");
|
|
ok(tabActors.has(gFirstActor), "gTabA closed: initial tab present");
|
|
|
|
info("actors: " + [a.url for (a of tabActors)]);
|
|
gActorA = [a for (a of tabActors) if (a !== gFirstActor)][0];
|
|
ok(gActorA.url.match(/^data:text\/html;/), "gTabA closed: new tab URL");
|
|
is(gActorA.title, "JS Debugger BrowserTabList test page", "gTabA closed: new tab title");
|
|
});
|
|
}
|
|
|
|
function addTabC() {
|
|
return addTab(gTestPage).then(aTab => {
|
|
gTabC = aTab;
|
|
});
|
|
}
|
|
|
|
function testTabC() {
|
|
is(onListChangedCount, 4, "onListChanged handler call count");
|
|
|
|
gTabList.getList().then(aTabActors => {
|
|
let tabActors = new Set(aTabActors);
|
|
is(tabActors.size, 3, "gTabC opened: three tabs in list");
|
|
});
|
|
}
|
|
|
|
function removeTabC() {
|
|
let deferred = promise.defer();
|
|
|
|
once(gBrowser.tabContainer, "TabClose").then(aEvent => {
|
|
ok(aEvent.detail, "This was a tab closed by moving");
|
|
|
|
// Let the actor's TabClose handler finish first.
|
|
executeSoon(deferred.resolve);
|
|
}, false);
|
|
|
|
gNewWindow = gBrowser.replaceTabWithWindow(gTabC);
|
|
return deferred.promise;
|
|
}
|
|
|
|
function testNewWindow() {
|
|
is(onListChangedCount, 5, "onListChanged handler call count");
|
|
|
|
return gTabList.getList().then(aTabActors => {
|
|
let tabActors = new Set(aTabActors);
|
|
is(tabActors.size, 3, "gTabC closed: three tabs in list");
|
|
ok(tabActors.has(gFirstActor), "gTabC closed: initial tab present");
|
|
|
|
info("actors: " + [a.url for (a of tabActors)]);
|
|
gActorA = [a for (a of tabActors) if (a !== gFirstActor)][0];
|
|
ok(gActorA.url.match(/^data:text\/html;/), "gTabC closed: new tab URL");
|
|
is(gActorA.title, "JS Debugger BrowserTabList test page", "gTabC closed: new tab title");
|
|
});
|
|
}
|
|
|
|
function removeNewWindow() {
|
|
let deferred = promise.defer();
|
|
|
|
once(gNewWindow, "unload").then(aEvent => {
|
|
ok(!aEvent.detail, "This was a normal window close");
|
|
|
|
// Let the actor's TabClose handler finish first.
|
|
executeSoon(deferred.resolve);
|
|
}, false);
|
|
|
|
gNewWindow.close();
|
|
return deferred.promise;
|
|
}
|
|
|
|
function testWindowClosed() {
|
|
is(onListChangedCount, 6, "onListChanged handler call count");
|
|
|
|
return gTabList.getList().then(aTabActors => {
|
|
let tabActors = new Set(aTabActors);
|
|
is(tabActors.size, 2, "gNewWindow closed: two tabs in list");
|
|
ok(tabActors.has(gFirstActor), "gNewWindow closed: initial tab present");
|
|
|
|
info("actors: " + [a.url for (a of tabActors)]);
|
|
gActorA = [a for (a of tabActors) if (a !== gFirstActor)][0];
|
|
ok(gActorA.url.match(/^data:text\/html;/), "gNewWindow closed: new tab URL");
|
|
is(gActorA.title, "JS Debugger BrowserTabList test page", "gNewWindow closed: new tab title");
|
|
});
|
|
}
|
|
|
|
function removeTabB() {
|
|
let deferred = promise.defer();
|
|
|
|
once(gBrowser.tabContainer, "TabClose").then(aEvent => {
|
|
ok(!aEvent.detail, "This was a normal tab close");
|
|
|
|
// Let the actor's TabClose handler finish first.
|
|
executeSoon(deferred.resolve);
|
|
}, false);
|
|
|
|
removeTab(gTabB);
|
|
return deferred.promise;
|
|
}
|