From 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:33 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- dom/notification/Notification.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'dom/notification/Notification.cpp') 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 obs = mozilla::services::GetObserverService(); NS_ENSURE_TRUE(obs, NS_ERROR_FAILURE); @@ -776,6 +781,10 @@ already_AddRefed 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::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(); } -- cgit v1.2.3