Bug 1190478 - Hide PushEvent.data until we ship message encryption. r=mt,jst
authorNikhil Marathe <nsm.nikhil@gmail.com>
Mon, 03 Aug 2015 11:04:41 -0700
changeset 256030 14003c5e401ddc28b3d4c5e9da785b35facc80b0
parent 256029 0866912ffc06bf7f32a28bedc590391c6ca86b83
child 256031 5ddf7484b5eaae748f569699d1611e8d77d43aa4
push id29163
push usercbook@mozilla.com
push dateTue, 04 Aug 2015 11:01:35 +0000
treeherdermozilla-central@5cf4d2f7f2f2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmt, jst
bugs1190478
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 1190478 - Hide PushEvent.data until we ship message encryption. r=mt,jst
dom/push/test/worker.js
dom/webidl/PushEvent.webidl
dom/workers/ServiceWorkerEvents.cpp
dom/workers/ServiceWorkerEvents.h
dom/workers/ServiceWorkerManager.cpp
--- a/dom/push/test/worker.js
+++ b/dom/push/test/worker.js
@@ -1,21 +1,16 @@
 // Any copyright is dedicated to the Public Domain.
 // http://creativecommons.org/licenses/publicdomain/
 
 this.onpush = handlePush;
 
 function handlePush(event) {
 
   self.clients.matchAll().then(function(result) {
-    if (event instanceof PushEvent &&
-      event.data instanceof PushMessageData &&
-      event.data.text === undefined &&
-      event.data.json === undefined &&
-      event.data.arrayBuffer === undefined &&
-      event.data.blob === undefined) {
-
+    // FIXME(nsm): Bug 1149195 will fix data exposure.
+    if (event instanceof PushEvent && !('data' in event)) {
       result[0].postMessage({type: "finished", okay: "yes"});
       return;
     }
     result[0].postMessage({type: "finished", okay: "no"});
   });
 }
--- a/dom/webidl/PushEvent.webidl
+++ b/dom/webidl/PushEvent.webidl
@@ -6,16 +6,18 @@
  * The origin of this IDL file is
  * https://w3c.github.io/push-api/
  */
 
 [Constructor(DOMString type, optional PushEventInit eventInitDict),
  Func="nsContentUtils::PushEnabled",
  Exposed=ServiceWorker]
 interface PushEvent : ExtendableEvent {
-  readonly attribute PushMessageData data;
+  // FIXME(nsm): Bug 1149195.
+  // readonly attribute PushMessageData data;
 };
 
 typedef USVString PushMessageDataInit;
 
 dictionary PushEventInit : ExtendableEventInit {
-  PushMessageDataInit data;
+  // FIXME(nsm): Bug 1149195.
+  // PushMessageDataInit data;
 };
--- a/dom/workers/ServiceWorkerEvents.cpp
+++ b/dom/workers/ServiceWorkerEvents.cpp
@@ -462,19 +462,11 @@ PushMessageData::Blob()
   return nullptr;
 }
 
 PushEvent::PushEvent(EventTarget* aOwner)
   : ExtendableEvent(aOwner)
 {
 }
 
-NS_IMPL_ADDREF_INHERITED(PushEvent, ExtendableEvent)
-NS_IMPL_RELEASE_INHERITED(PushEvent, ExtendableEvent)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(PushEvent)
-NS_INTERFACE_MAP_END_INHERITING(ExtendableEvent)
-
-NS_IMPL_CYCLE_COLLECTION_INHERITED(PushEvent, ExtendableEvent, mData)
-
 #endif /* ! MOZ_SIMPLEPUSH */
 
 END_WORKERS_NAMESPACE
--- a/dom/workers/ServiceWorkerEvents.h
+++ b/dom/workers/ServiceWorkerEvents.h
@@ -184,45 +184,47 @@ public:
   explicit PushMessageData(const nsAString& aData);
 private:
   ~PushMessageData();
 
 };
 
 class PushEvent final : public ExtendableEvent
 {
-  nsRefPtr<PushMessageData> mData;
+  // FIXME(nsm): Bug 1149195.
+  // nsRefPtr<PushMessageData> mData;
   nsMainThreadPtrHandle<ServiceWorker> mServiceWorker;
 
 protected:
   explicit PushEvent(mozilla::dom::EventTarget* aOwner);
   ~PushEvent() {}
 
 public:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PushEvent, ExtendableEvent)
+  // FIXME(nsm): Bug 1149195.
+  // Add cycle collection macros once data is re-exposed.
   NS_FORWARD_TO_EVENT
 
   virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
   {
     return mozilla::dom::PushEventBinding_workers::Wrap(aCx, this, aGivenProto);
   }
 
   static already_AddRefed<PushEvent>
   Constructor(mozilla::dom::EventTarget* aOwner,
               const nsAString& aType,
               const PushEventInit& aOptions)
   {
     nsRefPtr<PushEvent> e = new PushEvent(aOwner);
     bool trusted = e->Init(aOwner);
     e->InitEvent(aType, aOptions.mBubbles, aOptions.mCancelable);
     e->SetTrusted(trusted);
-    if(aOptions.mData.WasPassed()){
-      e->mData = new PushMessageData(aOptions.mData.Value());
-    }
+    // FIXME(nsm): Bug 1149195.
+    //if(aOptions.mData.WasPassed()){
+    //  e->mData = new PushMessageData(aOptions.mData.Value());
+    //}
     return e.forget();
   }
 
   static already_AddRefed<PushEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const PushEventInit& aOptions,
               ErrorResult& aRv)
@@ -233,15 +235,17 @@ public:
 
   void PostInit(nsMainThreadPtrHandle<ServiceWorker>& aServiceWorker)
   {
     mServiceWorker = aServiceWorker;
   }
 
   PushMessageData* Data()
   {
-    return mData;
+    // FIXME(nsm): Bug 1149195.
+    MOZ_CRASH("Should not be called!");
+    return nullptr;
   }
 };
 #endif /* ! MOZ_SIMPLEPUSH */
 
 END_WORKERS_NAMESPACE
 #endif /* mozilla_dom_workers_serviceworkerevents_h__ */
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -2162,17 +2162,18 @@ public:
 
   bool
   WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
   {
     MOZ_ASSERT(aWorkerPrivate);
     GlobalObject globalObj(aCx, aWorkerPrivate->GlobalScope()->GetWrapper());
 
     PushEventInit pei;
-    pei.mData.Construct(mData);
+    // FIXME(nsm): Bug 1149195.
+    // pei.mData.Construct(mData);
     pei.mBubbles = false;
     pei.mCancelable = true;
 
     ErrorResult result;
     nsRefPtr<PushEvent> event =
       PushEvent::Constructor(globalObj, NS_LITERAL_STRING("push"), pei, result);
     if (NS_WARN_IF(result.Failed())) {
       result.SuppressException();