diff options
author | itaysabato <itaysabato@gmail.com> | 2018-06-25 10:13:01 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-06-29 13:14:07 -0700 |
commit | 71e1602fb8542700c53b068f2120977b9f868753 (patch) | |
tree | 934ff7546e13c3fb44dc32afd7665006a54ab2b9 /test | |
parent | 074e7f88aff0244dd9aee412e885194ce3f5a953 (diff) | |
download | android-node-v8-71e1602fb8542700c53b068f2120977b9f868753.tar.gz android-node-v8-71e1602fb8542700c53b068f2120977b9f868753.tar.bz2 android-node-v8-71e1602fb8542700c53b068f2120977b9f868753.zip |
test: add a request-response test for MessageChannel
This commit adds a request-response test for MessageChannel.
PR-URL: https://github.com/nodejs/node/pull/21514
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-message-port.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/parallel/test-message-port.js b/test/parallel/test-message-port.js index fe88126d04..2d321611ec 100644 --- a/test/parallel/test-message-port.js +++ b/test/parallel/test-message-port.js @@ -21,6 +21,21 @@ const { MessageChannel, MessagePort } = require('worker_threads'); { const { port1, port2 } = new MessageChannel(); + port1.onmessage = common.mustCall((message) => { + assert.strictEqual(message, 4); + port2.close(common.mustCall()); + }); + + port1.postMessage(2); + + port2.onmessage = common.mustCall((message) => { + port2.postMessage(message * 2); + }); +} + +{ + const { port1, port2 } = new MessageChannel(); + const input = { a: 1 }; port1.postMessage(input); // Check that the message still gets delivered if `port2` has its |