Bug 1203159 - Remove DevTools support from webapprt. r=myk draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Fri, 16 Oct 2015 00:38:42 -0500
changeset 301211 71ab2da009b468eab0b15785cb6067344b01dd73
parent 301185 1c1433d2942714a56e9c0ae1aaef840ac9fbc3c9
child 301212 5389d910c1439b363ec7277992ac2498fb69fa58
push id6428
push userjryans@gmail.com
push dateFri, 16 Oct 2015 05:39:55 +0000
reviewersmyk
bugs1203159
milestone44.0a1
Bug 1203159 - Remove DevTools support from webapprt. r=myk To enable resource://devtools, all DevTools files are consolidated at the app level. This means they are no longer available for sharing between multiple XUL apps, such as browser and webapprt. We'll need to devise a new method to bring this support back to webapprt if desired.
browser/installer/package-manifest.in
webapprt/CommandLineHandler.js
webapprt/RemoteDebugger.jsm
webapprt/content/dbg-webapp-actors.js
webapprt/jar.mn
webapprt/moz.build
webapprt/prefs.js
webapprt/test/chrome/browser_debugger.js
webapprt/test/chrome/webapprt.ini
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -879,17 +879,16 @@ bin/libfreebl_32int64_3.so
 @RESPATH@/webapprt/components/DirectoryProvider.js
 @RESPATH@/webapprt/components/PaymentUIGlue.js
 @RESPATH@/webapprt/components/components.manifest
 @RESPATH@/webapprt/defaults/preferences/prefs.js
 @RESPATH@/webapprt/modules/DownloadView.jsm
 @RESPATH@/webapprt/modules/Startup.jsm
 @RESPATH@/webapprt/modules/WebappRT.jsm
 @RESPATH@/webapprt/modules/WebappManager.jsm
-@RESPATH@/webapprt/modules/RemoteDebugger.jsm
 @RESPATH@/webapprt/modules/WebRTCHandler.jsm
 #endif
 
 @RESPATH@/components/DataStore.manifest
 @RESPATH@/components/DataStoreImpl.js
 @RESPATH@/components/dom_datastore.xpt
 
 @RESPATH@/components/dom_audiochannel.xpt
