Bug 1558420 - Part 4: Do not report anti-tracking notifications when blocking storage access for sandboxed documents; r=baku

Differential Revision: https://phabricator.services.mozilla.com/D51328

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2019-11-12 15:40:14 +00:00
Родитель c639488e49
Коммит f78028be4e
1 изменённых файлов: 14 добавлений и 6 удалений

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

@ -78,12 +78,6 @@ bool GetParentPrincipalAndTrackingOrigin(
nsGlobalWindowInner* a3rdPartyTrackingWindow, uint32_t aBehavior, nsGlobalWindowInner* a3rdPartyTrackingWindow, uint32_t aBehavior,
nsIPrincipal** aTopLevelStoragePrincipal, nsACString& aTrackingOrigin, nsIPrincipal** aTopLevelStoragePrincipal, nsACString& aTrackingOrigin,
nsIURI** aTrackingURI, nsIPrincipal** aTrackingPrincipal) { nsIURI** aTrackingURI, nsIPrincipal** aTrackingPrincipal) {
Document* doc = a3rdPartyTrackingWindow->GetDocument();
// Make sure storage access isn't disabled
if (doc && (doc->StorageAccessSandboxed())) {
return false;
}
// Now we need the principal and the origin of the parent window. // Now we need the principal and the origin of the parent window.
nsCOMPtr<nsIPrincipal> topLevelStoragePrincipal = nsCOMPtr<nsIPrincipal> topLevelStoragePrincipal =
// Use the "top-level storage area principal" behaviour in reject tracker // Use the "top-level storage area principal" behaviour in reject tracker
@ -1014,6 +1008,13 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(
return StorageAccessGrantPromise::CreateAndReject(false, __func__); return StorageAccessGrantPromise::CreateAndReject(false, __func__);
} }
Document* doc = parentWindow->GetExtantDoc();
// Make sure storage access isn't disabled
if (doc && (doc->StorageAccessSandboxed())) {
LOG(("Our document is sandboxed"));
return StorageAccessGrantPromise::CreateAndReject(false, __func__);
}
if (!GetParentPrincipalAndTrackingOrigin( if (!GetParentPrincipalAndTrackingOrigin(
parentWindow, behavior, getter_AddRefs(topLevelStoragePrincipal), parentWindow, behavior, getter_AddRefs(topLevelStoragePrincipal),
trackingOrigin, getter_AddRefs(trackingURI), trackingOrigin, getter_AddRefs(trackingURI),
@ -1482,6 +1483,13 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
} }
#endif #endif
Document* doc = aWindow->GetExtantDoc();
// Make sure storage access isn't disabled
if (doc && (doc->StorageAccessSandboxed())) {
LOG(("Our document is sandboxed"));
return false;
}
nsCOMPtr<nsIPrincipal> parentPrincipal; nsCOMPtr<nsIPrincipal> parentPrincipal;
nsCOMPtr<nsIURI> parentPrincipalURI; nsCOMPtr<nsIURI> parentPrincipalURI;
nsCOMPtr<nsIURI> trackingURI; nsCOMPtr<nsIURI> trackingURI;