Bug 1374735 - use DevToolsShim to open browser console from extensions;r=bgrins,kmag

MozReview-Commit-ID: GJQ7fcw1L8i
This commit is contained in:
Julian Descottes
2017-07-24 12:12:47 +02:00
parent aaea6acb73
commit 4ba1ec480e
3 changed files with 17 additions and 6 deletions

View File

@@ -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;