Bug 1270011 - Check normalData.windows[0] exists before accessing tab count. r=margaret, a=lizzard
authorJan Henning <jh+bugzilla@buttercookie.de>
Sun, 01 May 2016 22:11:17 +0200
changeset 332811 2c40e21dafaa718d667bb2718f0f36f402b67614
parent 332810 00a32da7e4d6e85fdcf3618fb757d7cd8df4eefb
child 332812 4c5959b81fd5b61fe854f2d2e0743afa66f9aa07
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, lizzard
bugs1270011
milestone48.0a2
Bug 1270011 - Check normalData.windows[0] exists before accessing tab count. r=margaret, a=lizzard 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
@@ -640,18 +640,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
     });