diff options
Diffstat (limited to 'dom')
-rw-r--r-- | dom/webidl/Client.webidl | 4 | ||||
-rw-r--r-- | dom/webidl/ServiceWorker.webidl | 4 | ||||
-rw-r--r-- | dom/workers/ServiceWorker.cpp | 10 | ||||
-rw-r--r-- | dom/workers/ServiceWorker.h | 8 | ||||
-rw-r--r-- | dom/workers/ServiceWorkerClient.cpp | 9 | ||||
-rw-r--r-- | dom/workers/ServiceWorkerClient.h | 6 |
6 files changed, 39 insertions, 2 deletions
diff --git a/dom/webidl/Client.webidl b/dom/webidl/Client.webidl index 7abb65ab12..c961c2b31f 100644 --- a/dom/webidl/Client.webidl +++ b/dom/webidl/Client.webidl @@ -15,7 +15,9 @@ interface Client { readonly attribute DOMString id; [Throws] - void postMessage(any message, optional sequence<object> transfer = []); + void postMessage(any message, sequence<object> transferable); + [Throws] + void postMessage(any message, optional StructuredSerializeOptions options); }; [Exposed=ServiceWorker] diff --git a/dom/webidl/ServiceWorker.webidl b/dom/webidl/ServiceWorker.webidl index 6dab46a16b..ff80fafc21 100644 --- a/dom/webidl/ServiceWorker.webidl +++ b/dom/webidl/ServiceWorker.webidl @@ -20,7 +20,9 @@ interface ServiceWorker : EventTarget { attribute EventHandler onstatechange; [Throws] - void postMessage(any message, optional sequence<object> transferable = []); + void postMessage(any message, sequence<object> transferable); + [Throws] + void postMessage(any message, optional StructuredSerializeOptions options); }; ServiceWorker implements AbstractWorker; diff --git a/dom/workers/ServiceWorker.cpp b/dom/workers/ServiceWorker.cpp index 87b86c4805..f2a39ea9c2 100644 --- a/dom/workers/ServiceWorker.cpp +++ b/dom/workers/ServiceWorker.cpp @@ -14,6 +14,7 @@ #include "mozilla/Preferences.h" #include "mozilla/dom/Promise.h" +#include "mozilla/dom/MessagePortBinding.h" #include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h" #ifdef XP_WIN @@ -97,6 +98,15 @@ ServiceWorker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage, aRv = workerPrivate->SendMessageEvent(aCx, aMessage, aTransferable, Move(clientInfo)); } +void +ServiceWorker::PostMessage(JSContext* aCx, + JS::Handle<JS::Value> aMessage, + const StructuredSerializeOptions& aOptions, + ErrorResult& aRv) +{ + PostMessage(aCx, aMessage, aOptions.mTransfer, aRv); +} + } // namespace workers } // namespace dom } // namespace mozilla diff --git a/dom/workers/ServiceWorker.h b/dom/workers/ServiceWorker.h index d85d055aab..eb14fc4293 100644 --- a/dom/workers/ServiceWorker.h +++ b/dom/workers/ServiceWorker.h @@ -15,6 +15,8 @@ class nsPIDOMWindowInner; namespace mozilla { namespace dom { +struct StructuredSerializeOptions; + namespace workers { class ServiceWorkerInfo; @@ -66,6 +68,12 @@ public: const Sequence<JSObject*>& aTransferable, ErrorResult& aRv); + void + PostMessage(JSContext* aCx, + JS::Handle<JS::Value> aMessage, + const StructuredSerializeOptions& aOptions, + ErrorResult& aRv); + private: // This class can only be created from ServiceWorkerInfo::GetOrCreateInstance(). ServiceWorker(nsPIDOMWindowInner* aWindow, ServiceWorkerInfo* aInfo); diff --git a/dom/workers/ServiceWorkerClient.cpp b/dom/workers/ServiceWorkerClient.cpp index eb4e676ffa..e8b8341e21 100644 --- a/dom/workers/ServiceWorkerClient.cpp +++ b/dom/workers/ServiceWorkerClient.cpp @@ -11,6 +11,7 @@ #include "mozilla/dom/Navigator.h" #include "mozilla/dom/ServiceWorkerMessageEvent.h" #include "mozilla/dom/ServiceWorkerMessageEventBinding.h" +#include "mozilla/dom/MessagePortBinding.h" #include "nsGlobalWindow.h" #include "nsIBrowserDOMWindow.h" #include "nsIDocument.h" @@ -220,3 +221,11 @@ ServiceWorkerClient::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage, } } +void +ServiceWorkerClient::PostMessage(JSContext* aCx, + JS::Handle<JS::Value> aMessage, + const StructuredSerializeOptions& aOptions, + ErrorResult& aRv) +{ + PostMessage(aCx, aMessage, aOptions.mTransfer, aRv); +} diff --git a/dom/workers/ServiceWorkerClient.h b/dom/workers/ServiceWorkerClient.h index 4d8759c408..7f89ee611a 100644 --- a/dom/workers/ServiceWorkerClient.h +++ b/dom/workers/ServiceWorkerClient.h @@ -94,6 +94,12 @@ public: const Sequence<JSObject*>& aTransferable, ErrorResult& aRv); + void + PostMessage(JSContext* aCx, + JS::Handle<JS::Value> aMessage, + const StructuredSerializeOptions& aOptions, + ErrorResult& aRv); + JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; protected: |