diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /toolkit/components/antitracking/AntiTrackingUtils.cpp | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/antitracking/AntiTrackingUtils.cpp')
-rw-r--r-- | toolkit/components/antitracking/AntiTrackingUtils.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/toolkit/components/antitracking/AntiTrackingUtils.cpp b/toolkit/components/antitracking/AntiTrackingUtils.cpp index d9624237de..56d1b9e9e5 100644 --- a/toolkit/components/antitracking/AntiTrackingUtils.cpp +++ b/toolkit/components/antitracking/AntiTrackingUtils.cpp @@ -567,9 +567,8 @@ AntiTrackingUtils::GetStoragePermissionStateInParent(nsIChannel* aChannel) { if (policyType == ExtContentPolicy::TYPE_SUBDOCUMENT) { // For loads of framed documents, we only use storage access - // if the load is the result of a same-origin, self-initiated + // if the load is the result of a same-origin, same-site-initiated // navigation of the frame. - uint64_t targetWindowIdNoTop = bc->GetCurrentInnerWindowId(); uint64_t triggeringWindowId; rv = loadInfo->GetTriggeringWindowId(&triggeringWindowId); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -581,10 +580,29 @@ AntiTrackingUtils::GetStoragePermissionStateInParent(nsIChannel* aChannel) { if (NS_WARN_IF(NS_FAILED(rv))) { return nsILoadInfo::NoStoragePermission; } + + nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); + RefPtr<nsIPrincipal> channelResultPrincipal; + rv = ssm->GetChannelResultPrincipal(aChannel, + getter_AddRefs(channelResultPrincipal)); + if (NS_WARN_IF(NS_FAILED(rv))) { + return nsILoadInfo::NoStoragePermission; + } RefPtr<net::HttpBaseChannel> httpChannel = do_QueryObject(aChannel); + bool crossSiteInitiated = false; + if (bc && bc->GetParent()->GetCurrentWindowContext()) { + RefPtr<WindowGlobalParent> triggeringWGP = + WindowGlobalParent::GetByInnerWindowId(triggeringWindowId); + if (triggeringWGP && triggeringWGP->DocumentPrincipal()) { + rv = triggeringWGP->DocumentPrincipal()->IsThirdPartyPrincipal( + channelResultPrincipal, &crossSiteInitiated); + if (NS_FAILED(rv)) { + crossSiteInitiated = false; + } + } + } - if (targetWindowIdNoTop == triggeringWindowId && - triggeringWindowHasStorageAccess && + if (!crossSiteInitiated && triggeringWindowHasStorageAccess && trackingPrincipal->Equals(framePrincipal) && httpChannel && !httpChannel->HasRedirectTaintedOrigin()) { return nsILoadInfo::HasStoragePermission; @@ -880,7 +898,9 @@ bool AntiTrackingUtils::IsThirdPartyChannel(nsIChannel* aChannel) { } bool thirdParty = true; rv = tpuService->IsThirdPartyChannel(aChannel, nullptr, &thirdParty); - NS_ENSURE_SUCCESS(rv, true); + if (NS_FAILED(rv)) { + return true; + } return thirdParty; } @@ -955,7 +975,9 @@ bool AntiTrackingUtils::IsThirdPartyDocument(Document* aDocument) { nsresult rv = tpuService->IsThirdPartyChannel(aDocument->GetChannel(), nullptr, &thirdParty); - NS_ENSURE_SUCCESS(rv, true); + if (NS_FAILED(rv)) { + return true; + } return thirdParty; } |