Bug 1326937 - Fix persistent logs; r=bgrins draft
authorJan Odvarko <odvarko@gmail.com>
Fri, 21 Jul 2017 11:20:02 +0200
changeset 612951 abbd12a7909d7d184c081de4c82bab56e58f2ed4
parent 612950 33bef3a66d60e306d9ee72a95059d8699e5643e1
child 638559 b9707d41e9dde9a9d2921be8cf5f1222675bacd0
push id69666
push userjodvarko@mozilla.com
push dateFri, 21 Jul 2017 09:21:19 +0000
reviewersbgrins
bugs1326937
milestone56.0a1
Bug 1326937 - Fix persistent logs; r=bgrins MozReview-Commit-ID: BLsEmTwkrxK
devtools/client/webconsole/new-webconsole.js
--- a/devtools/client/webconsole/new-webconsole.js
+++ b/devtools/client/webconsole/new-webconsole.js
@@ -13,20 +13,24 @@ const defer = require("devtools/shared/d
 const Services = require("Services");
 const { gDevTools } = require("devtools/client/framework/devtools");
 const { JSTerm } = require("devtools/client/webconsole/jsterm");
 const { WebConsoleConnectionProxy } = require("devtools/client/webconsole/webconsole-connection-proxy");
 const KeyShortcuts = require("devtools/client/shared/key-shortcuts");
 const { l10n } = require("devtools/client/webconsole/new-console-output/utils/messages");
 const system = require("devtools/shared/system");
 const { ZoomKeys } = require("devtools/client/shared/zoom-keys");
+
 const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages";
+const PREF_PERSISTLOG = "devtools.webconsole.persistlog";
+
 // XXX: This file is incomplete (see bug 1326937).
 // It's used when loading the webconsole with devtools-launchpad, but will ultimately be
 // the entry point for the new frontend
+
 /**
  * A WebConsoleFrame instance is an interactive console initialized *per target*
  * that displays console log data as well as provides an interactive terminal to
  * manipulate the target's document content.
  *
  * The WebConsoleFrame is responsible for the actual Web Console UI
  * implementation.
  *
@@ -50,16 +54,29 @@ NewWebConsoleFrame.prototype = {
    * Getter for the debugger WebConsoleClient.
    * @type object
    */
   get webConsoleClient() {
     return this.proxy ? this.proxy.webConsoleClient : null;
   },
 
   /**
+   * Getter for the persistent logging preference.
+   * @type boolean
+   */
+  get persistLog() {
+    // For the browser console, we receive tab navigation
+    // when the original top level window we attached to is closed,
+    // but we don't want to reset console history and just switch to
+    // the next available window.
+    return this.isBrowserConsole ||
+           Services.prefs.getBoolPref(PREF_PERSISTLOG);
+  },
+
+  /**
    * Initialize the WebConsoleFrame instance.
    * @return object
    *         A promise object that resolves once the frame is ready to use.
    */
   init() {
     this._initUI();
     let connectionInited = this._initConnection();