Bug 1673889 - Remove topLevelStorageAreaPrincipal. r=timhuang,necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D122364
This commit is contained in:
Paul Zuehlcke 2021-08-11 18:51:20 +00:00
Родитель fc44521a67
Коммит 3a8091d1c2
8 изменённых файлов: 15 добавлений и 115 удалений

Просмотреть файл

@ -5984,37 +5984,6 @@ nsIPrincipal* nsGlobalWindowInner::GetTopLevelAntiTrackingPrincipal() {
return topLevelPrincipal;
}
nsIPrincipal* nsGlobalWindowInner::GetTopLevelStorageAreaPrincipal() {
if (mDoc && (mDoc->StorageAccessSandboxed())) {
// Storage access is disabled
return nullptr;
}
BrowsingContext* parent = GetBrowsingContext()->GetParent();
nsPIDOMWindowOuter* outerWindow = parent ? parent->GetDOMWindow() : nullptr;
if (!outerWindow) {
// No outer window available!
return nullptr;
}
if (!outerWindow->GetBrowsingContext()->IsTop()) {
return nullptr;
}
nsPIDOMWindowInner* innerWindow = outerWindow->GetCurrentInnerWindow();
if (NS_WARN_IF(!innerWindow)) {
return nullptr;
}
nsIPrincipal* parentPrincipal =
nsGlobalWindowInner::Cast(innerWindow)->GetPrincipal();
if (NS_WARN_IF(!parentPrincipal)) {
return nullptr;
}
return parentPrincipal;
}
//*****************************************************************************
// nsGlobalWindowInner: Timeout Functions
//*****************************************************************************

Просмотреть файл

@ -1157,11 +1157,6 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
// Get the toplevel principal, returns null if this is a toplevel window.
nsIPrincipal* GetTopLevelAntiTrackingPrincipal();
// Get the parent principal, returns null if this or the parent are not a
// toplevel window. This is mainly used to determine the anti-tracking storage
// area.
nsIPrincipal* GetTopLevelStorageAreaPrincipal();
// This method is called if this window loads a 3rd party tracking resource
// and the storage is just been granted. The window can reset the partitioned
// storage objects and switch to the first party cookie jar.

Просмотреть файл

