зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1367424 - add shims for addon sdk to DevToolsShim;r=ochameau
Some APIs and methods still used by the addon sdk are not worth exposing or migrating to mozilla-central given that this is only intended for release 56 (after that, legacy extensions will no longer be supported). For those APIs, we create a simple wrapper in DevToolsShim and moved the implementation to framework/devtools MozReview-Commit-ID: 8LiiptqO0NI --HG-- extra : rebase_source : 357b503532fed7933a6690418b846c70350c59b9
This commit is contained in:
Родитель
01c2dc7a45
Коммит
4cbdadf23f
|
@ -16,6 +16,11 @@ loader.lazyRequireGetter(this, "ToolboxHostManager", "devtools/client/framework/
|
|||
loader.lazyRequireGetter(this, "gDevToolsBrowser", "devtools/client/framework/devtools-browser", true);
|
||||
loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm");
|
||||
|
||||
// Dependencies required for addon sdk compatibility layer.
|
||||
loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
|
||||
loader.lazyRequireGetter(this, "DebuggerClient", "devtools/shared/client/main", true);
|
||||
loader.lazyImporter(this, "BrowserToolboxProcess", "resource://devtools/client/framework/ToolboxProcess.jsm");
|
||||
|
||||
const {defaultTools: DefaultTools, defaultThemes: DefaultThemes} =
|
||||
require("devtools/client/definitions");
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
@ -533,6 +538,42 @@ DevTools.prototype = {
|
|||
return TargetFactory.forTab(tab);
|
||||
},
|
||||
|
||||
/**
|
||||
* Compatibility layer for addon-sdk. Remove when Firefox 57 hits release.
|
||||
* Initialize the debugger server if needed and and create a connection.
|
||||
*
|
||||
* @return {DebuggerTransport} a client-side DebuggerTransport for communicating with
|
||||
* the created connection.
|
||||
*/
|
||||
connectDebuggerServer: function () {
|
||||
if (!DebuggerServer.initialized) {
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.addBrowserActors();
|
||||
}
|
||||
|
||||
return DebuggerServer.connectPipe();
|
||||
},
|
||||
|
||||
/**
|
||||
* Compatibility layer for addon-sdk. Remove when Firefox 57 hits release.
|
||||
*
|
||||
* Create a connection to the debugger server and return a debugger client for this
|
||||
* new connection.
|
||||
*/
|
||||
createDebuggerClient: function () {
|
||||
let transport = this.connectDebuggerServer();
|
||||
return new DebuggerClient(transport);
|
||||
},
|
||||
|
||||
/**
|
||||
* Compatibility layer for addon-sdk. Remove when Firefox 57 hits release.
|
||||
*
|
||||
* Create a BrowserToolbox process linked to the provided addon id.
|
||||
*/
|
||||
initBrowserToolboxProcessForAddon: function (addonID) {
|
||||
BrowserToolboxProcess.init({ addonID });
|
||||
},
|
||||
|
||||
/**
|
||||
* Either the SDK Loader has been destroyed by the add-on contribution
|
||||
* workflow, or firefox is shutting down.
|
||||
|
|
|
@ -196,3 +196,30 @@ this.DevToolsShim = {
|
|||
this.themes = [];
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Compatibility layer for addon-sdk. Remove when Firefox 57 hits release.
|
||||
*
|
||||
* 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",
|
||||
];
|
||||
|
||||
for (let method of addonSdkMethods) {
|
||||
this.DevToolsShim[method] = function () {
|
||||
if (!this.isInstalled()) {
|
||||
throw new Error(`Method ${method} unavailable if DevTools are not installed`);
|
||||
}
|
||||
|
||||
return this.gDevTools[method].apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче