summaryrefslogtreecommitdiffstats
path: root/devtools/client/webide/test/test_autoselect_project.html
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/webide/test/test_autoselect_project.html')
-rw-r--r--devtools/client/webide/test/test_autoselect_project.html110
1 files changed, 110 insertions, 0 deletions
diff --git a/devtools/client/webide/test/test_autoselect_project.html b/devtools/client/webide/test/test_autoselect_project.html
new file mode 100644
index 000000000..cd5793559
--- /dev/null
+++ b/devtools/client/webide/test/test_autoselect_project.html
@@ -0,0 +1,110 @@
+<!DOCTYPE html>
+
+<html>
+
+ <head>
+ <meta charset="utf8">
+ <title></title>
+
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
+ <script type="application/javascript;version=1.8" src="head.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
+ </head>
+
+ <body>
+
+ <script type="application/javascript;version=1.8">
+ window.onload = function() {
+ SimpleTest.waitForExplicitFinish();
+
+ Task.spawn(function* () {
+ if (!DebuggerServer.initialized) {
+ DebuggerServer.init();
+ DebuggerServer.addBrowserActors();
+ }
+
+ let win = yield openWebIDE();
+ let docRuntime = getRuntimeDocument(win);
+ let docProject = getProjectDocument(win);
+
+ let panelNode = docRuntime.querySelector("#runtime-panel");
+ let items = panelNode.querySelectorAll(".runtime-panel-item-other");
+ is(items.length, 2, "Found 2 runtime buttons");
+
+ // Connect to local runtime
+ let connectionsChanged = waitForConnectionChange("opened", 2);
+ items[1].click();
+
+ yield waitForUpdate(win, "runtime-targets");
+
+ yield connectionsChanged;
+ is(Object.keys(DebuggerServer._connections).length, 2, "Locally connected");
+
+ ok(win.AppManager.isMainProcessDebuggable(), "Main process available");
+
+ // Select main process
+ yield win.Cmds.showProjectPanel();
+ yield waitForUpdate(win, "runtime-targets");
+ SimpleTest.executeSoon(() => {
+ docProject.querySelectorAll("#project-panel-runtimeapps .panel-item")[0].click();
+ });
+
+ yield waitForUpdate(win, "project");
+
+ let lastProject = Services.prefs.getCharPref("devtools.webide.lastSelectedProject");
+ is(lastProject, "mainProcess:", "Last project is main process");
+
+ connectionsChanged = waitForConnectionChange("closed", 2);
+
+ yield nextTick();
+ yield closeWebIDE(win);
+
+ yield connectionsChanged;
+ is(Object.keys(DebuggerServer._connections).length, 0, "Disconnected");
+
+ connectionsChanged = waitForConnectionChange("opened", 2);
+
+ // Re-open, should reselect main process after connection
+ win = yield openWebIDE();
+
+ docRuntime = getRuntimeDocument(win);
+
+ panelNode = docRuntime.querySelector("#runtime-panel");
+ items = panelNode.querySelectorAll(".runtime-panel-item-other");
+ is(items.length, 2, "Found 2 runtime buttons");
+
+ // Connect to local runtime
+ items[1].click();
+
+ yield waitForUpdate(win, "runtime-targets");
+
+ yield connectionsChanged;
+ is(Object.keys(DebuggerServer._connections).length, 2, "Locally connected");
+ ok(win.AppManager.isMainProcessDebuggable(), "Main process available");
+ is(win.AppManager.selectedProject.type, "mainProcess", "Main process reselected");
+
+ // Wait for the toolbox to be fully loaded
+ yield win.UI.toolboxPromise;
+
+ // If we happen to pass a project object targeting the same context,
+ // here, the main process, the `selectedProject` attribute shouldn't be updated
+ // so that no `project` event would fire.
+ let oldProject = win.AppManager.selectedProject;
+ win.AppManager.selectedProject = {
+ type: "mainProcess"
+ };
+ is(win.AppManager.selectedProject, oldProject, "AppManager.selectedProject shouldn't be updated if we selected the same project");
+
+ yield win.Cmds.disconnectRuntime();
+
+ yield closeWebIDE(win);
+
+ DebuggerServer.destroy();
+
+ SimpleTest.finish();
+ });
+ }
+ </script>
+ </body>
+</html>