Bug 1386979 - register about-devtools-toolbox on browser startup;r=ochameau
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 21 Nov 2017 20:32:51 +0100
changeset 393344 f320e72a945f5f2c39c6a8fbddb30f3ada3834fe
parent 393343 da6568fa82df358453279e7ec5c22be7b8aad7c0
child 393345 85d8bab6cc6fcffa0ef3892c7937a4543269b5d6
push id32959
push usertoros@mozilla.com
push dateThu, 23 Nov 2017 22:24:31 +0000
treeherdermozilla-central@b705100d6ca8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1386979
milestone59.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 1386979 - register about-devtools-toolbox on browser startup;r=ochameau MozReview-Commit-ID: GUBEyzg2qCw
browser/installer/package-manifest.in
devtools/client/framework/about-devtools-toolbox.js
devtools/client/framework/devtools.js
devtools/client/framework/moz.build
devtools/shim/aboutdevtoolstoolbox-registration.js
devtools/shim/aboutdevtoolstoolbox.manifest
devtools/shim/moz.build
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -371,16 +371,18 @@
 @RESPATH@/browser/components/nsSetDefaultBrowser.manifest
 @RESPATH@/browser/components/nsSetDefaultBrowser.js
 @RESPATH@/browser/components/devtools-startup.manifest
 @RESPATH@/browser/components/devtools-startup.js
 @RESPATH@/browser/components/aboutdebugging-registration.js
 @RESPATH@/browser/components/aboutdebugging.manifest
 @RESPATH@/browser/components/aboutdevtools-registration.js
 @RESPATH@/browser/components/aboutdevtools.manifest
+@RESPATH@/browser/components/aboutdevtoolstoolbox-registration.js
+@RESPATH@/browser/components/aboutdevtoolstoolbox.manifest
 @RESPATH@/browser/components/Experiments.manifest
 @RESPATH@/browser/components/ExperimentsService.js
 @RESPATH@/browser/components/browser-newtab.xpt
 @RESPATH@/browser/components/aboutNewTabService.js
 @RESPATH@/browser/components/NewTabComponents.manifest
 @RESPATH@/components/Downloads.manifest
 @RESPATH@/components/DownloadLegacy.js
 @RESPATH@/components/thumbnails.xpt
