Bug 1966658 - Populate the partitionedPrincipal to the SessionHistoryEntry in the parent process. r=smaug,sessionstore-reviewers,core-sessionstore-reviewers,farre

In this patch, we populate the partitionedPrincipal when we commit
SessionHistory to the parent process. In addition, we remove the
serialization and deserialization of partitionedPrincipalToInherit in
sessionHistory.

Differential Revision: https://phabricator.services.mozilla.com/D250263
This commit is contained in:
Tim Huang
2025-05-21 22:23:07 +00:00
committed by tihuang@mozilla.com
parent fbd34bb1de
commit 52c31c4da0
15 changed files with 164 additions and 38 deletions

View File

@@ -9044,7 +9044,7 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
*mLoadingEntry, mLoadType, mCurrentURI, previousActiveEntry.get(),
true, true,
/* No expiration update on the same document loads*/
false, cacheKey);
false, cacheKey, doc->PartitionedPrincipal());
// FIXME Need to set postdata.
// Set the title for the SH entry for this target url so that
@@ -9104,6 +9104,9 @@ 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());
@@ -11609,7 +11612,7 @@ nsresult nsDocShell::UpdateURLAndHistory(
/* aReferrerInfo = */ referrerInfo,
/* aTriggeringPrincipal = */ aDocument->NodePrincipal(),
csp, title, scrollRestorationIsManual, aData,
uriWasModified);
uriWasModified, aDocument->PartitionedPrincipal());
} else {
// Since we're not changing which page we have loaded, pass
// true for aCloneChildren.
@@ -11663,7 +11666,7 @@ nsresult nsDocShell::UpdateURLAndHistory(
/* aReferrerInfo = */ referrerInfo, aDocument->NodePrincipal(),
aDocument->GetCsp(), title,
mActiveEntry && mActiveEntry->GetScrollRestorationIsManual(), aData,
uriWasModified);
uriWasModified, aDocument->PartitionedPrincipal());
} else {
// Step 3.
newSHEntry = mOSHE;
@@ -12112,7 +12115,8 @@ void nsDocShell::UpdateActiveEntry(
nsIURI* aOriginalURI, nsIReferrerInfo* aReferrerInfo,
nsIPrincipal* aTriggeringPrincipal, nsIContentSecurityPolicy* aCsp,
const nsAString& aTitle, bool aScrollRestorationIsManual,
nsIStructuredCloneContainer* aData, bool aURIWasModified) {
nsIStructuredCloneContainer* aData, bool aURIWasModified,
nsIPrincipal* aPartitionedPrincipal) {
MOZ_ASSERT(mozilla::SessionHistoryInParent());
MOZ_ASSERT(aURI, "uri is null");
MOZ_ASSERT(mLoadType == LOAD_PUSHSTATE,
@@ -12147,6 +12151,7 @@ void nsDocShell::UpdateActiveEntry(
mActiveEntry->SetStateData(static_cast<nsStructuredCloneContainer*>(aData));
mActiveEntry->SetURIWasModified(aURIWasModified);
mActiveEntry->SetScrollRestorationIsManual(aScrollRestorationIsManual);
mActiveEntry->SetPartitionedPrincipalToInherit(aPartitionedPrincipal);
if (replace) {
mBrowsingContext->ReplaceActiveSessionHistoryEntry(mActiveEntry.get());
@@ -13887,6 +13892,13 @@ 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;
@@ -13897,7 +13909,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);
aPersist, false, aExpired, aCacheKey, partitionedPrincipal);
}
// Only update navigation if the new entry will be persisted (i.e., is not