summaryrefslogtreecommitdiffstats
path: root/dom/notification/Notification.cpp
diff options
context:
space:
mode:
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();
}