Bug 1439212 Make ServiceWorkerRegistrationWorkerThread::ShowNotification() check for nullptr mWorkerPrivate. r=asuth
authorBen Kelly <ben@wanderview.com>
Mon, 19 Feb 2018 12:07:48 -0800
changeset 404417 1874ac39b41cbeaee0dd9b2442aacfd7c3731735
parent 404416 a2ebde19d2781370ea487c93ce9a7a0c7d6b263f
child 404418 a95360977f7635ca900c4001c3a69af6fd00920d
push id100002
push userbkelly@mozilla.com
push dateMon, 19 Feb 2018 20:07:56 +0000
treeherdermozilla-inbound@1874ac39b41c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1439212
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1439212 Make ServiceWorkerRegistrationWorkerThread::ShowNotification() check for nullptr mWorkerPrivate. r=asuth
dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp
--- a/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp
+++ b/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp
@@ -985,16 +985,20 @@ WorkerListener::UpdateFound()
 
 // Notification API extension.
 already_AddRefed<Promise>
 ServiceWorkerRegistrationWorkerThread::ShowNotification(JSContext* aCx,
                                                         const nsAString& aTitle,
                                                         const NotificationOptions& aOptions,
                                                         ErrorResult& aRv)
 {
+  if (!mWorkerPrivate) {
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+    return nullptr;
+  }
 
   // Until Bug 1131324 exposes ServiceWorkerContainer on workers,
   // ShowPersistentNotification() checks for valid active worker while it is
   // also verifying scope so that we block the worker on the main thread only
   // once.
   RefPtr<Promise> p =
     Notification::ShowPersistentNotification(aCx, mWorkerPrivate->GlobalScope(),
                                              mScope, aTitle, aOptions, aRv);