diff options
author | Anna Henningsen <anna@addaleax.net> | 2021-02-27 21:46:50 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2021-03-04 01:23:38 +0300 |
commit | 007a85ce83b42284e8fb83733cfe3a60c1fe119c (patch) | |
tree | 004c426196b1fc1262c5fc144790313310092137 /src/node_messaging.h | |
parent | 9dd2f9f19dd35a91eabd0aa5acff9011db59e238 (diff) |
worker: add ports property to MessageEvents
Add `ev.ports` for spec compliancy.
Since we only emit the raw `data` value, and only create the
`MessageEvent` instance if there are EventTarget-style listeners,
we store the ports list temporarily on the MessagePort object itself,
so that we can look it up when we need to create the event object.
Fixes: https://github.com/nodejs/node/issues/37358
PR-URL: https://github.com/nodejs/node/pull/37538
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/node_messaging.h')
-rw-r--r-- | src/node_messaging.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/node_messaging.h b/src/node_messaging.h index 2e63b22e4ce..429a5646b8a 100644 --- a/src/node_messaging.h +++ b/src/node_messaging.h @@ -62,8 +62,10 @@ class Message : public MemoryRetainer { // Deserialize the contained JS value. May only be called once, and only // after Serialize() has been called (e.g. by another thread). - v8::MaybeLocal<v8::Value> Deserialize(Environment* env, - v8::Local<v8::Context> context); + v8::MaybeLocal<v8::Value> Deserialize( + Environment* env, + v8::Local<v8::Context> context, + v8::Local<v8::Value>* port_list = nullptr); // Serialize a JS value, and optionally transfer objects, into this message. // The Message object retains ownership of all transferred objects until @@ -293,8 +295,10 @@ class MessagePort : public HandleWrap { void OnClose() override; void OnMessage(MessageProcessingMode mode); void TriggerAsync(); - v8::MaybeLocal<v8::Value> ReceiveMessage(v8::Local<v8::Context> context, - MessageProcessingMode mode); + v8::MaybeLocal<v8::Value> ReceiveMessage( + v8::Local<v8::Context> context, + MessageProcessingMode mode, + v8::Local<v8::Value>* port_list = nullptr); std::unique_ptr<MessagePortData> data_ = nullptr; bool receiving_messages_ = false; |