Bug 1386821 - call initDevTools if devtools.toolbar.visible is true;r=ochameau
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 03 Aug 2017 08:57:38 +0200
changeset 642634 da2bc55ad33a418547f7776cf761cbef0c93c0ae
parent 642633 448569fa56e550ce4cb71ae63c090227af71ecf3
child 642635 e38283010bb39d702a5301ae127b842c54908ba6
push id72833
push userbmo:emilio+bugs@crisal.io
push dateTue, 08 Aug 2017 16:50:16 +0000
reviewersochameau
bugs1386821
milestone57.0a1
Bug 1386821 - call initDevTools if devtools.toolbar.visible is true;r=ochameau MozReview-Commit-ID: C1EFv9T0VKS
devtools/client/preferences/devtools.js
devtools/shim/devtools-startup-prefs.js
devtools/shim/devtools-startup.js
--- a/devtools/client/preferences/devtools.js
+++ b/devtools/client/preferences/devtools.js
@@ -13,17 +13,16 @@ pref("devtools.devedition.promo.url", "h
   pref("devtools.devedition.promo.enabled", false);
 #endif
 
 // DevTools development workflow
 pref("devtools.loader.hotreload", false);
 
 // Developer toolbar preferences
 pref("devtools.toolbar.enabled", true);
-pref("devtools.toolbar.visible", false);
 
 // Enable DevTools WebIDE by default
 pref("devtools.webide.enabled", true);
 
 // Toolbox preferences
 pref("devtools.toolbox.footer.height", 250);
 pref("devtools.toolbox.sidebar.width", 500);
 pref("devtools.toolbox.host", "bottom");
--- a/devtools/shim/devtools-startup-prefs.js
+++ b/devtools/shim/devtools-startup-prefs.js
@@ -12,8 +12,11 @@
 pref("devtools.jsonview.enabled", true);
 
 // Default theme ("dark" or "light")
 #ifdef MOZ_DEV_EDITION
 sticky_pref("devtools.theme", "dark");
 #else
 sticky_pref("devtools.theme", "light");
 #endif
+
+// Should the devtools toolbar be opened on startup
+pref("devtools.toolbar.visible", false);
--- a/devtools/shim/devtools-startup.js
+++ b/devtools/shim/devtools-startup.js
@@ -21,16 +21,21 @@
 
 "use strict";
 
 const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
 const kDebuggerPrefs = [
   "devtools.debugger.remote-enabled",
   "devtools.chrome.enabled"
 ];
+
+// If devtools.toolbar.visible is set to true, the developer toolbar should appear on
+// startup.
+const TOOLBAR_VISIBLE_PREF = "devtools.toolbar.visible";
+
 const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
 XPCOMUtils.defineLazyModuleGetter(this, "Services",
                                   "resource://gre/modules/Services.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
                                   "resource://gre/modules/AppConstants.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
                                   "resource:///modules/CustomizableUI.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "CustomizableWidgets",
@@ -188,16 +193,22 @@ DevToolsStartup.prototype = {
     if (debuggerServerFlag) {
       this.handleDebuggerServerFlag(cmdLine, debuggerServerFlag);
     }
 
     // Only top level Firefox Windows fire a browser-delayed-startup-finished event
     let onWindowReady = window => {
       this.hookWindow(window);
 
+      if (Services.prefs.getBoolPref(TOOLBAR_VISIBLE_PREF, false)) {
+        // Loading devtools-browser will open the developer toolbar by also checking this
+        // pref.
+        this.initDevTools();
+      }
+
       if (devtoolsFlag) {
         this.handleDevToolsFlag(window);
         // This listener is called for all Firefox windows, but we want to execute
         // that command only once
         devtoolsFlag = false;
       }
       JsonView.initialize();
     };
@@ -361,17 +372,17 @@ DevToolsStartup.prototype = {
 
   /**
    * Boolean flag to check if DevTools have been already initialized or not.
    * By initialized, we mean that its main modules are loaded.
    */
   initialized: false,
 
   initDevTools: function (reason) {
-    if (!this.initialized) {
+    if (reason && !this.initialized) {
       // Only save the first call for each firefox run as next call
       // won't necessarely start the tool. For example key shortcuts may
       // only change the currently selected tool.
       try {
         Services.telemetry.getHistogramById("DEVTOOLS_ENTRY_POINT")
                           .add(reason);
       } catch (e) {
         dump("DevTools telemetry entry point failed: " + e + "\n");