Bug 1367424 - use DevTools shim in addon SDK;r=rpl
☠☠ backed out by 3b60060e1529 ☠ ☠
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 29 May 2017 18:20:01 +0200
changeset 412975 6f17a72e69cc9ccab071091347f6bb5cf7a57bab
parent 412974 8ecdc6d29e1dc737637d6cc03993aa5ecfb809c2
child 412976 34f42d4d3ef2a821ab398549cc2ffd8223724d4c
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrpl
bugs1367424
milestone55.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 1367424 - use DevTools shim in addon SDK;r=rpl MozReview-Commit-ID: 2ZoAU1pRxzx
addon-sdk/source/lib/dev/debuggee.js
addon-sdk/source/lib/dev/toolbox.js
addon-sdk/source/lib/dev/utils.js
addon-sdk/source/lib/sdk/addon/runner.js
addon-sdk/source/test/addons/page-mod-debugger-post/main.js
addon-sdk/source/test/addons/page-mod-debugger-pre/main.js
--- a/addon-sdk/source/lib/dev/debuggee.js
+++ b/addon-sdk/source/lib/dev/debuggee.js
@@ -6,18 +6,17 @@
 
 module.metadata = {
   "stability": "experimental"
 };
 
 const { Cu } = require("chrome");
 const { Class } = require("../sdk/core/heritage");
 const { MessagePort, MessageChannel } = require("../sdk/messaging");
-const { require: devtoolsRequire } = Cu.import("resource://devtools/shared/Loader.jsm", {});
-const { DebuggerServer } = devtoolsRequire("devtools/server/main");
+const { DevToolsShim } = Cu.import("chrome://devtools-shim/content/DevToolsShim.jsm", {});
 
 const outputs = new WeakMap();
 const inputs = new WeakMap();
 const targets = new WeakMap();
 const transports = new WeakMap();
 
 const inputFor = port => inputs.get(port);
 const outputFor = port => outputs.get(port);
