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
--- 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
});