@ -411,13 +411,6 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo,
NS_ENSURE_SUCCESS(rv, rv);
}
Maybe<PrincipalInfo> topLevelStorageAreaPrincipalInfo;
if (nsIPrincipal* prin = aLoadInfo->GetTopLevelStorageAreaPrincipal()) {
topLevelStorageAreaPrincipalInfo.emplace();
rv = PrincipalToPrincipalInfo(prin, topLevelStorageAreaPrincipalInfo.ptr());
NS_ENSURE_SUCCESS(rv, rv);
}
Maybe<URIParams> optionalResultPrincipalURI;
nsCOMPtr<nsIURI> resultPrincipalURI;
Unused << aLoadInfo->GetResultPrincipalURI(
@ -495,10 +488,9 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo,
*aOptionalLoadInfoArgs = Some(LoadInfoArgs(
loadingPrincipalInfo, triggeringPrincipalInfo, principalToInheritInfo,
topLevelPrincipalInfo, topLevelStorageAreaPrincipalInfo,
optionalResultPrincipalURI, aLoadInfo->GetSandboxedNullPrincipalID(),
aLoadInfo->GetSecurityFlags(), aLoadInfo->GetSandboxFlags(),
aLoadInfo->GetTriggeringSandboxFlags(),
topLevelPrincipalInfo, optionalResultPrincipalURI,
aLoadInfo->GetSandboxedNullPrincipalID(), aLoadInfo->GetSecurityFlags(),
aLoadInfo->GetSandboxFlags(), aLoadInfo->GetTriggeringSandboxFlags(),
aLoadInfo->InternalContentPolicyType(),
static_cast<uint32_t>(aLoadInfo->GetTainting()),
aLoadInfo->GetBlockAllMixedContent(),
@ -639,16 +631,6 @@ nsresult LoadInfoArgsToLoadInfo(
topLevelPrincipal = topLevelPrincipalOrErr.unwrap();
}
nsCOMPtr<nsIPrincipal> topLevelStorageAreaPrincipal;
if (loadInfoArgs.topLevelStorageAreaPrincipalInfo().isSome()) {
auto topLevelStorageAreaPrincipalOrErr = PrincipalInfoToPrincipal(
loadInfoArgs.topLevelStorageAreaPrincipalInfo().ref());
if (NS_WARN_IF(topLevelStorageAreaPrincipalOrErr.isErr())) {
return topLevelStorageAreaPrincipalOrErr.unwrapErr();
}
topLevelStorageAreaPrincipal = topLevelStorageAreaPrincipalOrErr.unwrap();
}
nsCOMPtr<nsIURI> resultPrincipalURI;
if (loadInfoArgs.resultPrincipalURI().isSome()) {
resultPrincipalURI = DeserializeURI(loadInfoArgs.resultPrincipalURI());
@ -744,11 +726,11 @@ nsresult LoadInfoArgsToLoadInfo(
RefPtr<mozilla::net::LoadInfo> loadInfo = new mozilla::net::LoadInfo(
loadingPrincipal, triggeringPrincipal, principalToInherit,
topLevelPrincipal, topLevelStorageAreaPrincipal, resultPrincipalURI,
cookieJarSettings, cspToInherit, loadInfoArgs.sandboxedNullPrincipalID(),
clientInfo, reservedClientInfo, initialClientInfo, controller,
loadInfoArgs.securityFlags(), loadInfoArgs.sandboxFlags(),
loadInfoArgs.triggeringSandboxFlags(), loadInfoArgs.contentPolicyType(),
topLevelPrincipal, resultPrincipalURI, cookieJarSettings, cspToInherit,
loadInfoArgs.sandboxedNullPrincipalID(), clientInfo, reservedClientInfo,
initialClientInfo, controller, loadInfoArgs.securityFlags(),
loadInfoArgs.sandboxFlags(), loadInfoArgs.triggeringSandboxFlags(),
loadInfoArgs.contentPolicyType(),
static_cast<LoadTainting>(loadInfoArgs.tainting()),
loadInfoArgs.blockAllMixedContent(),
loadInfoArgs.upgradeInsecureRequests(),

Просмотреть файл

@ -183,27 +183,13 @@ LoadInfo::LoadInfo(
if (innerWindow) {
mTopLevelPrincipal = innerWindow->GetTopLevelAntiTrackingPrincipal();
// The top-level-storage-area-principal is not null only for the first
// level of iframes (null for top-level contexts, and null for
// sub-iframes). If we are loading a sub-document resource, we must
// calculate what the top-level-storage-area-principal will be for the
// new context.
if (externalType != ExtContentPolicy::TYPE_SUBDOCUMENT) {
mTopLevelStorageAreaPrincipal =
innerWindow->GetTopLevelStorageAreaPrincipal();
} else if (bc->IsTop()) {
Document* doc = innerWindow->GetExtantDoc();
if (!doc || (!doc->StorageAccessSandboxed())) {
mTopLevelStorageAreaPrincipal = innerWindow->GetPrincipal();
}
if (!mTopLevelPrincipal &&
externalType == ExtContentPolicy::TYPE_SUBDOCUMENT && bc->IsTop()) {
// If this is the first level iframe, innerWindow is our top-level
// principal.
if (!mTopLevelPrincipal) {
mTopLevelPrincipal = innerWindow->GetPrincipal();
}
}
}
// Let's inherit the cookie behavior and permission from the parent
// document.
@ -353,8 +339,6 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
nsGlobalWindowInner::Cast(aOuterWindow->GetCurrentInnerWindow());
if (innerWindow) {
mTopLevelPrincipal = innerWindow->GetTopLevelAntiTrackingPrincipal();
// mTopLevelStorageAreaPrincipal is always null for top-level document
// loading.
}
// get the docshell from the outerwindow, and then get the originattributes
@ -469,22 +453,11 @@ LoadInfo::LoadInfo(dom::WindowGlobalParent* aParentWGP,
}
}
// The top-level-storage-area-principal is not null only for the first
// level of iframes (null for top-level contexts, and null for
// sub-iframes). If we are loading a sub-document resource, we must
// calculate what the top-level-storage-area-principal will be for the
// new context.
if (parentBC->IsTop()) {
if (!Document::StorageAccessSandboxed(aParentWGP->SandboxFlags())) {
mTopLevelStorageAreaPrincipal = aParentWGP->DocumentPrincipal();
}
if (!mTopLevelPrincipal && parentBC->IsTop()) {
// If this is the first level iframe, embedder WindowGlobalParent's document
// principal is our top-level principal.
if (!mTopLevelPrincipal) {
mTopLevelPrincipal = aParentWGP->DocumentPrincipal();
}
}
mInnerWindowID = aParentWGP->InnerWindowId();
mDocumentHasUserInteracted = aParentWGP->DocumentHasUserInteracted();
@ -546,7 +519,6 @@ LoadInfo::LoadInfo(const LoadInfo& rhs)
mTriggeringPrincipal(rhs.mTriggeringPrincipal),
mPrincipalToInherit(rhs.mPrincipalToInherit),
mTopLevelPrincipal(rhs.mTopLevelPrincipal),
mTopLevelStorageAreaPrincipal(rhs.mTopLevelStorageAreaPrincipal),
mResultPrincipalURI(rhs.mResultPrincipalURI),
mCookieJarSettings(rhs.mCookieJarSettings),
mCspToInherit(rhs.mCspToInherit),
@ -621,8 +593,7 @@ LoadInfo::LoadInfo(const LoadInfo& rhs)
LoadInfo::LoadInfo(
nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aPrincipalToInherit, nsIPrincipal* aTopLevelPrincipal,
nsIPrincipal* aTopLevelStorageAreaPrincipal, nsIURI* aResultPrincipalURI,
nsICookieJarSettings* aCookieJarSettings,
nsIURI* aResultPrincipalURI, nsICookieJarSettings* aCookieJarSettings,
nsIContentSecurityPolicy* aCspToInherit,
const nsID& aSandboxedNullPrincipalID, const Maybe<ClientInfo>& aClientInfo,
const Maybe<ClientInfo>& aReservedClientInfo,
@ -661,7 +632,6 @@ LoadInfo::LoadInfo(
mTriggeringPrincipal(aTriggeringPrincipal),
mPrincipalToInherit(aPrincipalToInherit),
mTopLevelPrincipal(aTopLevelPrincipal),
mTopLevelStorageAreaPrincipal(aTopLevelStorageAreaPrincipal),
mResultPrincipalURI(aResultPrincipalURI),
mCookieJarSettings(aCookieJarSettings),
mCspToInherit(aCspToInherit),
@ -866,10 +836,6 @@ void LoadInfo::ResetSandboxedNullPrincipalID() {
nsIPrincipal* LoadInfo::GetTopLevelPrincipal() { return mTopLevelPrincipal; }
nsIPrincipal* LoadInfo::GetTopLevelStorageAreaPrincipal() {
return mTopLevelStorageAreaPrincipal;
}
NS_IMETHODIMP
LoadInfo::GetLoadingDocument(Document** aResult) {
if (nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext)) {

Просмотреть файл

@ -186,8 +186,7 @@ class LoadInfo final : public nsILoadInfo {
LoadInfo(
nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aPrincipalToInherit, nsIPrincipal* aTopLevelPrincipal,
nsIPrincipal* aTopLevelStorageAreaPrincipal, nsIURI* aResultPrincipalURI,
nsICookieJarSettings* aCookieJarSettings,
nsIURI* aResultPrincipalURI, nsICookieJarSettings* aCookieJarSettings,
nsIContentSecurityPolicy* aCspToInherit,
const nsID& aSandboxedNullPrincipalID,
const Maybe<mozilla::dom::ClientInfo>& aClientInfo,
@ -261,7 +260,6 @@ class LoadInfo final : public nsILoadInfo {
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
nsCOMPtr<nsIPrincipal> mPrincipalToInherit;
nsCOMPtr<nsIPrincipal> mTopLevelPrincipal;
nsCOMPtr<nsIPrincipal> mTopLevelStorageAreaPrincipal;
nsCOMPtr<nsIURI> mResultPrincipalURI;
nsCOMPtr<nsICSPEventListener> mCSPEventListener;
nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;

Просмотреть файл

@ -66,8 +66,6 @@ void TRRLoadInfo::ResetSandboxedNullPrincipalID() {}
nsIPrincipal* TRRLoadInfo::GetTopLevelPrincipal() { return nullptr; }
nsIPrincipal* TRRLoadInfo::GetTopLevelStorageAreaPrincipal() { return nullptr; }
NS_IMETHODIMP
TRRLoadInfo::GetLoadingDocument(Document** aResult) {
return NS_ERROR_NOT_IMPLEMENTED;

Просмотреть файл

@ -1046,13 +1046,6 @@ interface nsILoadInfo : nsISupports
*/
[notxpcom, nostdcall] readonly attribute nsIPrincipal topLevelPrincipal;
/**
* Return the top-level storage area principal, which is the principal of
* the top-level window if it's not a 3rd party context, non tracking
* resource.
*/
[notxpcom, nostdcall] readonly attribute nsIPrincipal topLevelStorageAreaPrincipal;
/**
* Note which client (i.e. global) initiated this network request. All
* nsGlobalWindow and WorkerPrivate can be converted to a ClientInfo to

Просмотреть файл

@ -83,7 +83,6 @@ struct LoadInfoArgs
PrincipalInfo triggeringPrincipalInfo;
PrincipalInfo? principalToInheritInfo;
PrincipalInfo? topLevelPrincipalInfo;
PrincipalInfo? topLevelStorageAreaPrincipalInfo;
URIParams? resultPrincipalURI;
nsID sandboxedNullPrincipalID;
uint32_t securityFlags;