Bug 1020739 - kill WebIDE command line support. r=jryans
authorPaul Rouget <paul@mozilla.com>
Tue, 15 Jul 2014 21:03:24 +0200
changeset 216231 4b108e20d5d0b6b69806014f37fe282f8c67958a
parent 216230 76df92e390b52c996d4aa98d743109e6ca2ccf19
child 216232 48c77bd996de0c92ea2b9442daf9be89d31ea0e8
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1020739
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1020739 - kill WebIDE command line support. r=jryans
browser/devtools/webide/components/webideCli.js
browser/devtools/webide/content/cli.js
browser/devtools/webide/content/jar.mn
browser/devtools/webide/content/webide.xul
browser/devtools/webide/test/chrome.ini
browser/devtools/webide/test/test_cli.html
--- a/browser/devtools/webide/components/webideCli.js
+++ b/browser/devtools/webide/components/webideCli.js
@@ -6,66 +6,44 @@ const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
 
 /**
  * Handles -webide command line option.
- *
- * See webide/content/cli.js for a complete description of the command line.
  */
 
 function webideCli() { }
 
 webideCli.prototype = {
   handle: function(cmdLine) {
     let param;
 
-    try {
-      // Returns null if -webide is not present
-      // Throws if -webide is present with no params
-      param = cmdLine.handleFlagWithParam("webide", false);
-      if (!param) {
-        return;
-      }
-    } catch(e) {
-      // -webide is present with no params
-      cmdLine.handleFlag("webide", false);
+    if (!cmdLine.handleFlag("webide", false)) {
+      return;
     }
 
     // If -webide is used remotely, we don't want to open
     // a new tab.
     //
     // If -webide is used for a new Firefox instance, we
     // want to open webide only.
     cmdLine.preventDefault = true;
 
     let win = Services.wm.getMostRecentWindow("devtools:webide");
     if (win) {
       win.focus();
-      if (param) {
-        win.handleCommandline(param);
-      }
-      return;
-    }
-
-    win = Services.ww.openWindow(null,
-                                 "chrome://webide/content/",
-                                 "webide",
-                                 "chrome,centerscreen,resizable,dialog=no",
-                                 null);
-
-    if (param) {
-      win.addEventListener("load", function onLoad() {
-        win.removeEventListener("load", onLoad, true);
-        // next tick
-        win.setTimeout(() => win.handleCommandline(param), 0);
-      }, true);
+    } else {
+      win = Services.ww.openWindow(null,
+                                   "chrome://webide/content/",
+                                   "webide",
+                                   "chrome,centerscreen,resizable,dialog=no",
+                                   null);
     }
 
     if (cmdLine.state == Ci.nsICommandLine.STATE_INITIAL_LAUNCH) {
       // If this is a new Firefox instance, and because we will only start
       // webide, we need to notify "sessionstore-windows-restored" to trigger
       // addons registration (for simulators and adb helper).
       Services.obs.notifyObservers(null, "sessionstore-windows-restored", "");
     }
deleted file mode 100644
--- a/browser/devtools/webide/content/cli.js
+++ /dev/null
@@ -1,198 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- *
- *  SYNOPSIS
- *    firefox --webide [OPTIONS]
- *
- *  DESCRIPTION
- *    Starts WebIDE (aka App Manager). If Firefox has already started, opens
- *    the WebIDE window. If Firefox is not running, no browser window will
- *    be open.
- *
- *    It's recommended to add the option `-jsconsole` to see potential errors
- *    occurring while processing the parameters.
- *
- *  OPTIONS
- *    A set of "key=value" pairs, separated by '&'.
- *
- *    actions=action1,action2,...,actionN
- *      Executed in order. actionN will be executed only if actionN-1 doesn't fail.
- *      Available actions:
- *        addPackagedApp:      Import and select app ('location' parameter must be a directory)
- *        addHostedApp:        Import and select app ('location' parameter must be a URL)
- *        connectToRuntime:    Connect to runtime (require 'runtimeType')
- *        play:                Start or reload selected app on connected runtime
- *        debug:               Debug selected app or debug 'appID'
- *
- *    location
- *      packaged app directory or hosted app manifest URL
- *
- *    runtimeType
- *      Type of runtime to connect to. "usb" or "simulator"
- *
- *    runtimeID
- *      Which runtime to use. By default, the most recent USB device or most recent simulator
- *
- *    appID
- *      App on runtime
- *
- *  EXAMPLES
- *
- *    $ firefox --webide "actions=addPackagedApp,connectToRuntime,play,debug&location=/home/bob/Downloads/foobar/&runtimeType=usb"
- *        Select app located in /home/bob/Downloads/foobar, then
- *        Connect to USB device, then
- *        Install app, then
- *        Start developer tools connected to the running app
- *
- */
-
-window.handleCommandline = function(cmdline) {
-  console.log("External query", cmdline);
-  let params = new Map();
-  for (let token of cmdline.split("&")) {
-    token = token.split("=");
-    params.set(token[0], token[1]);
-  }
-  if (params.has("actions")) {
-    return UI.busyUntil(Task.spawn(function* () {
-      let actions = params.get("actions").split(",");
-      for (let action of actions) {
-        if (action in CliActions) {
-          console.log("External query - running action", action);
-          yield CliActions[action].call(window, params);
-        } else {
-          console.log("External query - unknown action", action);
-        }
-      }
-    }), "Computing command line");
-  } else {
-    return promise.reject("No actions provided");
-  }
-}
-
-let CliActions = {
-  addPackagedApp: function(params) {
-    return Task.spawn(function* () {
-      let location = params.get("location");
-      if (!location) {
-        throw new Error("No location parameter");
-      }
-
-      yield AppProjects.load();
-
-      // Normalize location
-      let directory = new FileUtils.File(location);
-      if (AppProjects.get(directory.path)) {
-        // Already imported
-        return;
-      }
-
-      yield Cmds.importPackagedApp(location);
-    })
-  },
-  addHostedApp: function(params) {
-    return Task.spawn(function* () {
-      let location = params.get("location");
-      if (!location) {
-        throw new Error("No location parameter");
-      }
-      yield AppProjects.load();
-      if (AppProjects.get(location)) {
-        // Already imported
-        return;
-      }
-      yield Cmds.importHostedApp(location);
-    })
-  },
-  debug: function(params) {
-    return Task.spawn(function* () {
-
-      let appID = params.get("appID");
-
-      if (appID) {
-        let appToSelect;
-        for (let i = 0; i < AppManager.webAppsStore.object.all.length; i++) {
-          let app = AppManager.webAppsStore.object.all[i];
-          if (app.manifestURL == appID) {
-            appToSelect = app;
-            break;
-          }
-        }
-        if (!appToSelect) {
-          throw new Error("App not found on device");
-        }
-        AppManager.selectedProject = {
-          type: "runtimeApp",
-          app: appToSelect,
-          icon: appToSelect.iconURL,
-          name: appToSelect.name
-        };
-      }
-
-      UI.closeToolbox();
-
-      yield Cmds.toggleToolbox();
-    });
-  },
-  connectToRuntime: function(params) {
-    return Task.spawn(function* () {
-
-      let type = params.get("runtimeType");
-      if (type != "usb" && type != "simulator") {
-        return promise.reject("Unkown runtime type");
-      }
-
-      yield Cmds.disconnectRuntime();
-
-      if (AppManager.runtimeList[type].length == 0) {
-        let deferred = promise.defer();
-        function onRuntimeListUpdate(event, what) {
-          if (AppManager.runtimeList[type].length > 0) {
-            deferred.resolve();
-          }
-        }
-
-        let timeout = setTimeout(deferred.resolve, 3000);
-        AppManager.on("app-manager-update", onRuntimeListUpdate);
-        yield deferred.promise;
-
-        AppManager.off("app-manager-update", onRuntimeListUpdate);
-        clearTimeout(timeout);
-      }
-
-      let runtime;
-      let runtimeID = params.get("runtimeID");
-
-      if (runtimeID) {
-        for (let r of AppManager.runtimeList[type]) {
-          if (r.getID() == runtimeID) {
-            runtime = r;
-            break;
-          }
-        }
-      } else {
-        let list = AppManager.runtimeList[type];
-        runtime = list[list.length - 1];
-      }
-
-      if (!runtime) {
-        return promise.reject("Can't find any runtime to connect to");
-      }
-
-      let deferred = promise.defer();
-      // store-ready is fired when the list of installed apps has been
-      // received by the webAppsStore.
-      AppManager.webAppsStore.once("store-ready", deferred.resolve);
-      UI.connectToRuntime(runtime).then(null, deferred.reject);
-      return deferred.promise;
-    })
-  },
-  play: function(params) {
-    return Task.spawn(function* () {
-      yield Cmds.play();
-    })
-  },
-}
--- a/browser/devtools/webide/content/jar.mn
+++ b/browser/devtools/webide/content/jar.mn
@@ -5,17 +5,16 @@
 webide.jar:
 %   content webide %content/
     content/webide.xul                (webide.xul)
     content/webide.js                 (webide.js)
     content/newapp.xul                (newapp.xul)
     content/newapp.js                 (newapp.js)
     content/details.xhtml             (details.xhtml)
     content/details.js                (details.js)
-    content/cli.js                    (cli.js)
     content/addons.js                 (addons.js)
     content/addons.xhtml              (addons.xhtml)
     content/permissionstable.js       (permissionstable.js)
     content/permissionstable.xhtml    (permissionstable.xhtml)
     content/runtimedetails.js         (runtimedetails.js)
     content/runtimedetails.xhtml      (runtimedetails.xhtml)
     content/prefs.js                  (prefs.js)
     content/prefs.xhtml               (prefs.xhtml)
--- a/browser/devtools/webide/content/webide.xul
+++ b/browser/devtools/webide/content/webide.xul
@@ -22,17 +22,16 @@
         macanimationtype="document"
         fullscreenbutton="true"
         screenX="4" screenY="4"
         width="640" height="480"
         persist="screenX screenY width height">
 
   <script type="application/javascript" src="chrome://global/content/globalOverlay.js"></script>
   <script type="application/javascript" src="webide.js"></script>
-  <script type="application/javascript" src="cli.js"></script>
 
   <commandset id="mainCommandSet">
     <commandset id="editMenuCommands"/>
     <commandset id="webideCommands">
       <command id="cmd_quit" oncommand="Cmds.quit()"/>
       <command id="cmd_newApp" oncommand="Cmds.newApp()" label="&projectMenu_newApp_label;"/>
       <command id="cmd_importPackagedApp" oncommand="Cmds.importPackagedApp()" label="&projectMenu_importPackagedApp_label;"/>
       <command id="cmd_importHostedApp" oncommand="Cmds.importHostedApp()" label="&projectMenu_importHostedApp_label;"/>
--- a/browser/devtools/webide/test/chrome.ini
+++ b/browser/devtools/webide/test/chrome.ini
@@ -23,12 +23,11 @@ support-files =
   head.js
   hosted_app.manifest
   templates.json
 
 [test_basic.html]
 [test_newapp.html]
 [test_import.html]
 [test_runtime.html]
-[test_cli.html]
 [test_manifestUpdate.html]
 [test_addons.html]
 [test_deviceinfo.html]
deleted file mode 100644
--- a/browser/devtools/webide/test/test_cli.html
+++ /dev/null
@@ -1,64 +0,0 @@
-<!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(function () { return true; });
-          DebuggerServer.addBrowserActors();
-
-          let win = yield openWebIDE();
-
-          let packagedAppLocation = getTestFilePath("app");
-
-          let cli = "actions=addPackagedApp&location=" + packagedAppLocation;
-          yield win.handleCommandline(cli);
-
-          let project = win.AppManager.selectedProject;
-          is(project.location, packagedAppLocation, "Project imported");
-
-          win.AppManager.runtimeList.usb.push({
-            connect: function(connection) {
-              ok(connection, win.AppManager.connection, "connection is valid");
-              connection.host = null; // force connectPipe
-              connection.connect();
-              return promise.resolve();
-            },
-            getName: function() {
-              return "fakeRuntime";
-            }
-          });
-
-          yield win.handleCommandline("actions=connectToRuntime&runtimeType=usb");
-
-          is(win.AppManager.connection.status, "connected", "connected");
-          is(win.AppManager.selectedProject.name, "A name (in app directory)", "project imported");
-
-          yield removeAllProjects();
-          yield closeWebIDE(win);
-          DebuggerServer.destroy();
-          SimpleTest.finish();
-
-        });
-      }
-
-
-    </script>
-  </body>
-</html>