@@ -44,22 +43,18 @@ const Debuggee = Class({
     }
     outputFor(this).close();
   },
   start: function() {
     const target = targets.get(this);
     if (target.isLocalTab) {
       // Since a remote protocol connection will be made, let's start the
       // DebuggerServer here, once and for all tools.
-      if (!DebuggerServer.initialized) {
-        DebuggerServer.init();
-        DebuggerServer.addBrowserActors();
-      }
-
-      transports.set(this, DebuggerServer.connectPipe());
+      let transport = DevToolsShim.connectDebuggerServer();
+      transports.set(this, transport);
     }
     // TODO: Implement support for remote connections (See Bug 980421)
     else {
       throw Error("Remote targets are not yet supported");
     }
 
     // pipe messages send to the debuggee to an actual
     // server via remote debugging protocol transport.
--- a/addon-sdk/source/lib/dev/toolbox.js
+++ b/addon-sdk/source/lib/dev/toolbox.js
@@ -10,17 +10,17 @@ module.metadata = {
 
 const { Cu, Cc, Ci } = require("chrome");
 const { Class } = require("../sdk/core/heritage");
 const { Disposable, setup } = require("../sdk/core/disposable");
 const { contract, validate } = require("../sdk/util/contract");
 const { each, pairs, values } = require("../sdk/util/sequence");
 const { onEnable, onDisable } = require("../dev/theme/hooks");
 
-const { gDevTools } = Cu.import("resource://devtools/client/framework/gDevTools.jsm", {});
+const { DevToolsShim } = Cu.import("chrome://devtools-shim/content/DevToolsShim.jsm", {});
 
 // This is temporary workaround to allow loading of the developer tools client - volcan
 // into a toolbox panel, this hack won't be necessary as soon as devtools patch will be
 // shipped in nightly, after which it can be removed. Bug 1038517
 const registerSDKURI = () => {
   const ioService = Cc['@mozilla.org/network/io-service;1']
                       .getService(Ci.nsIIOService);
   const resourceHandler = ioService.getProtocolHandler("resource")
@@ -41,17 +41,17 @@ const Tool = Class({
     this.panels = panels;
     this.themes = themes;
 
     each(([key, Panel]) => {
       const { url, label, tooltip, icon, invertIconForLightTheme,
               invertIconForDarkTheme } = validate(Panel.prototype);
       const { id } = Panel.prototype;
 
-      gDevTools.registerTool({
+      DevToolsShim.registerTool({
         id: id,
         url: "about:blank",
         label: label,
         tooltip: tooltip,
         icon: icon,
         invertIconForLightTheme: invertIconForLightTheme,
         invertIconForDarkTheme: invertIconForDarkTheme,
         isTargetSupported: target => target.isLocalTab,
@@ -65,37 +65,37 @@ const Tool = Class({
         }
       });
     }, pairs(panels));
 
     each(([key, theme]) => {
       validate(theme);
       setup(theme);
 
-      gDevTools.registerTheme({
+      DevToolsShim.registerTheme({
         id: theme.id,
         label: theme.label,
         stylesheets: theme.getStyles(),
         classList: theme.getClassList(),
         onApply: (window, oldTheme) => {
           onEnable(theme, { window: window,
                             oldTheme: oldTheme });
         },
         onUnapply: (window, newTheme) => {
           onDisable(theme, { window: window,
                             newTheme: newTheme });
         }
       });
     }, pairs(themes));
   },
   dispose: function() {
-    each(Panel => gDevTools.unregisterTool(Panel.prototype.id),
+    each(Panel => DevToolsShim.unregisterTool(Panel.prototype.id),
          values(this.panels));
 
-    each(Theme => gDevTools.unregisterTheme(Theme.prototype.id),
+    each(Theme => DevToolsShim.unregisterTheme(Theme.prototype.id),
          values(this.themes));
   }
 });
 
 validate.define(Tool, contract({
   panels: {
     is: ["object", "undefined"]
   },
--- a/addon-sdk/source/lib/dev/utils.js
+++ b/addon-sdk/source/lib/dev/utils.js
@@ -1,40 +1,39 @@
 /* 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 { Cu } = require("chrome");
-const { gDevTools } = Cu.import("resource://devtools/client/framework/gDevTools.jsm", {});
-const { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {});
+const { DevToolsShim } = Cu.import("chrome://devtools-shim/content/DevToolsShim.jsm", {});
 
 const { getActiveTab } = require("../sdk/tabs/utils");
 const { getMostRecentBrowserWindow } = require("../sdk/window/utils");
 
 const targetFor = target => {
   target = target || getActiveTab(getMostRecentBrowserWindow());
-  return devtools.TargetFactory.forTab(target);
+  return DevToolsShim.getTargetForTab(target);
 };
 
 const getId = id => ((id.prototype && id.prototype.id) || id.id || id);
 
 const getCurrentPanel = toolbox => toolbox.getCurrentPanel();
 exports.getCurrentPanel = getCurrentPanel;
 
 const openToolbox = (id, tab) => {
   id = getId(id);
-  return gDevTools.showToolbox(targetFor(tab), id);
+  return DevToolsShim.showToolbox(targetFor(tab), id);
 };
 exports.openToolbox = openToolbox;
 
-const closeToolbox = tab => gDevTools.closeToolbox(targetFor(tab));
+const closeToolbox = tab => DevToolsShim.closeToolbox(targetFor(tab));
 exports.closeToolbox = closeToolbox;
 
-const getToolbox = tab => gDevTools.getToolbox(targetFor(tab));
+const getToolbox = tab => DevToolsShim.getToolbox(targetFor(tab));
 exports.getToolbox = getToolbox;
 
 const openToolboxPanel = (id, tab) => {
   id = getId(id);
-  return gDevTools.showToolbox(targetFor(tab), id).then(getCurrentPanel);
+  return DevToolsShim.showToolbox(targetFor(tab), id).then(getCurrentPanel);
 };
 exports.openToolboxPanel = openToolboxPanel;
--- a/addon-sdk/source/lib/sdk/addon/runner.js
+++ b/addon-sdk/source/lib/sdk/addon/runner.js
@@ -12,22 +12,17 @@ const { id, loadReason } = require('../s
 const { descriptor, Sandbox, evaluate, main, resolveURI } = require('toolkit/loader');
 const { exit, env, staticArgs } = require('../system');
 const { when: unload } = require('../system/unload');
 const globals = require('../system/globals');
 const { get } = require('../preferences/service');
 const { preferences } = metadata;
 
 const Startup = Cu.import("resource://gre/modules/sdk/system/Startup.js", {}).exports;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-XPCOMUtils.defineLazyGetter(this, "BrowserToolboxProcess", function () {
-  return Cu.import("resource://devtools/client/framework/ToolboxProcess.jsm", {}).
-         BrowserToolboxProcess;
-});
+const { DevToolsShim } = Cu.import("chrome://devtools-shim/content/DevToolsShim.jsm", {});
 
 // Initializes default preferences
 function setDefaultPrefs(prefsURI) {
   const prefs = Cc['@mozilla.org/preferences-service;1'].
                 getService(Ci.nsIPrefService).
                 QueryInterface(Ci.nsIPrefBranch2);
   const branch = prefs.getDefaultBranch('');
   const sandbox = Sandbox({
@@ -151,17 +146,17 @@ function run(options) {
         staticArgs: staticArgs
       }, {
         print: function print(_) { dump(_ + '\n') },
         quit: exit
       });
     }
 
     if (get("extensions." + id + ".sdk.debug.show", false)) {
-      BrowserToolboxProcess.init({ addonID: id });
+      DevToolsShim.initBrowserToolboxProcessForAddon(id);
     }
   } catch (error) {
     console.exception(error);
     throw error;
   }
 }
 exports.startup = startup;
 
--- a/addon-sdk/source/test/addons/page-mod-debugger-post/main.js
+++ b/addon-sdk/source/test/addons/page-mod-debugger-post/main.js
@@ -7,40 +7,32 @@ const { Cu } = require('chrome');
 const { PageMod } = require('sdk/page-mod');
 const tabs = require('sdk/tabs');
 const { closeTab } = require('sdk/tabs/utils');
 const promise = require('sdk/core/promise')
 const { getMostRecentBrowserWindow } = require('sdk/window/utils');
 const { data } = require('sdk/self');
 const { set } = require('sdk/preferences/service');
 
-const { require: devtoolsRequire } = Cu.import("resource://devtools/shared/Loader.jsm", {});
-const { DebuggerServer } = devtoolsRequire("devtools/server/main");
-const { DebuggerClient } = devtoolsRequire("devtools/shared/client/main");
+const { DevToolsShim } = Cu.import("chrome://devtools-shim/content/DevToolsShim.jsm", {});
 
 var gClient;
 var ok;
 var testName = 'testDebugger';
 var iframeURL = 'data:text/html;charset=utf-8,' + testName;
 var TAB_URL = 'data:text/html;charset=utf-8,' + encodeURIComponent('<iframe src="' + iframeURL + '" />');
 TAB_URL = data.url('index.html');
 var mod;
 
 exports.testDebugger = function(assert, done) {
   ok = assert.ok.bind(assert);
   assert.pass('starting test');
   set('devtools.debugger.log', true);
 
-  if (!DebuggerServer.initialized) {
-    DebuggerServer.init();
-    DebuggerServer.addBrowserActors();
-  }
-
-  let transport = DebuggerServer.connectPipe();
-  gClient = new DebuggerClient(transport);
+  gClient = DevToolsShim.createDebuggerClient();
   gClient.connect((aType, aTraits) => {
     tabs.open({
       url: TAB_URL,
       onLoad: function(tab) {
         assert.pass('tab loaded');
 
         attachTabActorForUrl(gClient, TAB_URL).
           then(_ => { assert.pass('attachTabActorForUrl called'); return _; }).
--- a/addon-sdk/source/test/addons/page-mod-debugger-pre/main.js
+++ b/addon-sdk/source/test/addons/page-mod-debugger-pre/main.js
@@ -7,19 +7,17 @@ const { Cu } = require('chrome');
 const { PageMod } = require('sdk/page-mod');
 const tabs = require('sdk/tabs');
 const { closeTab } = require('sdk/tabs/utils');
 const promise = require('sdk/core/promise')
 const { getMostRecentBrowserWindow } = require('sdk/window/utils');
 const { data } = require('sdk/self');
 const { set } = require('sdk/preferences/service');
 
-const { require: devtoolsRequire } = Cu.import("resource://devtools/shared/Loader.jsm", {});
-const { DebuggerServer } = devtoolsRequire("devtools/server/main");
-const { DebuggerClient } = devtoolsRequire("devtools/shared/client/main");
+const { DevToolsShim } = Cu.import("chrome://devtools-shim/content/DevToolsShim.jsm", {});
 
 var gClient;
 var ok;
 var testName = 'testDebugger';
 var iframeURL = 'data:text/html;charset=utf-8,' + testName;
 var TAB_URL = 'data:text/html;charset=utf-8,' + encodeURIComponent('<iframe src="' + iframeURL + '" />');
 TAB_URL = data.url('index.html');
 var mod;
@@ -31,23 +29,17 @@ exports.testDebugger = function(assert, 
 
   mod = PageMod({
     include: TAB_URL,
     attachTo: ['existing', 'top', 'frame'],
     contentScriptFile: data.url('script.js'),
   });
   ok(true, 'PageMod was created');
 
-  if (!DebuggerServer.initialized) {
-    DebuggerServer.init();
-    DebuggerServer.addBrowserActors();
-  }
-
-  let transport = DebuggerServer.connectPipe();
-  gClient = new DebuggerClient(transport);
+  gClient = DevToolsShim.createDebuggerClient();
   gClient.connect((aType, aTraits) => {
     tabs.open({
       url: TAB_URL,
       onLoad: function(tab) {
         assert.pass('tab loaded');
 
         attachTabActorForUrl(gClient, TAB_URL).
           then(_ => { assert.pass('attachTabActorForUrl called'); return _; }).