Bug 457195 - nsSessionStartup::state not cleared with history, r=dietrich
authorSimon Bünzli <zeniko@gmail.com>
Sat, 11 Oct 2008 22:28:21 +0330
changeset 20316 3069ac5e6241fd29edd8623dbd15008227eec002
parent 20315 df62dc445ddccf154be2c3ec6990474d32269f47
child 20317 98f6214e28d0adf5cafba2ba58c7f5eec51c2d9e
push id2801
push userehsan.akhgari@gmail.com
push dateSat, 11 Oct 2008 18:58:46 +0000
treeherdermozilla-central@3069ac5e6241 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdietrich
bugs457195
milestone1.9.1b2pre
Bug 457195 - nsSessionStartup::state not cleared with history, r=dietrich
browser/components/sessionstore/src/nsSessionStartup.js
--- a/browser/components/sessionstore/src/nsSessionStartup.js
+++ b/browser/components/sessionstore/src/nsSessionStartup.js
@@ -136,16 +136,17 @@ SessionStartup.prototype = {
     else
       this._iniString = null; // reset the state string
 
     if (this._sessionType != Ci.nsISessionStartup.NO_SESSION) {
       // wait for the first browser window to open
       var observerService = Cc["@mozilla.org/observer-service;1"].
                             getService(Ci.nsIObserverService);
       observerService.addObserver(this, "domwindowopened", true);
+      observerService.addObserver(this, "browser:purge-session-history", true);
     }
   },
 
   /**
    * Handle notifications
    */
   observe: function sss_observe(aSubject, aTopic, aData) {
     var observerService = Cc["@mozilla.org/observer-service;1"].
@@ -169,16 +170,23 @@ SessionStartup.prototype = {
     case "domwindowopened":
       var window = aSubject;
       var self = this;
       window.addEventListener("load", function() {
         self._onWindowOpened(window);
         window.removeEventListener("load", arguments.callee, false);
       }, false);
       break;
+    case "browser:purge-session-history":
+      // reset all state on sanitization
+      this._iniString = null;
+      this._sessionType = Ci.nsISessionStartup.NO_SESSION;
+      // no need in repeating this, since startup state won't change
+      observerService.removeObserver(this, "browser:purge-session-history");
+      break;
     }
   },
 
   /**
    * Removes the default arguments from the first browser window
    * (and removes the "domwindowopened" observer afterwards).
    */
   _onWindowOpened: function sss_onWindowOpened(aWindow) {