Bug 1375833 - Part 2: Set mHistoryID to aSHEntry->DocshellID() in both reload and history navigation. r=smaug

The root cause of bug 1326845 is that reloading would apply frame history entries
without setting new child docshells' mHistoryID to the entrys' DocshellID.
So SHistory can not find corresponding entries for subframes in a consequent
GoBack(), and cause history navigation being broken (it would return
NS_ERROR_FAILURE).

MozReview-Commit-ID: 6syGYkoP1eZ
This commit is contained in:
Samael Wang
2017-08-11 14:49:09 +08:00
parent b565faea77
commit e8048bf88a
2 changed files with 10 additions and 7 deletions

View File

@@ -9928,8 +9928,9 @@ nsDocShell::InternalLoad(nsIURI* aURI,
isTargetTopLevelDocShell = true;
}
// If there's no targetDocShell, that means we are about to create a new window,
// perform a content policy check before creating the window.
// If there's no targetDocShell, that means we are about to create a new
// window (or aWindowTarget is empty). Perform a content policy check before
// creating the window.
if (!targetDocShell) {
nsCOMPtr<Element> requestingElement;
nsISupports* requestingContext = nullptr;
@@ -10741,16 +10742,17 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// mLSHE for the real page.
if (mLoadType != LOAD_ERROR_PAGE) {
SetHistoryEntry(&mLSHE, aSHEntry);
if (aSHEntry) {
// We're making history navigation or a reload. Make sure our history ID
// points to the same ID as SHEntry's docshell ID.
mHistoryID = aSHEntry->DocshellID();
}
}
mSavingOldViewer = savePresentation;
// If we have a saved content viewer in history, restore and show it now.
if (aSHEntry && (mLoadType & LOAD_CMD_HISTORY)) {
// Make sure our history ID points to the same ID as
// SHEntry's docshell ID.
mHistoryID = aSHEntry->DocshellID();
// It's possible that the previous viewer of mContentViewer is the
// viewer that will end up in aSHEntry when it gets closed. If that's
// the case, we need to go ahead and force it into its shentry so we