Bug 1170226 - Restore correct shistory index when setting up pending tabs r=billm

This commit is contained in:
Tim Taubert 2015-06-01 19:18:59 +02:00
parent ec6faf1fd9
commit c924ea409f
4 changed files with 39 additions and 12 deletions

View File

@ -193,11 +193,6 @@ ContentRestoreInternal.prototype = {
if (loadArguments) {
// A load has been redirected to a new process so get history into the
// same state it was before the load started then trigger the load.
let activeIndex = tabData.index - 1;
if (activeIndex > 0) {
// Go to the right history entry, but don't load anything yet.
history.getEntryAtIndex(activeIndex, true);
}
let referrer = loadArguments.referrer ?
Utils.makeURI(loadArguments.referrer) : null;
let referrerPolicy = ('referrerPolicy' in loadArguments
@ -210,12 +205,6 @@ ContentRestoreInternal.prototype = {
// If the user typed a URL into the URL bar and hit enter right before
// we crashed, we want to start loading that page again. A non-zero
// userTypedClear value means that the load had started.
let activeIndex = tabData.index - 1;
if (activeIndex > 0) {
// Go to the right history entry, but don't load anything yet.
history.getEntryAtIndex(activeIndex, true);
}
// Load userTypedValue and fix up the URL if it's partial/broken.
webNavigation.loadURI(tabData.userTypedValue,
Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP,
@ -231,7 +220,6 @@ ContentRestoreInternal.prototype = {
// In order to work around certain issues in session history, we need to
// force session history to update its internal index and call reload
// instead of gotoIndex. See bug 597315.
history.getEntryAtIndex(activeIndex, true);
history.reloadCurrentEntry();
} else {
// If there's nothing to restore, we should still blank the page.

View File

@ -265,6 +265,12 @@ let SessionHistoryInternal = {
let persist = "persist" in entry ? entry.persist : true;
history.addEntry(this.deserializeEntry(entry, idMap, docIdentMap), persist);
}
// Select the right history entry.
let index = tabData.index - 1;
if (index < history.count && history.index != index) {
history.getEntryAtIndex(index, true);
}
},
/**

View File

@ -94,6 +94,7 @@ skip-if = buildapp == 'mulet'
[browser_merge_closed_tabs.js]
[browser_page_title.js]
[browser_pageStyle.js]
[browser_pending_tabs.js]
[browser_privatetabs.js]
[browser_replace_load.js]
[browser_restore_redirect.js]

View File

@ -0,0 +1,32 @@
"use strict";
const TAB_STATE = {
entries: [{ url: "about:mozilla" }, { url: "about:robots" }],
index: 1,
};
add_task(function* () {
// Create a background tab.
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// The tab shouldn't be restored right away.
Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
// Prepare the tab state.
let promise = promiseTabRestoring(tab);
ss.setTabState(tab, JSON.stringify(TAB_STATE));
ok(tab.hasAttribute("pending"), "tab is pending");
yield promise;
// Flush to ensure the parent has all data.
yield TabStateFlusher.flush(browser);
// Check that the shistory index is the one we restored.
let tabState = TabState.collect(tab);
is(tabState.index, TAB_STATE.index, "correct shistory index");
// Cleanup.
gBrowser.removeTab(tab);
});