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 288325 96544133a324b9dc3c4cf512982a346dbb656935
parent 288324 92470c43a4cc54e0352ada0b17001ea445bdb83e
child 288326 cab252737a1240f3b6c4e248e8c9a2a7884ff36c
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [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: