Bug 1035557 - "about:sessionrestore shows instead of about:welcomeback after a reset". r=smacleod, a=sledru
authorDavid Rajchenbach-Teller <dteller@mozilla.com>
Tue, 08 Jul 2014 05:58:00 +0200
changeset 208118 23ad26e7e8d3960684525cce93d9a3c2d84757ea
parent 208117 4e4056fa74af476cc5ca11966d39a4b7a95bfe8f
child 208119 fdcf90ace4a596d74843ed31c2a8eef1f412c8d4
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmacleod, sledru
bugs1035557
milestone32.0a2
Bug 1035557 - "about:sessionrestore shows instead of about:welcomeback after a reset". r=smacleod, a=sledru
browser/components/sessionstore/src/nsSessionStartup.js
--- a/browser/components/sessionstore/src/nsSessionStartup.js
+++ b/browser/components/sessionstore/src/nsSessionStartup.js
@@ -143,34 +143,41 @@ SessionStartup.prototype = {
       if (checkpoints) {
         // If the previous session finished writing the final state, we'll
         // assume there was no crash.
         this._previousSessionCrashed = !checkpoints["sessionstore-final-state-write-complete"];
       } else {
         // If the Crash Monitor could not load a checkpoints file it will
         // provide null. This could occur on the first run after updating to
         // a version including the Crash Monitor, or if the checkpoints file
-        // was removed.
-        //
-        // If this is the first run after an update, sessionstore.js should
-        // still contain the session.state flag to indicate if the session
-        // crashed. If it is not present, we will assume this was not the first
-        // run after update and the checkpoints file was somehow corrupted or
-        // removed by a crash.
-        //
-        // If the session.state flag is present, we will fallback to using it
-        // for crash detection - If the last write of sessionstore.js had it
-        // set to "running", we crashed.
-        let stateFlagPresent = (this._initialState &&
-                                this._initialState.session &&
-                                this._initialState.session.state);
+        // was removed, or on first startup with this profile, or after Firefox Reset.
+
+        if (!this._initialState) {
+          // We have neither sessionstore.js nor a checkpoints file,
+          // assume that this is a first startup with the profile or after
+          // Firefox Reset.
+          this._previousSessionCrashed = false;
+
+        } else {
+          // If this is the first run after an update, sessionstore.js should
+          // still contain the session.state flag to indicate if the session
+          // crashed. If it is not present, we will assume this was not the first
+          // run after update and the checkpoints file was somehow corrupted or
+          // removed by a crash.
+          //
+          // If the session.state flag is present, we will fallback to using it
+          // for crash detection - If the last write of sessionstore.js had it
+          // set to "running", we crashed.
+          let stateFlagPresent = (this._initialState.session &&
+                                  this._initialState.session.state);
 
 
-        this._previousSessionCrashed = !stateFlagPresent ||
-                                       (this._initialState.session.state == STATE_RUNNING_STR);
+          this._previousSessionCrashed = !stateFlagPresent ||
+            (this._initialState.session.state == STATE_RUNNING_STR);
+        }
       }
 
       // Report shutdown success via telemetry. Shortcoming here are
       // being-killed-by-OS-shutdown-logic, shutdown freezing after
       // session restore was written, etc.
       Services.telemetry.getHistogramById("SHUTDOWN_OK").add(!this._previousSessionCrashed);
 
       // set the startup type