Bug 1433523 - Disable Session Restore in Permanent PBM. r=mikedeboer
authorKathy Brade <brade@pearlcrescent.com>
Mon, 12 Feb 2018 22:08:00 +0200
changeset 404140 1bd07bb7833c6326d8d128dce9df6618431922ef
parent 404139 0be0607b050e9eeaff114166618b0e486dcaa79b
child 404141 114d2a3202c0ddf706461952d63a14d35611f734
push id99941
push usernbeleuzu@mozilla.com
push dateFri, 16 Feb 2018 11:04:15 +0000
treeherdermozilla-inbound@287ae6668ed2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1433523, 18292
milestone60.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 1433523 - Disable Session Restore in Permanent PBM. r=mikedeboer When in permanent private browsing mode, always return false for isAutomaticRestoreEnabled. This ensures that there will not be any confusion inside nsBrowserContentHandler.defaultArgs as to whether a one time session restore will occur. Also, for consistency and in case someone looks at the pref, avoid setting browser.sessionstore.resume_session = true during browser shutdown. This bug occurred when staging was not used during the update process. On Windows it always occurred because staging is not used even when it should be (https://trac.torproject.org/18292).
browser/components/nsBrowserGlue.js
browser/components/sessionstore/SessionStore.jsm
browser/components/sessionstore/nsSessionStartup.js
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -310,17 +310,19 @@ BrowserGlue.prototype = {
   _saveSession: false,
   _migrationImportsDefaultBookmarks: false,
   _placesBrowserInitComplete: false,
 
   _setPrefToSaveSession: function BG__setPrefToSaveSession(aForce) {
     if (!this._saveSession && !aForce)
       return;
 
-    Services.prefs.setBoolPref("browser.sessionstore.resume_session_once", true);
+    if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
+      Services.prefs.setBoolPref("browser.sessionstore.resume_session_once", true);
+    }
 
     // This method can be called via [NSApplication terminate:] on Mac, which
     // ends up causing prefs not to be flushed to disk, so we need to do that
     // explicitly here. See bug 497652.
     Services.prefs.savePrefFile(null);
   },
 
   _setSyncAutoconnectDelay: function BG__setSyncAutoconnectDelay() {
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -1714,17 +1714,20 @@ var SessionStoreInternal = {
 
   /**
    * On quitting application
    * @param aData
    *        String type of quitting
    */
   onQuitApplication: function ssi_onQuitApplication(aData) {
     if (aData == "restart") {
-      this._prefBranch.setBoolPref("sessionstore.resume_session_once", true);
+      if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
+        this._prefBranch.setBoolPref("sessionstore.resume_session_once", true);
+      }
+
       // The browser:purge-session-history notification fires after the
       // quit-application notification so unregister the
       // browser:purge-session-history notification to prevent clearing
       // session data on disk on a restart.  It is also unnecessary to
       // perform any other sanitization processing on a restart as the
       // browser is about to exit anyway.
       Services.obs.removeObserver(this, "browser:purge-session-history");
     }
--- a/browser/components/sessionstore/nsSessionStartup.js
+++ b/browser/components/sessionstore/nsSessionStartup.js
@@ -291,16 +291,20 @@ SessionStartup.prototype = {
   /**
    * Determines whether automatic session restoration is enabled for this
    * launch of the browser. This does not include crash restoration. In
    * particular, if session restore is configured to restore only in case of
    * crash, this method returns false.
    * @returns bool
    */
   isAutomaticRestoreEnabled() {
+    if (PrivateBrowsingUtils.permanentPrivateBrowsing) {
+      return false;
+    }
+
     return Services.prefs.getBoolPref("browser.sessionstore.resume_session_once") ||
            Services.prefs.getIntPref("browser.startup.page") == BROWSER_STARTUP_RESUME_SESSION;
   },
 
   /**
    * Determines whether there is a pending session restore.
    * @returns bool
    */