Bug 1456663 - Add a preference to open webconsole.html directly in the Browser Console;r=nchevobbe
authorBrian Grinstead <bgrinstead@mozilla.com>
Thu, 26 Apr 2018 10:35:14 -0700
changeset 472170 a9bd9695b7e0741b5b0d1b73397b57a7cced77f8
parent 472169 fd07ca1a922fc89838ba3aac345d843d5e3fa082
child 472171 168a838455004d0e71546cf7198836c69016ca94
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1456663
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1456663 - Add a preference to open webconsole.html directly in the Browser Console;r=nchevobbe This makes it easier to test top-level HTML window support. We continue to use the XUL wrapper document unless if the pref is changed. MozReview-Commit-ID: LUunCOCSyMN
devtools/client/definitions.js
devtools/client/preferences/devtools-client.js
devtools/client/webconsole/hudservice.js
--- a/devtools/client/definitions.js
+++ b/devtools/client/definitions.js
@@ -96,17 +96,24 @@ Tools.inspector = {
     return new InspectorPanel(iframeWindow, toolbox);
   }
 };
 Tools.webConsole = {
   id: "webconsole",
   accesskey: l10n("webConsoleCmd.accesskey"),
   ordinal: 2,
   url: "chrome://devtools/content/webconsole/webconsole.html",
-  browserConsoleURL: "chrome://devtools/content/webconsole/browserconsole.xul",
+  get browserConsoleUsesHTML() {
+    return Services.prefs.getBoolPref("devtools.browserconsole.html");
+  },
+  get browserConsoleURL() {
+    return this.browserConsoleUsesHTML ?
+      "chrome://devtools/content/webconsole/webconsole.html" :
+      "chrome://devtools/content/webconsole/browserconsole.xul";
+  },
   icon: "chrome://devtools/skin/images/tool-webconsole.svg",
   label: l10n("ToolboxTabWebconsole.label"),
   menuLabel: l10n("MenuWebconsole.label"),
   panelLabel: l10n("ToolboxWebConsole.panelLabel"),
   get tooltip() {
     return l10n("ToolboxWebconsole.tooltip2",
     (osString == "Darwin" ? "Cmd+Opt+" : "Ctrl+Shift+") +
     l10n("webconsole.commandkey"));
--- a/devtools/client/preferences/devtools-client.js
+++ b/devtools/client/preferences/devtools-client.js
@@ -237,16 +237,19 @@ pref("devtools.scratchpad.enabled", fals
 pref("devtools.dom.enabled", false);
 
 // Make sure the Accessibility panel is hidden by default
 pref("devtools.accessibility.enabled", false);
 
 // Web Audio Editor Inspector Width should be a preference
 pref("devtools.webaudioeditor.inspectorWidth", 300);
 
+// Experimental UI for the browser console that doesn't use a XUL wrapper doc
+pref("devtools.browserconsole.html", false);
+
 // Web console filters
 pref("devtools.webconsole.filter.error", true);
 pref("devtools.webconsole.filter.warn", true);
 pref("devtools.webconsole.filter.info", true);
 pref("devtools.webconsole.filter.log", true);
 pref("devtools.webconsole.filter.debug", true);
 pref("devtools.webconsole.filter.css", false);
 pref("devtools.webconsole.filter.net", false);
--- a/devtools/client/webconsole/hudservice.js
+++ b/devtools/client/webconsole/hudservice.js
@@ -178,31 +178,37 @@ HUD_SERVICE.prototype =
 
       let client = new DebuggerClient(DebuggerServer.connectPipe());
       await client.connect();
       let response = await client.getProcess();
       return { form: response.form, client, chrome: true, isTabActor: true };
     }
 
     async function openWindow(t) {
-      let browserConsoleURL = Tools.webConsole.browserConsoleURL;
-      let win = Services.ww.openWindow(null, browserConsoleURL, "_blank",
-                                       BC_WINDOW_FEATURES, null);
+      let win = Services.ww.openWindow(null, Tools.webConsole.browserConsoleURL,
+                                       "_blank", BC_WINDOW_FEATURES, null);
+      let iframeWindow = win;
+
       await new Promise(resolve => {
         win.addEventListener("DOMContentLoaded", resolve, {once: true});
       });
 
       win.document.title = l10n.getStr("browserConsole.title");
 
-      let iframe = win.document.querySelector("iframe");
-      await new Promise(resolve => {
-        iframe.addEventListener("DOMContentLoaded", resolve, {once: true});
-      });
+      // With a XUL wrapper doc, we host webconsole.html in an iframe.
+      // Wait for that to be ready before resolving:
+      if (!Tools.webConsole.browserConsoleUsesHTML) {
+        let iframe = win.document.querySelector("iframe");
+        await new Promise(resolve => {
+          iframe.addEventListener("DOMContentLoaded", resolve, {once: true});
+        });
+        iframeWindow = iframe.contentWindow;
+      }
 
-      return {iframeWindow: iframe.contentWindow, chromeWindow: win};
+      return {iframeWindow, chromeWindow: win};
     }
 
     // Temporarily cache the async startup sequence so that if toggleBrowserConsole
     // gets called again we can return this console instead of opening another one.
     this._browserConsoleInitializing = (async () => {
       let connection = await connect();
       let target = await TargetFactory.forRemoteTab(connection);
       let {iframeWindow, chromeWindow} = await openWindow(target);