Bug 1742865 - Handle meta refresh correctly with session history in the parent. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D132837
This commit is contained in:
Peter Van der Beken
2021-12-16 08:19:45 +00:00
parent b8f03d5a65
commit 8e4b092406
10 changed files with 268 additions and 109 deletions

View File

@@ -3482,10 +3482,24 @@ bool BrowsingContext::IsPopupAllowed() {
return false;
}
/* static */
bool BrowsingContext::ShouldAddEntryForRefresh(
nsIURI* aCurrentURI, const SessionHistoryInfo& aInfo) {
if (aInfo.GetPostData()) {
return true;
}
bool equalsURI = false;
if (aCurrentURI) {
aCurrentURI->Equals(aInfo.GetURI(), &equalsURI);
}
return !equalsURI;
}
void BrowsingContext::SessionHistoryCommit(
const LoadingSessionHistoryInfo& aInfo, uint32_t aLoadType,
bool aHadActiveEntry, bool aPersist, bool aCloneEntryChildren,
bool aChannelExpired) {
nsIURI* aCurrentURI, bool aHadActiveEntry, bool aPersist,
bool aCloneEntryChildren, bool aChannelExpired) {
nsID changeID = {};
if (XRE_IsContentProcess()) {
RefPtr<ChildSHistory> rootSH = Top()->GetChildSessionHistory();
@@ -3495,13 +3509,17 @@ void BrowsingContext::SessionHistoryCommit(
// CanonicalBrowsingContext::SessionHistoryCommit. We'll be
// incrementing the session history length if we're not replacing,
// this is a top-level load or it's not the initial load in an iframe,
// and ShouldUpdateSessionHistory(loadType) returns true.
// ShouldUpdateSessionHistory(loadType) returns true and it's not a
// refresh for which ShouldAddEntryForRefresh returns false.
// It is possible that this leads to wrong length temporarily, but
// so would not having the check for replace.
if (!LOAD_TYPE_HAS_FLAGS(
aLoadType, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY) &&
(IsTop() || aHadActiveEntry) &&
ShouldUpdateSessionHistory(aLoadType)) {
ShouldUpdateSessionHistory(aLoadType) &&
(!LOAD_TYPE_HAS_FLAGS(aLoadType,
nsIWebNavigation::LOAD_FLAGS_IS_REFRESH) ||
ShouldAddEntryForRefresh(aCurrentURI, aInfo.mInfo))) {
changeID = rootSH->AddPendingHistoryChange();
}
} else {