Bug 1776109 - Part 1: Fall back to nsIPrincipal in StorageAllowedForWindow r=asuth,anti-tracking-reviewers,pbz

Differential Revision: https://phabricator.services.mozilla.com/D150282
This commit is contained in:
Kagami Sascha Rosylight 2022-06-30 11:33:55 +00:00
parent 388ea3d223
commit 4bbf6a056b

View File

@ -235,7 +235,16 @@ StorageAccess StorageAllowedForWindow(nsPIDOMWindowInner* aWindow,
*aRejectedReason);
}
// No document? Let's return a generic rejected reason.
// No document? Try checking Private Browsing Mode without document
if (const nsCOMPtr<nsIGlobalObject> global = aWindow->AsGlobal()) {
if (const nsCOMPtr<nsIPrincipal> principal = global->PrincipalOrNull()) {
if (principal->GetPrivateBrowsingId() > 0) {
return StorageAccess::ePrivateBrowsing;
}
}
}
// Everything failed? Let's return a generic rejected reason.
return StorageAccess::eDeny;
}