зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1843046: Do not allow notifications in private window.r=saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D184064
This commit is contained in:
Родитель
c023063eaa
Коммит
058e2f8b2a
|
@ -477,6 +477,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.
|
||||
|
||||
|
@ -1452,7 +1455,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()) {
|
||||
|
@ -1506,6 +1514,14 @@ NotificationPermission Notification::GetPermissionInternal(
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal = sop->GetPrincipal();
|
||||
if (!principal) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return NotificationPermission::Denied;
|
||||
}
|
||||
|
||||
if (principal->GetPrivateBrowsingId() != 0) {
|
||||
return NotificationPermission::Denied;
|
||||
}
|
||||
// Disallow showing notification if our origin is not the same origin as the
|
||||
// toplevel one, see https://github.com/whatwg/notifications/issues/177.
|
||||
if (!StaticPrefs::dom_webnotifications_allowcrossoriginiframe()) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче