Skip to content
Snippets Groups Projects
Verified Commit 9711e81b authored by hsingh's avatar hsingh Committed by Pier Angelo Vendrame
Browse files

Bug 1843046: Do not allow notifications in private window. r=saschanaz, a=RyanVM

parent 11ef8b88
Branches
Tags
1 merge request!768Bug 42090: Rebase release release onto 102.15.1esr
......@@ -478,6 +478,9 @@ NotificationPermissionRequest::Run() {
bool blocked = false;
if (isSystem) {
mPermission = NotificationPermission::Granted;
} else if (mPrincipal->GetPrivateBrowsingId() != 0) {
mPermission = NotificationPermission::Denied;
blocked = true;
} else {
// File are automatically granted permission.
......@@ -1483,7 +1486,12 @@ already_AddRefed<Promise> Notification::RequestPermission(
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
nsCOMPtr<nsIPrincipal> principal = sop->GetPrincipal();
if (!principal) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
RefPtr<Promise> promise = Promise::Create(window->AsGlobal(), aRv);
if (aRv.Failed()) {
......@@ -1537,6 +1545,15 @@ NotificationPermission Notification::GetPermissionInternal(nsISupports* aGlobal,
}
nsCOMPtr<nsIPrincipal> principal = sop->GetPrincipal();
if (!principal) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return NotificationPermission::Denied;
}
if (principal->GetPrivateBrowsingId() != 0) {
return NotificationPermission::Denied;
}
return GetPermissionInternal(principal, aRv);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment