Bug 1374735 - use DevToolsShim to create TabTarget in ext-devtools;r=mixedpuppy draft
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 22 Jun 2017 20:44:56 +0200
changeset 648850 515278b93ad9840f6af89fb13cc62bb819a65253
parent 648849 8d9011adb2a76427b554c9a18f0406b21e639d4f
child 648851 84526155e05cbbe47dc329fc4e58b08ac904e962
push id74909
push userjdescottes@mozilla.com
push dateFri, 18 Aug 2017 12:10:48 +0000
reviewersmixedpuppy
bugs1374735
milestone57.0a1
Bug 1374735 - use DevToolsShim to create TabTarget in ext-devtools;r=mixedpuppy Removing dependencies from mozilla-central to devtools. Use DevTools shim instead of directly depending on devtools code here. MozReview-Commit-ID: CeV5tfw1Vnz
browser/components/extensions/ext-devtools.js
devtools/shim/DevToolsShim.jsm
--- a/browser/components/extensions/ext-devtools.js
+++ b/browser/components/extensions/ext-devtools.js
@@ -48,19 +48,18 @@ global.getDevToolsTargetForContext = asy
   if (!context.devToolsToolbox || !context.devToolsToolbox.target) {
     throw new Error("Unable to get a TabTarget for a context not associated to any toolbox");
   }
 
   if (!context.devToolsToolbox.target.isLocalTab) {
     throw new Error("Unexpected target type: only local tabs are currently supported.");
   }
 
-  const {TabTarget} = require("devtools/client/framework/target");
-
-  context.devToolsTarget = new TabTarget(context.devToolsToolbox.target.tab);
+  const tab = context.devToolsToolbox.target.tab;
+  context.devToolsTarget = DevToolsShim.getTargetForTab(tab);
   await context.devToolsTarget.makeRemote();
 
   return context.devToolsTarget;
 };
 
 /**
  * Retrieve the devtools target for the devtools extension proxy context
  * (lazily cloned from the target of the toolbox associated to the context
--- a/devtools/shim/DevToolsShim.jsm
+++ b/devtools/shim/DevToolsShim.jsm
@@ -281,29 +281,29 @@ this.DevToolsShim = {
  * The methods below are used by classes and tests from addon-sdk/
  * If DevTools are not installed when calling one of them, the call will throw.
  */
 
 let addonSdkMethods = [
   "closeToolbox",
   "connectDebuggerServer",
   "createDebuggerClient",
-  "getTargetForTab",
   "getToolbox",
   "initBrowserToolboxProcessForAddon",
   "showToolbox",
 ];
 
 /**
  * Compatibility layer for webextensions.
  *
  * Those methods are called only after a DevTools webextension was loaded in DevTools,
  * therefore DevTools should always be available when they are called.
  */
 let webExtensionsMethods = [
+  "getTargetForTab",
   "getTheme",
 ];
 
 for (let method of [...addonSdkMethods, ...webExtensionsMethods]) {
   this.DevToolsShim[method] = function () {
     return this.gDevTools[method].apply(this.gDevTools, arguments);
   };
 }