Revert "Bug 1966658 - Populate the partitionedPrincipal to the SessionHistoryEntry in the parent process. r=smaug,sessionstore-reviewers,core-sessionstore-reviewers,farre"
This reverts commit 52c31c4da0.
This commit is contained in:
committed by
amarc@mozilla.com
parent
e497194fb3
commit
2b5b645133
@@ -289,8 +289,6 @@ run-if = ["fission"]
|
||||
|
||||
["browser_searchModeSwitcher_restore.js"]
|
||||
|
||||
["browser_sessionHistory_partitionedPrincipalToInherit.js"]
|
||||
|
||||
["browser_sessionHistory.js"]
|
||||
https_first_disabled = true
|
||||
support-files = ["file_sessionHistory_hashchange.html"]
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test_partitioned_principal_to_inherit() {
|
||||
if (!Services.appinfo.sessionHistoryInParent) {
|
||||
ok(true, "sessionHistoryInParent is not enabled, skipping the test.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new tab.
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
"https://example.com"
|
||||
);
|
||||
let browser = tab.linkedBrowser;
|
||||
|
||||
// Get the last entry in the session history.
|
||||
let sh = browser.browsingContext.sessionHistory;
|
||||
let entry = sh.getEntryAtIndex(sh.count - 1);
|
||||
let partitionedPrincipalToInherit = entry.partitionedPrincipalToInherit;
|
||||
|
||||
// Check that the partitioned principal to inherit is properly set.
|
||||
ok(partitionedPrincipalToInherit, "partitionedPrincipalToInherit is set");
|
||||
is(
|
||||
partitionedPrincipalToInherit.originAttributes.partitionKey,
|
||||
"(https,example.com)",
|
||||
"correct partitionKey"
|
||||
);
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
add_task(async function test_partitioned_Principal_to_inherit_in_iframe() {
|
||||
if (!Services.appinfo.sessionHistoryInParent) {
|
||||
ok(true, "sessionHistoryInParent is not enabled, skipping the test.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new tab.
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
"https://example.com"
|
||||
);
|
||||
let browser = tab.linkedBrowser;
|
||||
|
||||
// Load a same-origin iframe
|
||||
await SpecialPowers.spawn(browser, [], async _ => {
|
||||
let iframe = content.document.createElement("iframe");
|
||||
iframe.src = "https://example.com";
|
||||
|
||||
await new content.Promise(resolve => {
|
||||
iframe.onload = resolve;
|
||||
content.document.body.appendChild(iframe);
|
||||
});
|
||||
});
|
||||
|
||||
// Get the last child entry in the session history for the same-origin iframe.
|
||||
let sh = browser.browsingContext.sessionHistory;
|
||||
let entry = sh.getEntryAtIndex(sh.count - 1);
|
||||
let childEntry = entry.GetChildAt(entry.childCount - 1);
|
||||
let partitionedPrincipalToInherit = childEntry.partitionedPrincipalToInherit;
|
||||
|
||||
// Check that the partitioned principal to inherit is properly set.
|
||||
ok(partitionedPrincipalToInherit, "partitionedPrincipalToInherit is set");
|
||||
is(
|
||||
partitionedPrincipalToInherit.originNoSuffix,
|
||||
"https://example.com",
|
||||
"correct originNoSuffix in the same-origin iframe"
|
||||
);
|
||||
is(
|
||||
partitionedPrincipalToInherit.originAttributes.partitionKey,
|
||||
"(https,example.com)",
|
||||
"correct partitionKey in the same-origin iframe"
|
||||
);
|
||||
|
||||
// Load a cross-site iframe.
|
||||
await SpecialPowers.spawn(browser, [], async _ => {
|
||||
let iframe = content.document.createElement("iframe");
|
||||
iframe.src = "https://example.net";
|
||||
|
||||
await new content.Promise(resolve => {
|
||||
iframe.onload = resolve;
|
||||
content.document.body.appendChild(iframe);
|
||||
});
|
||||
});
|
||||
|
||||
// Get the last child entry in the session history for the cross-site iframe.
|
||||
entry = sh.getEntryAtIndex(sh.count - 1);
|
||||
childEntry = entry.GetChildAt(entry.childCount - 1);
|
||||
partitionedPrincipalToInherit = childEntry.partitionedPrincipalToInherit;
|
||||
|
||||
// Check that the partitioned principal to inherit is properly set.
|
||||
ok(partitionedPrincipalToInherit, "partitionedPrincipalToInherit is set");
|
||||
is(
|
||||
partitionedPrincipalToInherit.originNoSuffix,
|
||||
"https://example.net",
|
||||
"correct originNoSuffix in the cross-site iframe"
|
||||
);
|
||||
is(
|
||||
partitionedPrincipalToInherit.originAttributes.partitionKey,
|
||||
"(https,example.com)",
|
||||
"correct partitionKey in the cross-site iframe"
|
||||
);
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
@@ -3791,7 +3791,7 @@ void BrowsingContext::SessionHistoryCommit(
|
||||
const LoadingSessionHistoryInfo& aInfo, uint32_t aLoadType,
|
||||
nsIURI* aPreviousURI, SessionHistoryInfo* aPreviousActiveEntry,
|
||||
bool aPersist, bool aCloneEntryChildren, bool aChannelExpired,
|
||||
uint32_t aCacheKey, nsIPrincipal* aPartitionedPrincipal) {
|
||||
uint32_t aCacheKey) {
|
||||
nsID changeID = {};
|
||||
if (XRE_IsContentProcess()) {
|
||||
RefPtr<ChildSHistory> rootSH = Top()->GetChildSessionHistory();
|
||||
@@ -3830,11 +3830,11 @@ void BrowsingContext::SessionHistoryCommit(
|
||||
ContentChild* cc = ContentChild::GetSingleton();
|
||||
mozilla::Unused << cc->SendHistoryCommit(
|
||||
this, aInfo.mLoadId, changeID, aLoadType, aPersist, aCloneEntryChildren,
|
||||
aChannelExpired, aCacheKey, aPartitionedPrincipal);
|
||||
aChannelExpired, aCacheKey);
|
||||
} else {
|
||||
Canonical()->SessionHistoryCommit(
|
||||
aInfo.mLoadId, changeID, aLoadType, aPersist, aCloneEntryChildren,
|
||||
aChannelExpired, aCacheKey, aPartitionedPrincipal);
|
||||
Canonical()->SessionHistoryCommit(aInfo.mLoadId, changeID, aLoadType,
|
||||
aPersist, aCloneEntryChildren,
|
||||
aChannelExpired, aCacheKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -867,8 +867,7 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
||||
uint32_t aLoadType, nsIURI* aCurrentURI,
|
||||
SessionHistoryInfo* aPreviousActiveEntry,
|
||||
bool aPersist, bool aCloneEntryChildren,
|
||||
bool aChannelExpired, uint32_t aCacheKey,
|
||||
nsIPrincipal* aPartitionedPrincipal);
|
||||
bool aChannelExpired, uint32_t aCacheKey);
|
||||
|
||||
// Set a new active entry on this browsing context. This is used for
|
||||
// implementing history.pushState/replaceState and same document navigations.
|
||||
|
||||
@@ -1013,8 +1013,7 @@ void CanonicalBrowsingContext::CallOnTopDescendants(
|
||||
|
||||
void CanonicalBrowsingContext::SessionHistoryCommit(
|
||||
uint64_t aLoadId, const nsID& aChangeID, uint32_t aLoadType, bool aPersist,
|
||||
bool aCloneEntryChildren, bool aChannelExpired, uint32_t aCacheKey,
|
||||
nsIPrincipal* aPartitionedPrincipal) {
|
||||
bool aCloneEntryChildren, bool aChannelExpired, uint32_t aCacheKey) {
|
||||
MOZ_LOG(gSHLog, LogLevel::Verbose,
|
||||
("CanonicalBrowsingContext::SessionHistoryCommit %p %" PRIu64, this,
|
||||
aLoadId));
|
||||
@@ -1038,7 +1037,6 @@ void CanonicalBrowsingContext::SessionHistoryCommit(
|
||||
newActiveEntry->SharedInfo()->mExpired = true;
|
||||
}
|
||||
|
||||
newActiveEntry->SetPartitionedPrincipalToInherit(aPartitionedPrincipal);
|
||||
bool loadFromSessionHistory = !newActiveEntry->ForInitialLoad();
|
||||
newActiveEntry->SetForInitialLoad(false);
|
||||
SessionHistoryEntry::RemoveLoadId(aLoadId);
|
||||
|
||||
@@ -170,8 +170,7 @@ class CanonicalBrowsingContext final : public BrowsingContext {
|
||||
void SessionHistoryCommit(uint64_t aLoadId, const nsID& aChangeID,
|
||||
uint32_t aLoadType, bool aPersist,
|
||||
bool aCloneEntryChildren, bool aChannelExpired,
|
||||
uint32_t aCacheKey,
|
||||
nsIPrincipal* aPartitionedPrincipal);
|
||||
uint32_t aCacheKey);
|
||||
|
||||
// Calls the session history listeners' OnHistoryReload, storing the result in
|
||||
// aCanReload. If aCanReload is set to true and we have an active or a loading
|
||||
|
||||
@@ -9044,7 +9044,7 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
|
||||
*mLoadingEntry, mLoadType, mCurrentURI, previousActiveEntry.get(),
|
||||
true, true,
|
||||
/* No expiration update on the same document loads*/
|
||||
false, cacheKey, doc->PartitionedPrincipal());
|
||||
false, cacheKey);
|
||||
// FIXME Need to set postdata.
|
||||
|
||||
// Set the title for the SH entry for this target url so that
|
||||
@@ -9104,9 +9104,6 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
|
||||
// SH menus in go/back/forward buttons won't be empty for this.
|
||||
mActiveEntry->SetTitle(mTitle);
|
||||
|
||||
mActiveEntry->SetPartitionedPrincipalToInherit(
|
||||
doc->PartitionedPrincipal());
|
||||
|
||||
if (scrollRestorationIsManual.isSome()) {
|
||||
mActiveEntry->SetScrollRestorationIsManual(
|
||||
scrollRestorationIsManual.value());
|
||||
@@ -11612,7 +11609,7 @@ nsresult nsDocShell::UpdateURLAndHistory(
|
||||
/* aReferrerInfo = */ referrerInfo,
|
||||
/* aTriggeringPrincipal = */ aDocument->NodePrincipal(),
|
||||
csp, title, scrollRestorationIsManual, aData,
|
||||
uriWasModified, aDocument->PartitionedPrincipal());
|
||||
uriWasModified);
|
||||
} else {
|
||||
// Since we're not changing which page we have loaded, pass
|
||||
// true for aCloneChildren.
|
||||
@@ -11666,7 +11663,7 @@ nsresult nsDocShell::UpdateURLAndHistory(
|
||||
/* aReferrerInfo = */ referrerInfo, aDocument->NodePrincipal(),
|
||||
aDocument->GetCsp(), title,
|
||||
mActiveEntry && mActiveEntry->GetScrollRestorationIsManual(), aData,
|
||||
uriWasModified, aDocument->PartitionedPrincipal());
|
||||
uriWasModified);
|
||||
} else {
|
||||
// Step 3.
|
||||
newSHEntry = mOSHE;
|
||||
@@ -12115,8 +12112,7 @@ void nsDocShell::UpdateActiveEntry(
|
||||
nsIURI* aOriginalURI, nsIReferrerInfo* aReferrerInfo,
|
||||
nsIPrincipal* aTriggeringPrincipal, nsIContentSecurityPolicy* aCsp,
|
||||
const nsAString& aTitle, bool aScrollRestorationIsManual,
|
||||
nsIStructuredCloneContainer* aData, bool aURIWasModified,
|
||||
nsIPrincipal* aPartitionedPrincipal) {
|
||||
nsIStructuredCloneContainer* aData, bool aURIWasModified) {
|
||||
MOZ_ASSERT(mozilla::SessionHistoryInParent());
|
||||
MOZ_ASSERT(aURI, "uri is null");
|
||||
MOZ_ASSERT(mLoadType == LOAD_PUSHSTATE,
|
||||
@@ -12151,7 +12147,6 @@ void nsDocShell::UpdateActiveEntry(
|
||||
mActiveEntry->SetStateData(static_cast<nsStructuredCloneContainer*>(aData));
|
||||
mActiveEntry->SetURIWasModified(aURIWasModified);
|
||||
mActiveEntry->SetScrollRestorationIsManual(aScrollRestorationIsManual);
|
||||
mActiveEntry->SetPartitionedPrincipalToInherit(aPartitionedPrincipal);
|
||||
|
||||
if (replace) {
|
||||
mBrowsingContext->ReplaceActiveSessionHistoryEntry(mActiveEntry.get());
|
||||
@@ -13892,13 +13887,6 @@ void nsDocShell::MoveLoadingToActiveEntry(bool aPersist, bool aExpired,
|
||||
if (aCacheKey != 0) {
|
||||
mActiveEntry->SetCacheKey(aCacheKey);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> partitionedPrincipal;
|
||||
RefPtr<Document> doc = GetDocument();
|
||||
if (doc) {
|
||||
partitionedPrincipal = doc->PartitionedPrincipal();
|
||||
}
|
||||
mActiveEntry->SetPartitionedPrincipalToInherit(partitionedPrincipal);
|
||||
MOZ_ASSERT(loadingEntry);
|
||||
uint32_t loadType =
|
||||
mLoadType == LOAD_ERROR_PAGE ? mFailedLoadType : mLoadType;
|
||||
@@ -13909,7 +13897,7 @@ void nsDocShell::MoveLoadingToActiveEntry(bool aPersist, bool aExpired,
|
||||
// URI, but in that case mCurrentURI won't be null here.
|
||||
mBrowsingContext->SessionHistoryCommit(
|
||||
*loadingEntry, loadType, aPreviousURI, previousActiveEntry.get(),
|
||||
aPersist, false, aExpired, aCacheKey, partitionedPrincipal);
|
||||
aPersist, false, aExpired, aCacheKey);
|
||||
}
|
||||
|
||||
// Only update navigation if the new entry will be persisted (i.e., is not
|
||||
|
||||
@@ -625,8 +625,7 @@ class nsDocShell final : public nsDocLoader,
|
||||
nsIURI* aURI, nsIURI* aOriginalURI, nsIReferrerInfo* aReferrerInfo,
|
||||
nsIPrincipal* aTriggeringPrincipal, nsIContentSecurityPolicy* aCsp,
|
||||
const nsAString& aTitle, bool aScrollRestorationIsManual,
|
||||
nsIStructuredCloneContainer* aData, bool aURIWasModified,
|
||||
nsIPrincipal* aPartitionedPrincipal);
|
||||
nsIStructuredCloneContainer* aData, bool aURIWasModified);
|
||||
|
||||
nsresult AddChildSHEntry(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
|
||||
int32_t aChildOffset, uint32_t aLoadType,
|
||||
|
||||
@@ -227,11 +227,6 @@ nsIPrincipal* SessionHistoryInfo::GetPartitionedPrincipalToInherit() const {
|
||||
return mSharedState.Get()->mPartitionedPrincipalToInherit;
|
||||
}
|
||||
|
||||
void SessionHistoryInfo::SetPartitionedPrincipalToInherit(
|
||||
nsIPrincipal* aPartitionedPrincipal) {
|
||||
mSharedState.Get()->mPartitionedPrincipalToInherit = aPartitionedPrincipal;
|
||||
}
|
||||
|
||||
nsIContentSecurityPolicy* SessionHistoryInfo::GetCsp() const {
|
||||
return mSharedState.Get()->mCsp;
|
||||
}
|
||||
@@ -1670,10 +1665,12 @@ bool IPDLParamTraits<dom::SessionHistoryInfo>::Read(
|
||||
aResult->mSharedState.Get()->mPrincipalToInherit)
|
||||
: !aResult->mSharedState.Get()->mPrincipalToInherit,
|
||||
"We don't expect this to change!");
|
||||
MOZ_ASSERT_IF(
|
||||
aResult->mSharedState.Get()->mPartitionedPrincipalToInherit,
|
||||
aResult->mSharedState.Get()->mPartitionedPrincipalToInherit->Equals(
|
||||
partitionedPrincipalToInherit));
|
||||
MOZ_ASSERT(
|
||||
partitionedPrincipalToInherit
|
||||
? partitionedPrincipalToInherit->Equals(
|
||||
aResult->mSharedState.Get()->mPartitionedPrincipalToInherit)
|
||||
: !aResult->mSharedState.Get()->mPartitionedPrincipalToInherit,
|
||||
"We don't expect this to change!");
|
||||
MOZ_ASSERT(
|
||||
csp ? nsCSPContext::Equals(csp, aResult->mSharedState.Get()->mCsp)
|
||||
: !aResult->mSharedState.Get()->mCsp,
|
||||
|
||||
@@ -141,7 +141,6 @@ class SessionHistoryInfo {
|
||||
nsIPrincipal* GetPrincipalToInherit() const;
|
||||
|
||||
nsIPrincipal* GetPartitionedPrincipalToInherit() const;
|
||||
void SetPartitionedPrincipalToInherit(nsIPrincipal* aPrincipal);
|
||||
|
||||
nsIContentSecurityPolicy* GetCsp() const;
|
||||
|
||||
|
||||
@@ -7527,13 +7527,7 @@ mozilla::ipc::IPCResult ContentParent::RecvHistoryCommit(
|
||||
const MaybeDiscarded<BrowsingContext>& aContext, const uint64_t& aLoadID,
|
||||
const nsID& aChangeID, const uint32_t& aLoadType, const bool& aPersist,
|
||||
const bool& aCloneEntryChildren, const bool& aChannelExpired,
|
||||
const uint32_t& aCacheKey, nsIPrincipal* aPartitionedPrincipal) {
|
||||
if (!ValidatePrincipal(aPartitionedPrincipal,
|
||||
{ValidatePrincipalOptions::AllowNullPtr,
|
||||
ValidatePrincipalOptions::AllowSystem})) {
|
||||
LogAndAssertFailedPrincipalValidationInfo(aPartitionedPrincipal, __func__);
|
||||
}
|
||||
|
||||
const uint32_t& aCacheKey) {
|
||||
if (!aContext.IsDiscarded()) {
|
||||
CanonicalBrowsingContext* canonical = aContext.get_canonical();
|
||||
if (!canonical) {
|
||||
@@ -7542,7 +7536,7 @@ mozilla::ipc::IPCResult ContentParent::RecvHistoryCommit(
|
||||
}
|
||||
canonical->SessionHistoryCommit(aLoadID, aChangeID, aLoadType, aPersist,
|
||||
aCloneEntryChildren, aChannelExpired,
|
||||
aCacheKey, aPartitionedPrincipal);
|
||||
aCacheKey);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
@@ -1304,7 +1304,7 @@ class ContentParent final : public PContentParent,
|
||||
const MaybeDiscarded<BrowsingContext>& aContext, const uint64_t& aLoadID,
|
||||
const nsID& aChangeID, const uint32_t& aLoadType, const bool& aPersist,
|
||||
const bool& aCloneEntryChildren, const bool& aChannelExpired,
|
||||
const uint32_t& aCacheKey, nsIPrincipal* aPartitionedPrincipal);
|
||||
const uint32_t& aCacheKey);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
mozilla::ipc::IPCResult RecvHistoryGo(
|
||||
|
||||
@@ -1784,8 +1784,7 @@ parent:
|
||||
async HistoryCommit(MaybeDiscardedBrowsingContext aContext,
|
||||
uint64_t aLoadID, nsID aChangeID, uint32_t aLoadType,
|
||||
bool aPersist, bool aCloneEntryChildren,
|
||||
bool aChannelExpired, uint32_t aCacheKey,
|
||||
nullable nsIPrincipal aPartitionedPrincipal);
|
||||
bool aChannelExpired, uint32_t aCacheKey);
|
||||
|
||||
async HistoryGo(MaybeDiscardedBrowsingContext aContext, int32_t aOffset,
|
||||
uint64_t aHistoryEpoch, bool aRequireUserInteraction,
|
||||
|
||||
@@ -662,8 +662,7 @@ static Result<SessionHistoryEntry*, const char*> ValidateHistoryLoad(
|
||||
aLoadState->PrincipalToInherit())) {
|
||||
return Err("PrincipalToInherit");
|
||||
}
|
||||
if (snapshot->GetPartitionedPrincipalToInherit() &&
|
||||
!principalEq(snapshot->GetPartitionedPrincipalToInherit(),
|
||||
if (!principalEq(snapshot->GetPartitionedPrincipalToInherit(),
|
||||
aLoadState->PartitionedPrincipalToInherit())) {
|
||||
return Err("PartitionedPrincipalToInherit");
|
||||
}
|
||||
|
||||
@@ -277,6 +277,13 @@ var SessionHistoryInternal = {
|
||||
);
|
||||
}
|
||||
|
||||
if (shEntry.partitionedPrincipalToInherit) {
|
||||
entry.partitionedPrincipalToInherit_base64 =
|
||||
lazy.E10SUtils.serializePrincipal(
|
||||
shEntry.partitionedPrincipalToInherit
|
||||
);
|
||||
}
|
||||
|
||||
entry.hasUserInteraction = shEntry.hasUserInteraction;
|
||||
|
||||
if (shEntry.triggeringPrincipal) {
|
||||
@@ -563,6 +570,12 @@ var SessionHistoryInternal = {
|
||||
);
|
||||
// As both partitionedPrincipal and principalToInherit are both not required to load
|
||||
// it's ok to keep these undefined when we don't have a previously defined principal.
|
||||
if (entry.partitionedPrincipalToInherit_base64) {
|
||||
shEntry.partitionedPrincipalToInherit =
|
||||
lazy.E10SUtils.deserializePrincipal(
|
||||
entry.partitionedPrincipalToInherit_base64
|
||||
);
|
||||
}
|
||||
if (entry.principalToInherit_base64) {
|
||||
shEntry.principalToInherit = lazy.E10SUtils.deserializePrincipal(
|
||||
entry.principalToInherit_base64
|
||||
|
||||
Reference in New Issue
Block a user