Skip to content
Snippets Groups Projects
Verified Commit 61b100bc authored by hsingh's avatar hsingh Committed by ma1
Browse files

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

parent 5b85dfb4
No related branches found
No related tags found
No related merge requests found
......@@ -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