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
--- 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);
};
}