diff --git a/test/parallel/test-message-port.js b/test/parallel/test-message-port.js index fe88126d044c2b..2d321611ec7758 100644 --- a/test/parallel/test-message-port.js +++ b/test/parallel/test-message-port.js @@ -18,6 +18,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();