--- a/devtools/client/framework/devtools.js
+++ b/devtools/client/framework/devtools.js
@@ -19,17 +19,16 @@ loader.lazyRequireGetter(this, "HUDServi
 loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm");
 
 loader.lazyRequireGetter(this, "WebExtensionInspectedWindowFront",
       "devtools/shared/fronts/webextension-inspected-window", true);
 
 const {defaultTools: DefaultTools, defaultThemes: DefaultThemes} =
   require("devtools/client/definitions");
 const EventEmitter = require("devtools/shared/old-event-emitter");
-const AboutDevTools = require("devtools/client/framework/about-devtools-toolbox");
 const {Task} = require("devtools/shared/task");
 const {getTheme, setTheme, addThemeObserver, removeThemeObserver} =
   require("devtools/client/shared/theme");
 
 const FORBIDDEN_IDS = new Set(["toolbox", ""]);
 const MAX_ORDINAL = 99;
 
 /**
@@ -38,18 +37,16 @@ const MAX_ORDINAL = 99;
  */
 function DevTools() {
   this._tools = new Map(); // Map<toolId, tool>
   this._themes = new Map(); // Map<themeId, theme>
   this._toolboxes = new Map(); // Map<target, toolbox>
   // List of toolboxes that are still in process of creation
   this._creatingToolboxes = new Map(); // Map<target, toolbox Promise>
 
-  AboutDevTools.register();
-
   EventEmitter.decorate(this);
 
   // Listen for changes to the theme pref.
   this._onThemeChanged = this._onThemeChanged.bind(this);
   addThemeObserver(this._onThemeChanged);
 
   // This is important step in initialization codepath where we are going to
   // start registering all default tools and themes: create menuitems, keys, emit
@@ -663,17 +660,16 @@ DevTools.prototype = {
    */
   destroy({ shuttingDown }) {
     // Do not cleanup everything during firefox shutdown, but only when
     // devtools are reloaded via the add-on contribution workflow.
     if (!shuttingDown) {
       for (let [, toolbox] of this._toolboxes) {
         toolbox.destroy();
       }
-      AboutDevTools.unregister();
     }
 
     for (let [key, ] of this.getToolDefinitionMap()) {
       this.unregisterTool(key, true);
     }
 
     gDevTools.unregisterDefaults();
 
--- a/devtools/client/framework/moz.build
+++ b/devtools/client/framework/moz.build
@@ -9,17 +9,16 @@ TEST_HARNESS_FILES.xpcshell.devtools.cli
     'test/shared-redux-head.js',
 ]
 
 DIRS += [
     'components',
 ]
 
 DevToolsModules(
-    'about-devtools-toolbox.js',
     'attach-thread.js',
     'browser-menus.js',
     'devtools-browser.js',
     'devtools.js',
     'gDevTools.jsm',
     'menu-item.js',
     'menu.js',
     'selection.js',
@@ -30,10 +29,10 @@ DevToolsModules(
     'toolbox-highlighter-utils.js',
     'toolbox-host-manager.js',
     'toolbox-hosts.js',
     'toolbox-options.js',
     'toolbox.js',
     'ToolboxProcess.jsm',
 )
 
-with Files('**'):
-    BUG_COMPONENT = ('Firefox', 'Developer Tools: Framework')
+with Files('**'):
+    BUG_COMPONENT = ('Firefox', 'Developer Tools: Framework')
rename from devtools/client/framework/about-devtools-toolbox.js
rename to devtools/shim/aboutdevtoolstoolbox-registration.js
--- a/devtools/client/framework/about-devtools-toolbox.js
+++ b/devtools/shim/aboutdevtoolstoolbox-registration.js
@@ -2,62 +2,42 @@
  * 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";
 
 // Register about:devtools-toolbox which allows to open a devtools toolbox
 // in a Firefox tab or a custom html iframe in browser.html
 
-const { Ci, Cu, Cm, components } = require("chrome");
-const registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
-const Services = require("Services");
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
 const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
+const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
+
 const { nsIAboutModule } = Ci;
 
-function AboutURL() {}
+function AboutDevtoolsToolbox() {}
 
-AboutURL.prototype = {
+AboutDevtoolsToolbox.prototype = {
   uri: Services.io.newURI("chrome://devtools/content/framework/toolbox.xul"),
   classDescription: "about:devtools-toolbox",
-  classID: components.ID("11342911-3135-45a8-8d71-737a2b0ad469"),
+  classID: Components.ID("11342911-3135-45a8-8d71-737a2b0ad469"),
   contractID: "@mozilla.org/network/protocol/about;1?what=devtools-toolbox",
 
   QueryInterface: XPCOMUtils.generateQI([nsIAboutModule]),
 
-  newChannel: function (aURI, aLoadInfo) {
-    let chan = Services.io.newChannelFromURIWithLoadInfo(this.uri, aLoadInfo);
+  newChannel: function (uri, loadInfo) {
+    let chan = Services.io.newChannelFromURIWithLoadInfo(this.uri, loadInfo);
     chan.owner = Services.scriptSecurityManager.getSystemPrincipal();
-    chan.originalURI = aURI;
     return chan;
   },
 
-  getURIFlags: function (aURI) {
+  getURIFlags: function (uri) {
     return nsIAboutModule.ALLOW_SCRIPT |
            nsIAboutModule.ENABLE_INDEXED_DB |
            nsIAboutModule.HIDE_FROM_ABOUTABOUT;
   }
 };
 
-AboutURL.createInstance = function (outer, iid) {
-  if (outer) {
-    throw Cr.NS_ERROR_NO_AGGREGATION;
-  }
-  return new AboutURL();
-};
-
-exports.register = function () {
-  if (registrar.isCIDRegistered(AboutURL.prototype.classID)) {
-    console.error("Trying to register " + AboutURL.prototype.classDescription +
-                  " more than once.");
-  } else {
-    registrar.registerFactory(AboutURL.prototype.classID,
-                       AboutURL.prototype.classDescription,
-                       AboutURL.prototype.contractID,
-                       AboutURL);
-  }
-};
-
-exports.unregister = function () {
-  if (registrar.isCIDRegistered(AboutURL.prototype.classID)) {
-    registrar.unregisterFactory(AboutURL.prototype.classID, AboutURL);
-  }
-};
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([
+  AboutDevtoolsToolbox
+]);
new file mode 100644
--- /dev/null
+++ b/devtools/shim/aboutdevtoolstoolbox.manifest
@@ -0,0 +1,2 @@
+component {11342911-3135-45a8-8d71-737a2b0ad469} aboutdevtoolstoolbox-registration.js
+contract @mozilla.org/network/protocol/about;1?what=devtools-toolbox {11342911-3135-45a8-8d71-737a2b0ad469}
\ No newline at end of file
--- a/devtools/shim/moz.build
+++ b/devtools/shim/moz.build
@@ -10,16 +10,18 @@ JS_PREFERENCE_PP_FILES += [
     'devtools-startup-prefs.js',
 ]
 
 # Register the about:debugging page only for 'addon' and 'all' builds.
 if CONFIG['MOZ_DEVTOOLS'] != 'server':
     EXTRA_COMPONENTS += [
         'aboutdebugging-registration.js',
         'aboutdebugging.manifest',
+        'aboutdevtoolstoolbox-registration.js',
+        'aboutdevtoolstoolbox.manifest',
         'devtools-startup.js',
         'devtools-startup.manifest',
     ]
 
     DIRS += [
       'aboutdevtools',
       'locales',
     ]