Bug 1189543 - `pushManager.getSubscription()` should return `null` for nonexistent push subscriptions in workers. r=nsm
authorKit Cambridge <kcambridge@mozilla.com>
Thu, 06 Aug 2015 10:15:00 -0700
changeset 256675 96544133a324b9dc3c4cf512982a346dbb656935
parent 256674 92470c43a4cc54e0352ada0b17001ea445bdb83e
child 256676 cab252737a1240f3b6c4e248e8c9a2a7884ff36c
push id29187
push usercbook@mozilla.com
push dateFri, 07 Aug 2015 11:13:32 +0000
treeherdermozilla-central@3e51753a099f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnsm
bugs1189543
milestone42.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 1189543 - `pushManager.getSubscription()` should return `null` for nonexistent push subscriptions in workers. r=nsm
dom/push/PushManager.cpp
--- a/dom/push/PushManager.cpp
+++ b/dom/push/PushManager.cpp
@@ -445,19 +445,23 @@ public:
   { }
 
   bool
   WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
   {
     nsRefPtr<PromiseWorkerProxy> proxy = mProxy.forget();
     nsRefPtr<Promise> promise = proxy->GetWorkerPromise();
     if (NS_SUCCEEDED(mStatus)) {
-      nsRefPtr<WorkerPushSubscription> sub =
-        new WorkerPushSubscription(mEndpoint, mScope);
-      promise->MaybeResolve(sub);
+      if (mEndpoint.IsEmpty()) {
+        promise->MaybeResolve(JS::NullHandleValue);
+      } else {
+        nsRefPtr<WorkerPushSubscription> sub =
+          new WorkerPushSubscription(mEndpoint, mScope);
+        promise->MaybeResolve(sub);
+      }
     } else {
       promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
     }
 
     proxy->CleanUp(aCx);
     return true;
   }
 private: