Bug 1205109 - Make `pushsubscriptionchange` extendable. r=mt a=ritu
authorKit Cambridge <kcambridge@mozilla.com>
Fri, 30 Oct 2015 18:13:48 -0700
changeset 292377 810ac5245b1450f5c2d55607b0b27d35f20fd2d1
parent 292376 336a31419e0085f3c63c294d8824ca283d9cafcb
child 292378 d14a19cedf0ccc55905adb3af41eeca4031c15ce
push id227
push usercbook@mozilla.com
push dateWed, 30 Dec 2015 14:49:35 +0000
reviewersmt, ritu
bugs1205109
milestone44.0
Bug 1205109 - Make `pushsubscriptionchange` extendable. r=mt a=ritu
dom/workers/ServiceWorkerPrivate.cpp
--- a/dom/workers/ServiceWorkerPrivate.cpp
+++ b/dom/workers/ServiceWorkerPrivate.cpp
@@ -641,29 +641,32 @@ public:
     MOZ_ASSERT(aWorkerPrivate->IsServiceWorker());
   }
 
   bool
   WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
   {
     MOZ_ASSERT(aWorkerPrivate);
 
-    WorkerGlobalScope* globalScope = aWorkerPrivate->GlobalScope();
-
-    RefPtr<Event> event = NS_NewDOMEvent(globalScope, nullptr, nullptr);
+    RefPtr<EventTarget> target = aWorkerPrivate->GlobalScope();
 
-    nsresult rv = event->InitEvent(NS_LITERAL_STRING("pushsubscriptionchange"),
-                                   false, false);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return false;
-    }
+    ExtendableEventInit init;
+    init.mBubbles = false;
+    init.mCancelable = false;
+
+    RefPtr<ExtendableEvent> event =
+      ExtendableEvent::Constructor(target,
+                                   NS_LITERAL_STRING("pushsubscriptionchange"),
+                                   init);
 
     event->SetTrusted(true);
 
-    globalScope->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+    DispatchExtendableEventOnWorkerScope(aCx, aWorkerPrivate->GlobalScope(),
+                                         event, nullptr);
+
     return true;
   }
 };
 
 } // anonymous namespace
 #endif // !MOZ_SIMPLEPUSH
 
 nsresult