summaryrefslogtreecommitdiffstats
path: root/devtools/client/webide/test/browser_tabs.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/webide/test/browser_tabs.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/webide/test/browser_tabs.js')
-rw-r--r--devtools/client/webide/test/browser_tabs.js84
1 files changed, 84 insertions, 0 deletions
diff --git a/devtools/client/webide/test/browser_tabs.js b/devtools/client/webide/test/browser_tabs.js
new file mode 100644
index 000000000..541c6b363
--- /dev/null
+++ b/devtools/client/webide/test/browser_tabs.js
@@ -0,0 +1,84 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+const TEST_URI = "http://example.com/browser/devtools/client/webide/test/doc_tabs.html";
+
+function test() {
+ waitForExplicitFinish();
+ requestCompleteLog();
+
+ Task.spawn(function* () {
+ // Since we test the connections set below, destroy the server in case it
+ // was left open.
+ DebuggerServer.destroy();
+ DebuggerServer.init();
+ DebuggerServer.addBrowserActors();
+
+ let tab = yield addTab(TEST_URI);
+
+ let win = yield openWebIDE();
+ let docProject = getProjectDocument(win);
+ let docRuntime = getRuntimeDocument(win);
+
+ yield connectToLocal(win, docRuntime);
+
+ is(Object.keys(DebuggerServer._connections).length, 1, "Locally connected");
+
+ yield selectTabProject(win, docProject);
+
+ ok(win.UI.toolboxPromise, "Toolbox promise exists");
+ yield win.UI.toolboxPromise;
+
+ let project = win.AppManager.selectedProject;
+ is(project.location, TEST_URI, "Location is correct");
+ is(project.name, "example.com: Test Tab", "Name is correct");
+
+ // Ensure tab list changes are noticed
+ let tabsNode = docProject.querySelector("#project-panel-tabs");
+ is(tabsNode.querySelectorAll(".panel-item").length, 2, "2 tabs available");
+ yield removeTab(tab);
+ yield waitForUpdate(win, "project");
+ yield waitForUpdate(win, "runtime-targets");
+ is(tabsNode.querySelectorAll(".panel-item").length, 1, "1 tab available");
+
+ tab = yield addTab(TEST_URI);
+
+ is(tabsNode.querySelectorAll(".panel-item").length, 2, "2 tabs available");
+
+ yield removeTab(tab);
+
+ is(tabsNode.querySelectorAll(".panel-item").length, 2, "2 tabs available");
+
+ docProject.querySelector("#refresh-tabs").click();
+
+ yield waitForUpdate(win, "runtime-targets");
+
+ is(tabsNode.querySelectorAll(".panel-item").length, 1, "1 tab available");
+
+ yield win.Cmds.disconnectRuntime();
+ yield closeWebIDE(win);
+
+ DebuggerServer.destroy();
+ }).then(finish, handleError);
+}
+
+function connectToLocal(win, docRuntime) {
+ let deferred = promise.defer();
+ win.AppManager.connection.once(
+ win.Connection.Events.CONNECTED,
+ () => deferred.resolve());
+ docRuntime.querySelectorAll(".runtime-panel-item-other")[1].click();
+ return deferred.promise;
+}
+
+function selectTabProject(win, docProject) {
+ return Task.spawn(function* () {
+ yield waitForUpdate(win, "runtime-targets");
+ let tabsNode = docProject.querySelector("#project-panel-tabs");
+ let tabNode = tabsNode.querySelectorAll(".panel-item")[1];
+ let project = waitForUpdate(win, "project");
+ tabNode.click();
+ yield project;
+ });
+}