Bug 1270011 - Check normalData.windows[0] exists before accessing tab count. r=margaret draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sun, 01 May 2016 22:11:17 +0200
changeset 363203 a5617314061fbdb763283b62a6a719552c1c2c41
parent 363202 0e29ccf9f04bf448e87a9767f4f0fa4c426ccfe6
child 519975 e7346886e0ae161d7b235f5e0845b88d49ee9242
push id17138
push usermozilla@buttercookie.de
push dateWed, 04 May 2016 07:40:08 +0000
reviewersmargaret
bugs1270011
milestone49.0a1
Bug 1270011 - Check normalData.windows[0] exists before accessing tab count. r=margaret There is no window in the normalData when clearing browsing history on quit with tab restore set to "never restore", which breaks the assumption made in the logging function. It also means that in that case, the current session will show up as "Tabs from last time" on next startup despite wanting to clear the history on exit. MozReview-Commit-ID: Ft4jdomopFL
mobile/android/components/SessionStore.js
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -657,18 +657,22 @@ SessionStore.prototype = {
         savedWin.tabs.push(tab);
         if (win.selected == i + 1) {
           savedWin.selected = savedWin.tabs.length;
         }
       }
     }
 
     // Write only non-private data to disk
-    log("_saveState() writing normal data, " +
-         normalData.windows[0].tabs.length + " tabs in window[0]");
+    if (normalData.windows[0] && normalData.windows[0].tabs) {
+      log("_saveState() writing normal data, " +
+           normalData.windows[0].tabs.length + " tabs in window[0]");
+    } else {
+      log("_saveState() writing empty normal data");
+    }
     this._writeFile(this._sessionFile, normalData, aAsync);
 
     // If we have private data, send it to Java; otherwise, send null to
     // indicate that there is no private data
     Messaging.sendRequest({
       type: "PrivateBrowsing:Data",
       session: (privateData.windows.length > 0 && privateData.windows[0].tabs.length > 0) ? JSON.stringify(privateData) : null
     });