Bug 1149820 - Restore WebIDE project auto select. r=ochameau, a=lizzard
authorJ. Ryan Stinnett <jryans@gmail.com>
Thu, 02 Apr 2015 11:35:24 -0500
changeset 266879 c846da7a03a606375ad80deb983f0a4284bd994e
parent 266878 8cef59e11f864087e003e737c6a5f74b8fa067bc
child 266880 c7e51145a7ab8f5e0a467c9e9f0062ea47ca021a
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau, lizzard
bugs1149820
milestone39.0a2
Bug 1149820 - Restore WebIDE project auto select. r=ochameau, a=lizzard
browser/devtools/webide/content/webide.js
browser/devtools/webide/test/chrome.ini
browser/devtools/webide/test/head.js
browser/devtools/webide/test/test_autoselect_project.html
--- a/browser/devtools/webide/content/webide.js
+++ b/browser/devtools/webide/content/webide.js
@@ -199,26 +199,25 @@ let UI = {
         break;
       case "project-validated":
         this.updateTitle();
         this.updateCommands();
         this.updateProjectButton();
         this.updateProjectEditorHeader();
         projectList.update();
         break;
-      case "runtime-targets":
       case "project-removed":
-        projectList.update(details);
+        projectList.update();
         break;
       case "install-progress":
         this.updateProgress(Math.round(100 * details.bytesSent / details.totalBytes));
         break;
       case "runtime-targets":
         this.autoSelectProject();
-        projectList.update();
+        projectList.update(details);
         break;
       case "pre-package":
         this.prePackageLog(details);
         break;
     };
     this._updatePromise = promise.resolve();
   },
 
--- a/browser/devtools/webide/test/chrome.ini
+++ b/browser/devtools/webide/test/chrome.ini
@@ -43,14 +43,15 @@ support-files =
 [test_import.html]
 [test_duplicate_import.html]
 [test_runtime.html]
 [test_manifestUpdate.html]
 [test_addons.html]
 [test_device_runtime.html]
 [test_device_permissions.html]
 [test_autoconnect_runtime.html]
+[test_autoselect_project.html]
 [test_telemetry.html]
 [test_device_preferences.html]
 [test_device_settings.html]
 [test_fullscreenToolbox.html]
 [test_zoom.html]
 [test_build.html]
--- a/browser/devtools/webide/test/head.js
+++ b/browser/devtools/webide/test/head.js
@@ -33,16 +33,18 @@ Services.prefs.setCharPref("devtools.web
 
 SimpleTest.registerCleanupFunction(() => {
   Services.prefs.clearUserPref("devtools.webide.enabled");
   Services.prefs.clearUserPref("devtools.webide.enableLocalRuntime");
   Services.prefs.clearUserPref("devtools.webide.autoinstallADBHelper");
   Services.prefs.clearUserPref("devtools.webide.autoinstallFxdtAdapters");
   Services.prefs.clearUserPref("devtools.webide.sidebars");
   Services.prefs.clearUserPref("devtools.webide.busyTimeout");
+  Services.prefs.clearUserPref("devtools.webide.lastSelectedProject");
+  Services.prefs.clearUserPref("devtools.webide.lastConnectedRuntime");
 });
 
 function openWebIDE(autoInstallAddons) {
   info("opening WebIDE");
 
   Services.prefs.setBoolPref("devtools.webide.autoinstallADBHelper", !!autoInstallAddons);
   Services.prefs.setBoolPref("devtools.webide.autoinstallFxdtAdapters", !!autoInstallAddons);
 
new file mode 100644
--- /dev/null
+++ b/browser/devtools/webide/test/test_autoselect_project.html
@@ -0,0 +1,87 @@
+<!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* () {
+
+          Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
+          DebuggerServer.init();
+          DebuggerServer.addBrowserActors();
+
+          let win = yield openWebIDE();
+
+          let panelNode = win.document.querySelector("#runtime-panel");
+          let 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");
+
+          is(Object.keys(DebuggerServer._connections).length, 1, "Locally connected");
+
+          ok(win.AppManager.isMainProcessDebuggable(), "Main process available");
+
+          // Select main process
+          yield win.Cmds.showProjectPanel();
+          yield waitForUpdate(win, "runtime-targets");
+          SimpleTest.executeSoon(() => {
+            win.document.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");
+
+          yield nextTick();
+          yield closeWebIDE(win);
+
+          is(Object.keys(DebuggerServer._connections).length, 0, "Disconnected");
+
+          // Re-open, should reselect main process after connection
+          win = yield openWebIDE();
+
+          panelNode = win.document.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");
+
+          is(Object.keys(DebuggerServer._connections).length, 1, "Locally connected");
+          ok(win.AppManager.isMainProcessDebuggable(), "Main process available");
+          is(win.AppManager.selectedProject.type, "mainProcess", "Main process reselected");
+
+          yield win.Cmds.disconnectRuntime();
+
+          yield closeWebIDE(win);
+
+          DebuggerServer.destroy();
+
+          SimpleTest.finish();
+        });
+      }
+
+    </script>
+  </body>
+</html>