diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 59a27f7e799b..85d0099c0bcc 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -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 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 diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 83b73c5fa067..3399c4b73118 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -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;