diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp index 7881614a36cb..e3e818268649 100644 --- a/docshell/base/CanonicalBrowsingContext.cpp +++ b/docshell/base/CanonicalBrowsingContext.cpp @@ -1093,7 +1093,7 @@ void CanonicalBrowsingContext::HistoryGo( // GoToIndex checks that index is >= 0 and < length. nsTArray loadResults; nsresult rv = shistory->GotoIndex(index.value(), loadResults, sameEpoch, - aOffset == 0, aUserActivation); + aUserActivation); if (NS_FAILED(rv)) { MOZ_LOG(gSHLog, LogLevel::Debug, ("Dropping HistoryGo - bad index or same epoch (not in same doc)")); diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 6c7add59230d..c6990219a465 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -8636,7 +8636,7 @@ bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState, } if (aState.mHistoryNavBetweenSameDoc && - !aLoadState->GetLoadingSessionHistoryInfo()->mLoadingCurrentEntry) { + !aLoadState->GetLoadingSessionHistoryInfo()->mLoadingCurrentActiveEntry) { return true; } @@ -11751,12 +11751,13 @@ nsresult nsDocShell::LoadHistoryEntry(const LoadingSessionHistoryInfo& aEntry, loadState->SetHasValidUserGestureActivation( loadState->HasValidUserGestureActivation() || aUserActivation); - return LoadHistoryEntry(loadState, aLoadType, aEntry.mLoadingCurrentEntry); + return LoadHistoryEntry(loadState, aLoadType, + aEntry.mLoadingCurrentActiveEntry); } nsresult nsDocShell::LoadHistoryEntry(nsDocShellLoadState* aLoadState, uint32_t aLoadType, - bool aLoadingCurrentEntry) { + bool aReloadingActiveEntry) { if (!IsNavigationAllowed()) { return NS_OK; } @@ -11777,7 +11778,7 @@ nsresult nsDocShell::LoadHistoryEntry(nsDocShellLoadState* aLoadState, rv = CreateAboutBlankContentViewer( aLoadState->PrincipalToInherit(), aLoadState->PartitionedPrincipalToInherit(), nullptr, nullptr, - /* aIsInitialDocument */ false, Nothing(), !aLoadingCurrentEntry); + /* aIsInitialDocument */ false, Nothing(), !aReloadingActiveEntry); if (NS_FAILED(rv)) { // The creation of the intermittent about:blank content diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 113106c22768..dab7bd4ac4ec 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -987,7 +987,7 @@ class nsDocShell final : public nsDocLoader, const mozilla::dom::LoadingSessionHistoryInfo& aEntry, uint32_t aLoadType, bool aUserActivation); nsresult LoadHistoryEntry(nsDocShellLoadState* aLoadState, uint32_t aLoadType, - bool aLoadingCurrentEntry); + bool aReloadingActiveEntry); nsresult GetHttpChannel(nsIChannel* aChannel, nsIHttpChannel** aReturn); nsresult ConfirmRepost(bool* aRepost); nsresult GetPromptAndStringBundle(nsIPrompt** aPrompt, diff --git a/docshell/base/nsDocShellLoadState.cpp b/docshell/base/nsDocShellLoadState.cpp index f6e2da2a77f2..fea0e2485901 100644 --- a/docshell/base/nsDocShellLoadState.cpp +++ b/docshell/base/nsDocShellLoadState.cpp @@ -557,12 +557,13 @@ nsDocShellLoadState::GetLoadingSessionHistoryInfo() const { void nsDocShellLoadState::SetLoadIsFromSessionHistory( int32_t aRequestedIndex, int32_t aSessionHistoryLength, - bool aLoadingCurrentEntry) { + bool aLoadingFromActiveEntry) { if (mLoadingSessionHistoryInfo) { mLoadingSessionHistoryInfo->mLoadIsFromSessionHistory = true; mLoadingSessionHistoryInfo->mRequestedIndex = aRequestedIndex; mLoadingSessionHistoryInfo->mSessionHistoryLength = aSessionHistoryLength; - mLoadingSessionHistoryInfo->mLoadingCurrentEntry = aLoadingCurrentEntry; + mLoadingSessionHistoryInfo->mLoadingCurrentActiveEntry = + aLoadingFromActiveEntry; } } diff --git a/docshell/base/nsDocShellLoadState.h b/docshell/base/nsDocShellLoadState.h index 3b18746b551d..fa0836bf49e8 100644 --- a/docshell/base/nsDocShellLoadState.h +++ b/docshell/base/nsDocShellLoadState.h @@ -328,7 +328,7 @@ class nsDocShellLoadState final { void SetLoadIsFromSessionHistory(int32_t aRequestedIndex, int32_t aSessionHistoryLength, - bool aLoadingCurrentEntry); + bool aLoadingFromActiveEntry); void ClearLoadIsFromSessionHistory(); void MaybeStripTrackerQueryStrings(mozilla::dom::BrowsingContext* aContext, diff --git a/docshell/shistory/SessionHistoryEntry.cpp b/docshell/shistory/SessionHistoryEntry.cpp index 301f9d9122a9..925b8e0c40b4 100644 --- a/docshell/shistory/SessionHistoryEntry.cpp +++ b/docshell/shistory/SessionHistoryEntry.cpp @@ -351,7 +351,7 @@ LoadingSessionHistoryInfo::LoadingSessionHistoryInfo( mLoadIsFromSessionHistory(aInfo->mLoadIsFromSessionHistory), mRequestedIndex(aInfo->mRequestedIndex), mSessionHistoryLength(aInfo->mSessionHistoryLength), - mLoadingCurrentEntry(aInfo->mLoadingCurrentEntry) { + mLoadingCurrentActiveEntry(aInfo->mLoadingCurrentActiveEntry) { MOZ_ASSERT(SessionHistoryEntry::sLoadIdToEntry && SessionHistoryEntry::sLoadIdToEntry->Get(mLoadId) == aEntry); } @@ -1588,7 +1588,7 @@ void IPDLParamTraits::Write( WriteIPDLParam(aMsg, aActor, aParam.mLoadIsFromSessionHistory); WriteIPDLParam(aMsg, aActor, aParam.mRequestedIndex); WriteIPDLParam(aMsg, aActor, aParam.mSessionHistoryLength); - WriteIPDLParam(aMsg, aActor, aParam.mLoadingCurrentEntry); + WriteIPDLParam(aMsg, aActor, aParam.mLoadingCurrentActiveEntry); WriteIPDLParam(aMsg, aActor, aParam.mForceMaybeResetName); } @@ -1601,7 +1601,8 @@ bool IPDLParamTraits::Read( &aResult->mLoadIsFromSessionHistory) || !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRequestedIndex) || !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSessionHistoryLength) || - !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mLoadingCurrentEntry) || + !ReadIPDLParam(aMsg, aIter, aActor, + &aResult->mLoadingCurrentActiveEntry) || !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mForceMaybeResetName)) { aActor->FatalError("Error reading fields for LoadingSessionHistoryInfo"); return false; diff --git a/docshell/shistory/SessionHistoryEntry.h b/docshell/shistory/SessionHistoryEntry.h index 538c7b4e08e6..a05fa42a2a94 100644 --- a/docshell/shistory/SessionHistoryEntry.h +++ b/docshell/shistory/SessionHistoryEntry.h @@ -229,13 +229,13 @@ struct LoadingSessionHistoryInfo { // but session-history-in-parent needs to pass needed information explicitly // to the relevant child process. bool mLoadIsFromSessionHistory = false; - // mRequestedIndex, mSessionHistoryLength and mLoadingCurrentEntry are + // mRequestedIndex, mSessionHistoryLength and mLoadingCurrentActiveEntry are // relevant only if mLoadIsFromSessionHistory is true. int32_t mRequestedIndex = -1; int32_t mSessionHistoryLength = 0; - // If we're loading from the current entry we want to treat it as not a - // same-document navigation (see nsDocShell::IsSameDocumentNavigation). - bool mLoadingCurrentEntry = false; + // If we're loading from the current active entry we want to treat it as not + // a same-document navigation (see nsDocShell::IsSameDocumentNavigation). + bool mLoadingCurrentActiveEntry = false; // If mForceMaybeResetName.isSome() is true then the parent process has // determined whether the BC's name should be cleared and stored in session // history (see https://html.spec.whatwg.org/#history-traversal step 4.2). diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp index f9dc5146dbad..3996a3a68aa7 100644 --- a/docshell/shistory/nsSHistory.cpp +++ b/docshell/shistory/nsSHistory.cpp @@ -1404,8 +1404,7 @@ nsresult nsSHistory::Reload(uint32_t aReloadFlags, } nsresult rv = LoadEntry( - mIndex, loadType, HIST_CMD_RELOAD, aLoadResults, /* aSameEpoch */ false, - /* aLoadCurrentEntry */ true, + mIndex, loadType, HIST_CMD_RELOAD, aLoadResults, /*aSameEpoch*/ false, aReloadFlags & nsIWebNavigation::LOAD_FLAGS_USER_ACTIVATION); if (NS_FAILED(rv)) { aLoadResults.Clear(); @@ -1430,9 +1429,7 @@ nsresult nsSHistory::ReloadCurrentEntry( // Notify listeners NOTIFY_LISTENERS(OnHistoryGotoIndex, ()); - return LoadEntry(mIndex, LOAD_HISTORY, HIST_CMD_RELOAD, aLoadResults, - /* aSameEpoch */ false, /* aLoadCurrentEntry */ true, - /* aUserActivation */ false); + return LoadEntry(mIndex, LOAD_HISTORY, HIST_CMD_RELOAD, aLoadResults); } void nsSHistory::EvictOutOfRangeWindowContentViewers(int32_t aIndex) { @@ -1967,8 +1964,8 @@ nsSHistory::UpdateIndex() { NS_IMETHODIMP nsSHistory::GotoIndex(int32_t aIndex, bool aUserActivation) { nsTArray loadResults; - nsresult rv = GotoIndex(aIndex, loadResults, /*aSameEpoch*/ false, - aIndex == mIndex, aUserActivation); + nsresult rv = + GotoIndex(aIndex, loadResults, /*aSameEpoch*/ false, aUserActivation); NS_ENSURE_SUCCESS(rv, rv); LoadURIs(loadResults); @@ -1985,10 +1982,9 @@ nsSHistory::EnsureCorrectEntryAtCurrIndex(nsISHEntry* aEntry) { nsresult nsSHistory::GotoIndex(int32_t aIndex, nsTArray& aLoadResults, - bool aSameEpoch, bool aLoadCurrentEntry, - bool aUserActivation) { + bool aSameEpoch, bool aUserActivation) { return LoadEntry(aIndex, LOAD_HISTORY, HIST_CMD_GOTOINDEX, aLoadResults, - aSameEpoch, aLoadCurrentEntry, aUserActivation); + aSameEpoch, aUserActivation); } NS_IMETHODIMP_(bool) @@ -2003,16 +1999,15 @@ nsSHistory::HasUserInteractionAtIndex(int32_t aIndex) { nsresult nsSHistory::LoadNextPossibleEntry( int32_t aNewIndex, long aLoadType, uint32_t aHistCmd, - nsTArray& aLoadResults, bool aLoadCurrentEntry, - bool aUserActivation) { + nsTArray& aLoadResults, bool aUserActivation) { mRequestedIndex = -1; if (aNewIndex < mIndex) { return LoadEntry(aNewIndex - 1, aLoadType, aHistCmd, aLoadResults, - /*aSameEpoch*/ false, aLoadCurrentEntry, aUserActivation); + /*aSameEpoch*/ false, aUserActivation); } if (aNewIndex > mIndex) { return LoadEntry(aNewIndex + 1, aLoadType, aHistCmd, aLoadResults, - /*aSameEpoch*/ false, aLoadCurrentEntry, aUserActivation); + /*aSameEpoch*/ false, aUserActivation); } return NS_ERROR_FAILURE; } @@ -2020,8 +2015,7 @@ nsresult nsSHistory::LoadNextPossibleEntry( nsresult nsSHistory::LoadEntry(int32_t aIndex, long aLoadType, uint32_t aHistCmd, nsTArray& aLoadResults, - bool aSameEpoch, bool aLoadCurrentEntry, - bool aUserActivation) { + bool aSameEpoch, bool aUserActivation) { MOZ_LOG(gSHistoryLog, LogLevel::Debug, ("LoadEntry(%d, 0x%lx, %u)", aIndex, aLoadType, aHistCmd)); if (!mRootBC) { @@ -2091,19 +2085,17 @@ nsresult nsSHistory::LoadEntry(int32_t aIndex, long aLoadType, if (mRequestedIndex == mIndex) { // Possibly a reload case - InitiateLoad(nextEntry, mRootBC, aLoadType, aLoadResults, aLoadCurrentEntry, - aUserActivation); + InitiateLoad(nextEntry, mRootBC, aLoadType, aLoadResults, aUserActivation); return NS_OK; } // Going back or forward. - bool differenceFound = - LoadDifferingEntries(prevEntry, nextEntry, mRootBC, aLoadType, - aLoadResults, aLoadCurrentEntry, aUserActivation); + bool differenceFound = LoadDifferingEntries( + prevEntry, nextEntry, mRootBC, aLoadType, aLoadResults, aUserActivation); if (!differenceFound) { // We did not find any differences. Go further in the history. return LoadNextPossibleEntry(aIndex, aLoadType, aHistCmd, aLoadResults, - aLoadCurrentEntry, aUserActivation); + aUserActivation); } return NS_OK; @@ -2113,7 +2105,6 @@ bool nsSHistory::LoadDifferingEntries(nsISHEntry* aPrevEntry, nsISHEntry* aNextEntry, BrowsingContext* aParent, long aLoadType, nsTArray& aLoadResults, - bool aLoadCurrentEntry, bool aUserActivation) { MOZ_ASSERT(aPrevEntry && aNextEntry && aParent); @@ -2124,8 +2115,7 @@ bool nsSHistory::LoadDifferingEntries(nsISHEntry* aPrevEntry, if (prevID != nextID) { // Set the Subframe flag if not navigating the root docshell. aNextEntry->SetIsSubFrame(aParent != mRootBC); - InitiateLoad(aNextEntry, aParent, aLoadType, aLoadResults, - aLoadCurrentEntry, aUserActivation); + InitiateLoad(aNextEntry, aParent, aLoadType, aLoadResults, aUserActivation); return true; } @@ -2184,7 +2174,7 @@ bool nsSHistory::LoadDifferingEntries(nsISHEntry* aPrevEntry, // This will either load a new page to shell or some subshell or // do nothing. if (LoadDifferingEntries(pChild, nChild, bcChild, aLoadType, aLoadResults, - aLoadCurrentEntry, aUserActivation)) { + aUserActivation)) { differenceFound = true; } } @@ -2194,7 +2184,7 @@ bool nsSHistory::LoadDifferingEntries(nsISHEntry* aPrevEntry, void nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry, BrowsingContext* aFrameBC, long aLoadType, nsTArray& aLoadResults, - bool aLoadCurrentEntry, bool aUserActivation) { + bool aUserActivation) { MOZ_ASSERT(aFrameBC && aFrameEntry); LoadEntryResult* loadResult = aLoadResults.AppendElement(); @@ -2215,19 +2205,20 @@ void nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry, loadState->SetSHEntry(aFrameEntry); - // If we're loading the current entry we want to treat it as not a - // same-document navigation (see nsDocShell::IsSameDocumentNavigation), so + // If we're loading from the current active entry we want to treat it as not + // a same-document navigation (see nsDocShell::IsSameDocumentNavigation), so // record that here in the LoadingSessionHistoryEntry. - bool loadingCurrentEntry; + bool loadingFromActiveEntry; if (mozilla::SessionHistoryInParent()) { - loadingCurrentEntry = aLoadCurrentEntry; + loadingFromActiveEntry = + aFrameBC->Canonical()->GetActiveSessionHistoryEntry() == aFrameEntry; } else { - loadingCurrentEntry = + loadingFromActiveEntry = aFrameBC->GetDocShell() && nsDocShell::Cast(aFrameBC->GetDocShell())->IsOSHE(aFrameEntry); } loadState->SetLoadIsFromSessionHistory(mRequestedIndex, Length(), - loadingCurrentEntry); + loadingFromActiveEntry); if (mozilla::SessionHistoryInParent()) { nsCOMPtr she = do_QueryInterface(aFrameEntry); diff --git a/docshell/shistory/nsSHistory.h b/docshell/shistory/nsSHistory.h index 771661c5be1f..2bf059847dfe 100644 --- a/docshell/shistory/nsSHistory.h +++ b/docshell/shistory/nsSHistory.h @@ -165,8 +165,7 @@ class nsSHistory : public mozilla::LinkedListElement, nsTArray& aLoadResults); nsresult ReloadCurrentEntry(nsTArray& aLoadResults); nsresult GotoIndex(int32_t aIndex, nsTArray& aLoadResults, - bool aSameEpoch, bool aLoadCurrentEntry, - bool aUserActivation); + bool aSameEpoch = false, bool aUserActivation = false); void WindowIndices(int32_t aIndex, int32_t* aOutStartIndex, int32_t* aOutEndIndex); @@ -223,15 +222,15 @@ class nsSHistory : public mozilla::LinkedListElement, mozilla::dom::BrowsingContext* aParent, long aLoadType, nsTArray& aLoadResults, - bool aLoadCurrentEntry, bool aUserActivation); + bool aUserActivation); void InitiateLoad(nsISHEntry* aFrameEntry, mozilla::dom::BrowsingContext* aFrameBC, long aLoadType, nsTArray& aLoadResult, - bool aLoadCurrentEntry, bool aUserActivation); + bool aUserActivation); nsresult LoadEntry(int32_t aIndex, long aLoadType, uint32_t aHistCmd, - nsTArray& aLoadResults, bool aSameEpoch, - bool aLoadCurrentEntry, bool aUserActivation); + nsTArray& aLoadResults, + bool aSameEpoch = false, bool aUserActivation = false); // Find the history entry for a given bfcache entry. It only looks up between // the range where alive viewers may exist (i.e nsSHistory::VIEWER_WINDOW). @@ -252,7 +251,7 @@ class nsSHistory : public mozilla::LinkedListElement, nsresult LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType, uint32_t aHistCmd, nsTArray& aLoadResults, - bool aLoadCurrentEntry, bool aUserActivation); + bool aUserActivation); // aIndex is the index of the entry which may be removed. // If aKeepNext is true, aIndex is compared to aIndex + 1, diff --git a/docshell/test/mochitest/file_bug1729662.html b/docshell/test/mochitest/file_bug1729662.html deleted file mode 100644 index f5710e1c496c..000000000000 --- a/docshell/test/mochitest/file_bug1729662.html +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/docshell/test/mochitest/mochitest.ini b/docshell/test/mochitest/mochitest.ini index 1501867d613e..cea63f080117 100644 --- a/docshell/test/mochitest/mochitest.ini +++ b/docshell/test/mochitest/mochitest.ini @@ -109,9 +109,6 @@ support-files = file_bug675587.html [test_bug1151421.html] [test_bug1186774.html] [test_bug1450164.html] -[test_bug1729662.html] -support-files = - file_bug1729662.html [test_close_onpagehide_by_history_back.html] [test_close_onpagehide_by_window_close.html] [test_compressed_multipart.html] diff --git a/docshell/test/mochitest/test_bug1729662.html b/docshell/test/mochitest/test_bug1729662.html deleted file mode 100644 index ec4350849461..000000000000 --- a/docshell/test/mochitest/test_bug1729662.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - Test back/forward after pushState - - - - - -

- -

-
-