summaryrefslogtreecommitdiffstats
path: root/dom/notification/Notification.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /dom/notification/Notification.cpp
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/notification/Notification.cpp')
-rw-r--r--dom/notification/Notification.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp
index 39ba7b23ff..fb5b0ea9a3 100644
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -714,7 +714,12 @@ Notification::Notification(nsIGlobalObject* aGlobal, const nsAString& aID,
}
}
-nsresult Notification::Init() {
+nsresult Notification::MaybeObserveWindowFrozenOrDestroyed() {
+ // NOTE: Non-persistent notifications can also be opened from workers, but we
+ // don't care and nobody else cares. And it's not clear whether we even should
+ // do this for window at all, see
+ // https://github.com/whatwg/notifications/issues/204.
+ // TODO: Somehow extend GlobalTeardownObserver to deal with FROZEN_TOPIC?
if (!mWorkerPrivate) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
NS_ENSURE_TRUE(obs, NS_ERROR_FAILURE);
@@ -776,6 +781,10 @@ already_AddRefed<Notification> Notification::Constructor(
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
+ if (NS_WARN_IF(
+ NS_FAILED(notification->MaybeObserveWindowFrozenOrDestroyed()))) {
+ return nullptr;
+ }
// This is be ok since we are on the worker thread where this function will
// run to completion before the Notification has a chance to go away.
@@ -915,8 +924,6 @@ already_AddRefed<Notification> Notification::CreateInternal(
aGlobal, id, aTitle, aOptions.mBody, aOptions.mDir, aOptions.mLang,
aOptions.mTag, aOptions.mIcon, aOptions.mRequireInteraction, silent,
std::move(vibrate), aOptions.mMozbehavior);
- rv = notification->Init();
- NS_ENSURE_SUCCESS(rv, nullptr);
return notification.forget();
}