Bug 1307881 - Part 1 - Split message persistence prefs into two, one for the netmonitor and one for the console;r=Honza draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Thu, 31 Aug 2017 21:42:15 -0700
changeset 657165 2f3d35329126866b0c85d3620fb9f3d046ff3a85
parent 657025 14eea6bedcf3e2f46ea7c908e1ac9b7d256a42f0
child 657166 19b8decae600ef1a93338003200f97c96fd558de
push id77454
push userbgrinstead@mozilla.com
push dateFri, 01 Sep 2017 04:45:10 +0000
reviewersHonza
bugs1307881
milestone57.0a1
Bug 1307881 - Part 1 - Split message persistence prefs into two, one for the netmonitor and one for the console;r=Honza MozReview-Commit-ID: 4i8heIyPEv0
browser/components/nsBrowserGlue.js
devtools/client/framework/toolbox-options.xhtml
devtools/client/locales/en-US/toolbox.dtd
devtools/client/netmonitor/index.js
devtools/client/netmonitor/src/connector/firefox-connector.js
devtools/client/netmonitor/test/browser_net_persistent_logs.js
devtools/client/preferences/devtools.js
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1739,17 +1739,17 @@ BrowserGlue.prototype = {
         return;
       this._openPreferences("sync", { origin: "doorhanger" });
     }
     this.AlertsService.showAlertNotification(null, title, body, true, null, clickCallback);
   },
 
   // eslint-disable-next-line complexity
   _migrateUI: function BG__migrateUI() {
-    const UI_VERSION = 51;
+    const UI_VERSION = 52;
     const BROWSER_DOCURL = "chrome://browser/content/browser.xul";
 
     let currentUIVersion;
     if (Services.prefs.prefHasUserValue("browser.migration.version")) {
       currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
     } else {
       // This is a new profile, nothing to migrate.
       Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
@@ -2109,16 +2109,24 @@ BrowserGlue.prototype = {
       // dark or light theme.
       let currentTheme = Services.prefs.getCharPref("lightweightThemes.selectedThemeID", "");
       if (currentTheme == "firefox-compact-dark@mozilla.org" ||
           currentTheme == "firefox-compact-light@mozilla.org") {
         Services.prefs.setIntPref("browser.uidensity", 1);
       }
     }
 
+    if (currentUIVersion < 52) {
+      // Keep old devtools log persistence behavior after splitting netmonitor and
+      // webconsole prefs (bug 1307881).
+      if (Services.prefs.getBoolPref("devtools.webconsole.persistlog")) {
+        Services.prefs.setBoolPref("devtools.netmonitor.persistlog", true);
+      }
+    }
+
     // Update the migration version.
     Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
   },
 
   _checkForDefaultBrowser() {
     // Perform default browser checking.
     if (!ShellService) {
       return;
--- a/devtools/client/framework/toolbox-options.xhtml
+++ b/devtools/client/framework/toolbox-options.xhtml
@@ -36,24 +36,16 @@
       <fieldset id="devtools-theme-box"
                 class="options-groupbox
                        horizontal-options-groupbox
                        radiogroup"
                 data-pref="devtools.theme">
         <legend>&options.selectDevToolsTheme.label2;</legend>
       </fieldset>
 
-      <fieldset id="commonprefs-options" class="options-groupbox">
-        <legend>&options.commonPrefs.label;</legend>
-        <label title="&options.enablePersistentLogs.tooltip;">
-          <input type="checkbox" data-pref="devtools.webconsole.persistlog" />
-          <span>&options.enablePersistentLogs.label;</span>
-        </label>
-      </fieldset>
-
       <fieldset id="inspector-options" class="options-groupbox">
         <legend>&options.context.inspector;</legend>
         <label title="&options.showUserAgentStyles.tooltip;">
           <input type="checkbox"
                  data-pref="devtools.inspector.showUserAgentStyles"/>
           <span>&options.showUserAgentStyles.label;</span>
         </label>
         <label title="&options.collapseAttrs.tooltip;">
@@ -89,16 +81,24 @@
         <label title="&options.sourceMaps.tooltip;">
           <input type="checkbox"
                  id="debugger-sourcemaps"
                  data-pref="devtools.debugger.client-source-maps-enabled"/>
           <span>&options.sourceMaps.label;</span>
         </label>
       </fieldset>
 
+      <fieldset id="netmonitor-options" class="options-groupbox">
+        <legend>&options.netmonitor.label;</legend>
+        <label title="&options.netmonitor.enablePersistentLogs.tooltip;">
+          <input type="checkbox" data-pref="devtools.netmonitor.persistlog" />
+          <span>&options.netmonitor.enablePersistentLogs.label;</span>
+        </label>
+      </fieldset>
+
       <fieldset id="styleeditor-options" class="options-groupbox">
         <legend>&options.styleeditor.label;</legend>
         <label title="&options.stylesheetSourceMaps.tooltip;">
           <input type="checkbox"
                  data-pref="devtools.styleeditor.source-maps-enabled"/>
           <span>&options.stylesheetSourceMaps.label;</span>
         </label>
         <label title="&options.stylesheetAutocompletion.tooltip;">
--- a/devtools/client/locales/en-US/toolbox.dtd
+++ b/devtools/client/locales/en-US/toolbox.dtd
@@ -174,27 +174,26 @@
 <!ENTITY options.screenshot.clipboard.label      "Screenshot to clipboard">
 <!ENTITY options.screenshot.clipboard.tooltip    "Saves to the screenshot directly to the clipboard">
 
 <!-- LOCALIZATION NOTE (options.screenshot.audio.label): This is the
    - label for the checkbox that toggles the camera shutter audio for screenshot tool -->
 <!ENTITY options.screenshot.audio.label      "Play camera shutter sound">
 <!ENTITY options.screenshot.audio.tooltip    "Enables the camera audio sound when taking screenshot">
 
-<!-- LOCALIZATION NOTE (options.commonprefs): This is the label for the heading
-      of all preferences that affect both the Web Console and the Network
-      Monitor -->
-<!ENTITY options.commonPrefs.label           "Common Preferences">
+<!-- LOCALIZATION NOTE (options.netmonitor.label): This is the label for the
+  -  heading of the group of Network Monitor preferences in the options panel. -->
+<!ENTITY options.netmonitor.label           "Network">
 
 <!-- LOCALIZATION NOTE (options.enablePersistentLogs.label): This is the
-  -  label for the checkbox that toggles persistent logs in the Web Console and
-  -  network monitor,  i.e. devtools.webconsole.persistlog a boolean preference in
+  -  label for the checkbox that toggles persistent logs in the netmonitor,
+  -  i.e. devtools.netmonitor.persistlog a boolean preference in
   -  about:config, in the options panel. -->
-<!ENTITY options.enablePersistentLogs.label    "Enable persistent logs">
-<!ENTITY options.enablePersistentLogs.tooltip  "If you enable this option the Web Console and Network Monitor will not clear the output each time you navigate to a new page">
+<!ENTITY options.netmonitor.enablePersistentLogs.label    "Enable persistent logs">
+<!ENTITY options.netmonitor.enablePersistentLogs.tooltip  "If you enable this option the Network Monitor will not clear the output each time you navigate to a new page">
 
 <!-- LOCALIZATION NOTE (options.showPlatformData.label): This is the
   -  label for the checkbox that toggles the display of the platform data in the,
   -  Profiler i.e. devtools.profiler.ui.show-platform-data a boolean preference
   -  in about:config, in the options panel. -->
 <!ENTITY options.showPlatformData.label    "Show Gecko platform data">
 <!ENTITY options.showPlatformData.tooltip  "If you enable this option the JavaScript Profiler reports will include
 Gecko platform symbols">
--- a/devtools/client/netmonitor/index.js
+++ b/devtools/client/netmonitor/index.js
@@ -30,17 +30,17 @@ pref("devtools.netmonitor.har.defaultLog
 pref("devtools.netmonitor.har.defaultFileName", "Archive %date");
 pref("devtools.netmonitor.har.jsonp", false);
 pref("devtools.netmonitor.har.jsonpCallback", "");
 pref("devtools.netmonitor.har.includeResponseBodies", true);
 pref("devtools.netmonitor.har.compress", false);
 pref("devtools.netmonitor.har.forceExport", false);
 pref("devtools.netmonitor.har.pageLoadedTimeout", 1500);
 pref("devtools.netmonitor.har.enableAutoExportToFile", false);
-pref("devtools.webconsole.persistlog", false);
+pref("devtools.netmonitor.persistlog", false);
 pref("devtools.styleeditor.enabled", true);
 
 const { configureStore } = require("./src/utils/create-store");
 
 require("./src/assets/styles/netmonitor.css");
 
 EventEmitter.decorate(window);
 const App = require("./src/components/app");
--- a/devtools/client/netmonitor/src/connector/firefox-connector.js
+++ b/devtools/client/netmonitor/src/connector/firefox-connector.js
@@ -77,17 +77,17 @@ class FirefoxConnector {
     this.webConsoleClient.off("networkEvent");
     this.webConsoleClient.off("networkEventUpdate");
     this.webConsoleClient = null;
     this.timelineFront = null;
     this.dataProvider = null;
   }
 
   willNavigate() {
-    if (!Services.prefs.getBoolPref("devtools.webconsole.persistlog")) {
+    if (!Services.prefs.getBoolPref("devtools.netmonitor.persistlog")) {
       this.actions.batchReset();
       this.actions.clearRequests();
     } else {
       // If the log is persistent, just clear all accumulated timing markers.
       this.actions.clearTimingMarkers();
     }
   }
 
--- a/devtools/client/netmonitor/test/browser_net_persistent_logs.js
+++ b/devtools/client/netmonitor/test/browser_net_persistent_logs.js
@@ -9,39 +9,39 @@
  */
 
 add_task(function* () {
   let { tab, monitor } = yield initNetMonitor(SINGLE_GET_URL);
   info("Starting test... ");
 
   let { document } = monitor.panelWin;
 
-  Services.prefs.setBoolPref("devtools.webconsole.persistlog", false);
+  Services.prefs.setBoolPref("devtools.netmonitor.persistlog", false);
 
   yield reloadAndWait();
 
   is(document.querySelectorAll(".request-list-item").length, 2,
     "The request list should have two items at this point.");
 
   yield reloadAndWait();
 
   // Since the reload clears the log, we still expect two requests in the log
   is(document.querySelectorAll(".request-list-item").length, 2,
     "The request list should still have two items at this point.");
 
   // Now we toggle the persistence logs on
-  Services.prefs.setBoolPref("devtools.webconsole.persistlog", true);
+  Services.prefs.setBoolPref("devtools.netmonitor.persistlog", true);
 
   yield reloadAndWait();
 
   // Since we togged the persistence logs, we expect four items after the reload
   is(document.querySelectorAll(".request-list-item").length, 4,
     "The request list should now have four items at this point.");
 
-  Services.prefs.setBoolPref("devtools.webconsole.persistlog", false);
+  Services.prefs.setBoolPref("devtools.netmonitor.persistlog", false);
   return teardown(monitor);
 
   /**
    * Reload the page and wait for 2 GET requests. Race-free.
    */
   function reloadAndWait() {
     let wait = waitForNetworkEvents(monitor, 2);
     tab.linkedBrowser.reload();
--- a/devtools/client/preferences/devtools.js
+++ b/devtools/client/preferences/devtools.js
@@ -282,20 +282,21 @@ pref("devtools.browserconsole.filter.ser
 pref("devtools.browserconsole.filter.serverlog", false);
 
 // Web console filter settings bar
 pref("devtools.webconsole.ui.filterbar", false);
 
 // Max number of inputs to store in web console history.
 pref("devtools.webconsole.inputHistoryCount", 50);
 
-// Persistent logging: |true| if you want the Web Console to keep all of the
+// Persistent logging: |true| if you want the relevant tool to keep all of the
 // logged messages after reloading the page, |false| if you want the output to
 // be cleared each time page navigation happens.
 pref("devtools.webconsole.persistlog", false);
+pref("devtools.netmonitor.persistlog", false);
 
 // Web Console timestamp: |true| if you want the logs and instructions
 // in the Web Console to display a timestamp, or |false| to not display
 // any timestamps.
 pref("devtools.webconsole.timestampMessages", false);
 
 // Web Console automatic multiline mode: |true| if you want incomplete statements
 // to automatically trigger multiline editing (equivalent to shift + enter).