diff --git a/dom/messagechannel/MessagePort.cpp b/dom/messagechannel/MessagePort.cpp index a63c84b2b0..5fbd1e9bb9 100644 --- a/dom/messagechannel/MessagePort.cpp +++ b/dom/messagechannel/MessagePort.cpp @@ -495,6 +495,14 @@ MessagePort::PostMessage(JSContext* aCx, mActor->SendPostMessages(messages); } +void +MessagePort::PostMessage(JSContext* aCx, JS::Handle aMessage, + const StructuredSerializeOptions& aOptions, + ErrorResult& aRv) +{ + PostMessage(aCx, aMessage, aOptions.mTransfer, aRv); +} + void MessagePort::Start() { diff --git a/dom/messagechannel/MessagePort.h b/dom/messagechannel/MessagePort.h index e635c532a3..b832872e1f 100644 --- a/dom/messagechannel/MessagePort.h +++ b/dom/messagechannel/MessagePort.h @@ -26,6 +26,7 @@ class MessagePortIdentifier; class MessagePortMessage; class PostMessageRunnable; class SharedMessagePortMessage; +struct StructuredSerializeOptions; namespace workers { class WorkerHolder; @@ -65,6 +66,11 @@ public: const Sequence& aTransferable, ErrorResult& aRv); + void + PostMessage(JSContext* aCx, JS::Handle aMessage, + const StructuredSerializeOptions& aOptions, + ErrorResult& aRv); + void Start(); void Close(); diff --git a/dom/webidl/MessagePort.webidl b/dom/webidl/MessagePort.webidl index 6495b5616d..0b36c47d94 100644 --- a/dom/webidl/MessagePort.webidl +++ b/dom/webidl/MessagePort.webidl @@ -10,7 +10,9 @@ [Exposed=(Window,Worker,System)] interface MessagePort : EventTarget { [Throws] - void postMessage(any message, optional sequence transferable = []); + void postMessage(any message, sequence transferable); + [Throws] + void postMessage(any message, optional StructuredSerializeOptions options); void start(); void close(); @@ -19,3 +21,8 @@ interface MessagePort : EventTarget { attribute EventHandler onmessage; }; // MessagePort implements Transferable; + +// Used to declare which objects should be transferred. +dictionary StructuredSerializeOptions { + sequence transfer = []; +}; \ No newline at end of file