Backed out changeset 4a496e6b99af (bug 867097)

This commit is contained in:
Tim Taubert 2013-05-24 15:28:29 +02:00
parent be92a4b097
commit 9209d1586d
3 changed files with 29 additions and 6 deletions

View File

@ -1055,6 +1055,7 @@ let SessionStoreInternal = {
this._forEachBrowserWindow(function(aWindow) {
Array.forEach(aWindow.gBrowser.tabs, function(aTab) {
delete aTab.linkedBrowser.__SS_data;
delete aTab.linkedBrowser.__SS_tabStillLoading;
delete aTab.linkedBrowser.__SS_formDataSaved;
delete aTab.linkedBrowser.__SS_hostSchemeData;
if (aTab.linkedBrowser.__SS_restoreState)
@ -1246,6 +1247,7 @@ let SessionStoreInternal = {
MESSAGES.forEach(msg => mm.removeMessageListener(msg, this));
delete browser.__SS_data;
delete browser.__SS_tabStillLoading;
delete browser.__SS_formDataSaved;
delete browser.__SS_hostSchemeData;
@ -1323,6 +1325,7 @@ let SessionStoreInternal = {
}
delete aBrowser.__SS_data;
delete aBrowser.__SS_tabStillLoading;
delete aBrowser.__SS_formDataSaved;
this.saveStateDelayed(aWindow);
@ -1890,7 +1893,7 @@ let SessionStoreInternal = {
if (!browser || !browser.currentURI)
// can happen when calling this function right after .addTab()
return tabData;
else if (browser.__SS_data) {
else if (browser.__SS_data && browser.__SS_tabStillLoading) {
// use the data to be restored when the tab hasn't been completely loaded
tabData = browser.__SS_data;
if (aTab.pinned)
@ -1915,7 +1918,16 @@ let SessionStoreInternal = {
}
catch (ex) { } // this could happen if we catch a tab during (de)initialization
if (history && history.count > 0) {
// XXXzeniko anchor navigation doesn't reset __SS_data, so we could reuse
// data even when we shouldn't (e.g. Back, different anchor)
if (history && browser.__SS_data &&
browser.__SS_data.entries[history.index] &&
browser.__SS_data.entries[history.index].url == browser.currentURI.spec &&
history.index < this._sessionhistory_max_entries - 1 && !aFullData) {
tabData = browser.__SS_data;
tabData.index = history.index + 1;
}
else if (history && history.count > 0) {
browser.__SS_hostSchemeData = [];
try {
for (var j = 0; j < history.count; j++) {
@ -1944,6 +1956,10 @@ let SessionStoreInternal = {
}
}
tabData.index = history.index + 1;
// make sure not to cache privacy sensitive data which shouldn't get out
if (!aFullData)
browser.__SS_data = tabData;
}
else if (browser.currentURI.spec != "about:blank" ||
browser.contentDocument.body.hasChildNodes()) {
@ -2171,7 +2187,7 @@ let SessionStoreInternal = {
_updateTextAndScrollDataForTab:
function ssi_updateTextAndScrollDataForTab(aWindow, aBrowser, aTabData, aFullData) {
// we shouldn't update data for incompletely initialized tabs
if (aBrowser.__SS_data)
if (aBrowser.__SS_data && aBrowser.__SS_tabStillLoading)
return;
var tabIndex = (aTabData.index || aTabData.entries.length) - 1;
@ -2977,6 +2993,8 @@ let SessionStoreInternal = {
Object.keys(tabData.attributes).forEach(a => TabAttributes.persist(a));
}
browser.__SS_tabStillLoading = true;
// keep the data around to prevent dataloss in case
// a tab gets closed before it's been properly restored
browser.__SS_data = tabData;
@ -4093,13 +4111,15 @@ let SessionStoreInternal = {
/**
* Determine if we can restore history into this tab.
* This will be false when a tab has been removed (usually between
* restoreHistoryPrecursor && restoreHistory).
* restoreHistoryPrecursor && restoreHistory) or if the tab is still marked
* as loading.
*
* @param aTab
* @returns boolean
*/
_canRestoreTabHistory: function ssi_canRestoreTabHistory(aTab) {
return aTab.parentNode && aTab.linkedBrowser;
return aTab.parentNode && aTab.linkedBrowser &&
aTab.linkedBrowser.__SS_tabStillLoading;
},
/**

View File

@ -17,7 +17,9 @@ function test() {
// Undo pinning
gBrowser.unpinTab(tab1);
ok("__SS_data" in tab1.linkedBrowser, "tab should still be loading");
is(tab1.linkedBrowser.__SS_tabStillLoading, true,
"_tabStillLoading should be true.");
// Close and restore tab
gBrowser.removeTab(tab1);

View File

@ -39,6 +39,7 @@ function firstOnLoad(aEvent) {
ss.getBrowserState();
is(gBrowser.tabs[1], tab, "newly created tab should exist by now");
ok(tab.linkedBrowser.__SS_data, "newly created tab should be in save state");
tab.linkedBrowser.loadURI(URI_TO_LOAD);
}