diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /dom/notification/Notification.cpp | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-adbda400be353e676059e335c3c0aaf99e719475.tar.xz firefox-adbda400be353e676059e335c3c0aaf99e719475.zip |
Adding upstream version 125.0.1.upstream/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.cpp | 13 |
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(); } |