mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1374735 - use DevToolsShim to open browser console from extensions;r=bgrins,kmag
MozReview-Commit-ID: GJQ7fcw1L8i --HG-- extra : source : da075933f7bcd9e3b7ff735879c521bb50f28b7a
This commit is contained in:
parent
721cd7ffa1
commit
d148f3f8c0
@ -590,6 +590,15 @@ DevTools.prototype = {
|
||||
return new WebExtensionInspectedWindowFront(tabTarget.client, tabTarget.form);
|
||||
},
|
||||
|
||||
/**
|
||||
* Compatibility layer for web-extensions. Used by DevToolsShim for
|
||||
* toolkit/components/extensions/ext-c-toolkit.js
|
||||
*/
|
||||
openBrowserConsole: function () {
|
||||
let {HUDService} = require("devtools/client/webconsole/hudservice");
|
||||
HUDService.openBrowserConsoleOrFocus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Called from the DevToolsShim, used by nsContextMenu.js.
|
||||
*
|
||||
|
@ -298,9 +298,10 @@ let addonSdkMethods = [
|
||||
* therefore DevTools should always be available when they are called.
|
||||
*/
|
||||
let webExtensionsMethods = [
|
||||
"createWebExtensionInspectedWindowFront",
|
||||
"getTargetForTab",
|
||||
"getTheme",
|
||||
"createWebExtensionInspectedWindowFront",
|
||||
"openBrowserConsole",
|
||||
];
|
||||
|
||||
for (let method of [...addonSdkMethods, ...webExtensionsMethods]) {
|
||||
|
@ -2,6 +2,11 @@
|
||||
|
||||
Cu.import("resource://gre/modules/ExtensionCommon.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Services",
|
||||
"resource://gre/modules/Services.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "DevToolsShim",
|
||||
"chrome://devtools-shim/content/DevToolsShim.jsm");
|
||||
|
||||
// These are defined on "global" which is used for the same scopes as the other
|
||||
// ext-c-*.js files.
|
||||
/* exported EventManager */
|
||||
@ -16,11 +21,7 @@ global.initializeBackgroundPage = (contentWindow) => {
|
||||
let alertDisplayedWarning = false;
|
||||
let alertOverwrite = text => {
|
||||
if (!alertDisplayedWarning) {
|
||||
require("devtools/client/framework/devtools-browser");
|
||||
|
||||
let {HUDService} = require("devtools/client/webconsole/hudservice");
|
||||
HUDService.openBrowserConsoleOrFocus();
|
||||
|
||||
DevToolsShim.openBrowserConsole();
|
||||
contentWindow.console.warn("alert() is not supported in background windows; please use console.log instead.");
|
||||
|
||||
alertDisplayedWarning = true;
|
||||
|
Loading…
Reference in New Issue
Block a user