--- a/webapprt/CommandLineHandler.js
+++ b/webapprt/CommandLineHandler.js
@@ -16,22 +16,16 @@ CommandLineHandler.prototype = {
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
 
   handle: function handle(cmdLine) {
     let args = Cc["@mozilla.org/hash-property-bag;1"].
                createInstance(Ci.nsIWritablePropertyBag);
     let inTestMode = this._handleTestMode(cmdLine, args);
 
-    let debugPort = this._handleDebugMode(cmdLine);
-    if (!isNaN(debugPort)) {
-      Cu.import("resource://webapprt/modules/RemoteDebugger.jsm");
-      RemoteDebugger.init(debugPort);
-    }
-
     if (inTestMode) {
       // Open the mochitest shim window, which configures the runtime for tests.
       Services.ww.openWindow(null,
                              "chrome://webapprt/content/mochitest.xul",
                              "_blank",
                              "chrome,dialog=no",
                              args);
     } else {
@@ -45,44 +39,16 @@ CommandLineHandler.prototype = {
       Cu.import("resource://webapprt/modules/Startup.jsm");
       startup(window).then(null, function (aError) {
         dump("Error: " + aError + "\n");
         Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit);
       });
     }
   },
 
-  /**
-   * Handle debug command line option.
-   *
-   * @param cmdLine A nsICommandLine object.
-   *
-   * @returns the port number if it's specified, the default port number if
-   *          the debug option is specified, NaN if the debug option isn't
-   *          specified or the port number isn't valid.
-   */
-  _handleDebugMode: function(cmdLine) {
-    // -debug [port]
-    let idx = cmdLine.findFlag("debug", true);
-    if (idx < 0) {
-      return NaN;
-    }
-
-    let port;
-    let portIdx = idx + 1;
-    if (portIdx < cmdLine.length) {
-      port = parseInt(cmdLine.getArgument(portIdx));
-      if (port != NaN) {
-        return port;
-      }
-    }
-
-    return Services.prefs.getIntPref('devtools.debugger.remote-port');
-  },
-
   _handleTestMode: function _handleTestMode(cmdLine, args) {
     // -test-mode [url]
     let idx = cmdLine.findFlag("test-mode", true);
     if (idx < 0)
       return false;
     let url;
     let urlIdx = idx + 1;
     if (urlIdx < cmdLine.length) {
deleted file mode 100644
--- a/webapprt/RemoteDebugger.jsm
+++ /dev/null
@@ -1,29 +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/. */
-
-"use strict";
-
-this.EXPORTED_SYMBOLS = ["RemoteDebugger"];
-
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cu = Components.utils;
-
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-var { require } = Cu.import("resource://gre/modules/devtools/shared/Loader.jsm", {});
-var { DebuggerServer } = require("devtools/server/main");
-
-this.RemoteDebugger = {
-  init: function(port) {
-    if (!DebuggerServer.initialized) {
-      DebuggerServer.init();
-      DebuggerServer.addBrowserActors("webapprt:webapp");
-      DebuggerServer.addActors("chrome://webapprt/content/dbg-webapp-actors.js");
-    }
-    let listener = DebuggerServer.createListener();
-    listener.portOrPath = port;
-    listener.open();
-  }
-}
deleted file mode 100644
--- a/webapprt/content/dbg-webapp-actors.js
+++ /dev/null
@@ -1,130 +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/. */
-
-'use strict';
-
-const { Promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
-const { devtools } = Cu.import("resource://gre/modules/devtools/shared/Loader.jsm", {});
-const { BrowserTabActor, BrowserTabList, allAppShellDOMWindows,
-        sendShutdownEvent } = devtools.require("devtools/server/actors/webbrowser");
-const { RootActor } = devtools.require("devtools/server/actors/root");
-
-/**
- * WebappRT-specific actors.
- */
-
-/**
- * Construct a root actor appropriate for use in a server running in the webapp
- * runtime. The returned root actor:
- * - respects the factories registered with DebuggerServer.addGlobalActor,
- * - uses a WebappTabList to supply tab actors,
- * - sends all webapprt:webapp window documents a Debugger:Shutdown event
- *   when it exits.
- *
- * * @param connection DebuggerServerConnection
- *        The conection to the client.
- */
-function createRootActor(connection)
-{
-  let parameters = {
-    tabList: new WebappTabList(connection),
-    globalActorFactories: DebuggerServer.globalActorFactories,
-    onShutdown: sendShutdownEvent
-  };
-  return new RootActor(connection, parameters);
-}
-
-/**
- * A live list of BrowserTabActors representing the current webapp windows,
- * to be provided to the root actor to answer 'listTabs' requests. In the
- * webapp runtime, only a single tab per window is ever present.
- *
- * @param connection DebuggerServerConnection
- *     The connection in which this list's tab actors may participate.
- *
- * @see BrowserTabList for more a extensive description of how tab list objects
- *      work.
- */
-function WebappTabList(connection)
-{
-  BrowserTabList.call(this, connection);
-}
-
-WebappTabList.prototype = Object.create(BrowserTabList.prototype);
-
-WebappTabList.prototype.constructor = WebappTabList;
-
-WebappTabList.prototype.getList = function() {
-  let topXULWindow = Services.wm.getMostRecentWindow(this._windowType);
-
-  // As a sanity check, make sure all the actors presently in our map get
-  // picked up when we iterate over all windows.
-  let initialMapSize = this._actorByBrowser.size;
-  let foundCount = 0;
-
-  // To avoid mysterious behavior if windows are closed or opened mid-iteration,
-  // we update the map first, and then make a second pass over it to yield
-  // the actors. Thus, the sequence yielded is always a snapshot of the
-  // actors that were live when we began the iteration.
-
-  // Iterate over all webapprt:webapp XUL windows.
-  for (let win of allAppShellDOMWindows(this._windowType)) {
-    let browser = win.document.getElementById("content");
-    if (!browser) {
-      continue;
-    }
-
-    // Do we have an existing actor for this browser? If not, create one.
-    let actor = this._actorByBrowser.get(browser);
-    if (actor) {
-      foundCount++;
-    } else {
-      actor = new WebappTabActor(this._connection, browser);
-      this._actorByBrowser.set(browser, actor);
-    }
-
-    actor.selected = (win == topXULWindow);
-  }
-
-  if (this._testing && initialMapSize !== foundCount) {
-    throw Error("_actorByBrowser map contained actors for dead tabs");
-  }
-
-  this._mustNotify = true;
-  this._checkListening();
-
-  return Promise.resolve([actor for ([_, actor] of this._actorByBrowser)]);
-};
-
-/**
- * Creates a tab actor for handling requests to the single tab, like
- * attaching and detaching. WebappTabActor respects the actor factories
- * registered with DebuggerServer.addTabActor.
- *
- * We override the title of the XUL window in content/webapp.js so here
- * we need to override the title property to avoid confusion to the user.
- * We won't return the title of the contained browser, but the title of
- * the webapp window.
- *
- * @param connection DebuggerServerConnection
- *        The conection to the client.
- * @param browser browser
- *        The browser instance that contains this tab.
- */
-function WebappTabActor(connection, browser)
-{
-  BrowserTabActor.call(this, connection, browser);
-}
-
-WebappTabActor.prototype.constructor = WebappTabActor;
-
-WebappTabActor.prototype = Object.create(BrowserTabActor.prototype);
-
-Object.defineProperty(WebappTabActor.prototype, "title", {
-  get: function() {
-    return this.browser.ownerDocument.defaultView.document.title;
-  },
-  enumerable: true,
-  configurable: false
-});
--- a/webapprt/jar.mn
+++ b/webapprt/jar.mn
@@ -6,13 +6,12 @@ webapprt.jar:
 % content webapprt %content/
 * content/webapp.js                     (content/webapp.js)
 * content/webapp.xul                    (content/webapp.xul)
   content/getUserMediaDialog.xul        (content/getUserMediaDialog.xul)
   content/getUserMediaDialog.js         (content/getUserMediaDialog.js)
   content/mochitest-shared.js           (content/mochitest-shared.js)
   content/mochitest.js                  (content/mochitest.js)
   content/mochitest.xul                 (content/mochitest.xul)
-  content/dbg-webapp-actors.js          (content/dbg-webapp-actors.js)
 * content/downloads/downloads.xul       (content/downloads/downloads.xul)
   content/downloads/downloads.js        (content/downloads/downloads.js)
   content/downloads/downloads.css       (content/downloads/downloads.css)
   content/downloads/download.xml        (content/downloads/download.xml)
--- a/webapprt/moz.build
+++ b/webapprt/moz.build
@@ -24,17 +24,16 @@ EXTRA_COMPONENTS += [
     'components.manifest',
     'ContentPermission.js',
     'DirectoryProvider.js',
     'PaymentUIGlue.js',
 ]
 
 EXTRA_JS_MODULES += [
     'DownloadView.jsm',
-    'RemoteDebugger.jsm',
     'Startup.jsm',
     'WebappManager.jsm',
     'WebappRT.jsm',
     'WebRTCHandler.jsm',
 ]
 
 MOCHITEST_WEBAPPRT_CHROME_MANIFESTS += [
     'test/chrome/downloads/webapprt.ini',
@@ -49,9 +48,8 @@ export('DIST_SUBDIR')
 DEFINES['GRE_MILESTONE'] = CONFIG['GRE_MILESTONE']
 DEFINES['MOZ_APP_BASENAME'] = CONFIG['MOZ_APP_BASENAME']
 
 JAR_MANIFESTS += ['jar.mn']
 
 JS_PREFERENCE_FILES += [
     'prefs.js',
 ]
-
--- a/webapprt/prefs.js
+++ b/webapprt/prefs.js
@@ -77,19 +77,16 @@ pref("dom.payment.provider.0.requestMeth
 pref("dom.always_allow_move_resize_window", true);
 
 // Disable all plugins.  This has to be a non-empty string to disable plugins;
 // otherwise, nsPluginHost::IsTypeWhitelisted assumes all plugins are enabled.
 pref("plugin.allowed_types", " ");
 // Suppress the check for outdated plugins from opening a window.
 pref("extensions.blocklist.suppressUI", true);
 
-pref("devtools.debugger.remote-enabled", true);
-pref("devtools.debugger.force-local", true);
-
 // The default for this pref reflects whether the build is capable of IPC.
 // (Turning it on in a no-IPC build will have no effect.)
 #ifdef XP_MACOSX
 // i386 ipc preferences
 pref("dom.ipc.plugins.enabled.i386", false);
 pref("dom.ipc.plugins.enabled.i386.flash player.plugin", true);
 // x86_64 ipc preferences
 pref("dom.ipc.plugins.enabled.x86_64", true);
deleted file mode 100644
--- a/webapprt/test/chrome/browser_debugger.js
+++ /dev/null
@@ -1,34 +0,0 @@
-Cu.import("resource://gre/modules/Services.jsm");
-var { require } = Cu.import("resource://gre/modules/devtools/shared/Loader.jsm", {});
-var { DebuggerServer } = require("devtools/server/main");
-var { DebuggerClient } = require("devtools/shared/client/main");
-var { RemoteDebugger } = Cu.import("resource://webapprt/modules/RemoteDebugger.jsm", {});
-
-function test() {
-  waitForExplicitFinish();
-
-  loadWebapp("debugger.webapp", undefined, () => {
-    RemoteDebugger.init(Services.prefs.getIntPref('devtools.debugger.remote-port'));
-
-    let client = new DebuggerClient(DebuggerServer.connectPipe());
-    client.connect(() => {
-      client.listTabs((aResponse) => {
-        is(aResponse.tabs[0].title, "Debugger Test Webapp", "Title correct");
-        is(aResponse.tabs[0].url, "http://test/webapprtChrome/webapprt/test/chrome/debugger.html", "URL correct");
-        ok(aResponse.tabs[0].consoleActor, "consoleActor set");
-        ok(aResponse.tabs[0].gcliActor, "gcliActor set");
-        ok(aResponse.tabs[0].styleEditorActor, "styleEditorActor set");
-        ok(aResponse.tabs[0].inspectorActor, "inspectorActor set");
-        ok(aResponse.deviceActor, "deviceActor set");
-
-        client.close(() => {
-          finish();
-        });
-      });
-    });
-  });
-
-  registerCleanupFunction(function() {
-    DebuggerServer.destroy();
-  });
-}
--- a/webapprt/test/chrome/webapprt.ini
+++ b/webapprt/test/chrome/webapprt.ini
@@ -48,17 +48,16 @@ support-files =
   download.test
   install-app.html
   install-app.webapp
   install-app.webapp^headers^
   TestApp.app/Contents/Info.plist
   TestApp.app/Contents/MacOS/webapp.ini
 
 [browser_alarm.js]
-[browser_debugger.js]
 [browser_download.js]
 [browser_geolocation-prompt-noperm.js]
 [browser_geolocation-prompt-perm.js]
 [browser_getUserMedia.js]
 [browser_install-app.js]
 [browser_mozpay.js]
 [browser_noperm.js]
 [browser_sample.js]