summaryrefslogtreecommitdiff
path: root/test/parallel/test-worker-onmessage.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-02-13 21:26:59 +0100
committerAnna Henningsen <anna@addaleax.net>2019-02-15 23:16:16 +0100
commit5adda2c44748ace543447da8844b9b08965e402b (patch)
tree9d1b5bd62b76f84da8bc5c8cafe24f877004c9dc /test/parallel/test-worker-onmessage.js
parenta02e3e2d5f1f96f3c408270d45935afdd5d1fffc (diff)
downloadandroid-node-v8-5adda2c44748ace543447da8844b9b08965e402b.tar.gz
android-node-v8-5adda2c44748ace543447da8844b9b08965e402b.tar.bz2
android-node-v8-5adda2c44748ace543447da8844b9b08965e402b.zip
worker: use fake MessageEvent for port.onmessage
Instead of passing the payload for Workers directly to `.onmessage`, perform something more similar to what the browser API provides, namely create an event object with a `.data` property. This does not make `MessagePort` implement the `EventTarget` API, nor does it implement the full `MessageEvent` API, but it would make such extensions non-breaking changes if we desire them at some point in the future. (This would be a breaking change if Workers were not experimental. Currently, this method is also undocumented and only exists with the idea of enabling some degree of Web compatibility.) PR-URL: https://github.com/nodejs/node/pull/26082 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Diffstat (limited to 'test/parallel/test-worker-onmessage.js')
-rw-r--r--test/parallel/test-worker-onmessage.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/test/parallel/test-worker-onmessage.js b/test/parallel/test-worker-onmessage.js
index 47f6324aad..f315b0d201 100644
--- a/test/parallel/test-worker-onmessage.js
+++ b/test/parallel/test-worker-onmessage.js
@@ -14,6 +14,6 @@ if (!process.env.HAS_STARTED_WORKER) {
w.postMessage(2);
} else {
parentPort.onmessage = common.mustCall((message) => {
- parentPort.postMessage(message * 2);
+ parentPort.postMessage(message.data * 2);
});
}