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

--HG--
extra : rebase_source : ba0edd6ee121cc81d9e7c6e825e17844b26c730d
This commit is contained in:
Samael Wang 2017-08-11 14:49:09 +08:00
Родитель d281a28f21
Коммит 363b9e9d45
2 изменённых файлов: 10 добавлений и 7 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -927,7 +927,8 @@ protected:
int32_t mItemType;
// Index into the SHTransaction list, indicating the previous and current
// transaction at the time that this DocShell begins to load
// transaction at the time that this DocShell begins to load. Consequently
// root docshell's indices can differ from child docshells'.
int32_t mPreviousTransIndex;
int32_t mLoadedTransIndex;