Backed out changeset a399e91dd5c2 (bug 1729662) for causing wpt failures on cross-document-traversal-cross-document-traversal.html.

This commit is contained in:
Iulian Moraru
2021-09-28 19:14:02 +03:00
parent caf4295618
commit 82a9a640ee
12 changed files with 49 additions and 143 deletions

View File

@@ -1093,7 +1093,7 @@ void CanonicalBrowsingContext::HistoryGo(
// GoToIndex checks that index is >= 0 and < length.
nsTArray<nsSHistory::LoadEntryResult> 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)"));

View File

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

View File

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

View File

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

View File

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

View File

@@ -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<dom::LoadingSessionHistoryInfo>::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<dom::LoadingSessionHistoryInfo>::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;

View File

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

View File

@@ -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<LoadEntryResult> 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<LoadEntryResult>& 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<LoadEntryResult>& aLoadResults, bool aLoadCurrentEntry,
bool aUserActivation) {
nsTArray<LoadEntryResult>& 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<LoadEntryResult>& 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<LoadEntryResult>& 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<LoadEntryResult>& 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<SessionHistoryEntry> she = do_QueryInterface(aFrameEntry);

View File

@@ -165,8 +165,7 @@ class nsSHistory : public mozilla::LinkedListElement<nsSHistory>,
nsTArray<LoadEntryResult>& aLoadResults);
nsresult ReloadCurrentEntry(nsTArray<LoadEntryResult>& aLoadResults);
nsresult GotoIndex(int32_t aIndex, nsTArray<LoadEntryResult>& 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<nsSHistory>,
mozilla::dom::BrowsingContext* aParent,
long aLoadType,
nsTArray<LoadEntryResult>& aLoadResults,
bool aLoadCurrentEntry, bool aUserActivation);
bool aUserActivation);
void InitiateLoad(nsISHEntry* aFrameEntry,
mozilla::dom::BrowsingContext* aFrameBC, long aLoadType,
nsTArray<LoadEntryResult>& aLoadResult,
bool aLoadCurrentEntry, bool aUserActivation);
bool aUserActivation);
nsresult LoadEntry(int32_t aIndex, long aLoadType, uint32_t aHistCmd,
nsTArray<LoadEntryResult>& aLoadResults, bool aSameEpoch,
bool aLoadCurrentEntry, bool aUserActivation);
nsTArray<LoadEntryResult>& 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<nsSHistory>,
nsresult LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType,
uint32_t aHistCmd,
nsTArray<LoadEntryResult>& 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,

View File

@@ -1,8 +0,0 @@
<script>
addEventListener("load", () => {
(new BroadcastChannel("bug1729662")).postMessage("load");
history.pushState(1, null, location.href);
history.back();
history.forward();
});
</script>

View File

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

View File

@@ -1,76 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test back/forward after pushState</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<script>
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("Need to wait to make sure an event does not fire");
async function runTest() {
let win = window.open();
let goneBackAndForwardOnce = new Promise((resolve) => {
let timeoutID;
// We should only get one load event in win.
let bc = new BroadcastChannel("bug1729662");
bc.addEventListener("message", () => {
bc.addEventListener("message", () => {
clearTimeout(timeoutID);
resolve(false);
});
}, { once: true });
let goneBack = false, goneForward = false;
win.addEventListener("popstate", ({ state }) => {
// We should only go back and forward once, if we get another
// popstate after that then we should fall through to the
// failure case below.
if (!(goneBack && goneForward)) {
// Check if this is the popstate for the forward (the one for
// back will have state == undefined).
if (state == 1) {
ok(goneBack, "We should have gone back before going forward");
goneForward = true;
// Wait a bit to make sure there are no more popstate events.
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
timeoutID = setTimeout(resolve, 1000, true);
return;
}
// Check if we've gone back once before, if we get another
// popstate after that then we should fall through to the
// failure case below.
if (!goneBack) {
goneBack = true;
return;
}
}
clearTimeout(timeoutID);
resolve(false);
});
});
win.location = "file_bug1729662.html";
ok(await goneBackAndForwardOnce, "Stopped navigating history");
win.close();
SimpleTest.finish();
}
</script>
</head>
<body onload="runTest();">
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
</html>