Bug 1205109 - Make `pushsubscriptionchange` extendable. r=mt
authorKit Cambridge <kcambridge@mozilla.com>
Fri, 30 Oct 2015 18:13:48 -0700
changeset 270531 cf81a62b5a374679029aa29fad6b81f0bca69cf7
parent 270530 c8488e4be05d389b284f686f48f1861cd56f24f4
child 270532 1a7a278648367a73ba842f297f2c4e042b28edfe
push id67381
push userkcambridge@mozilla.com
push dateSat, 31 Oct 2015 05:24:10 +0000
treeherdermozilla-inbound@9cc31dc74e39 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmt
bugs1205109
milestone45.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 1205109 - Make `pushsubscriptionchange` extendable. r=mt
dom/workers/ServiceWorkerPrivate.cpp
--- a/dom/workers/ServiceWorkerPrivate.cpp
+++ b/dom/workers/ServiceWorkerPrivate.cpp
@@ -554,29 +554,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