Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e7abde4

Browse filesBrowse files
itaysabatotargos
authored andcommitted
test: add a request-response test for MessageChannel
This commit adds a request-response test for MessageChannel. PR-URL: #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>
1 parent 3d3dbae commit e7abde4
Copy full SHA for e7abde4

File tree

Expand file treeCollapse file tree

1 file changed

+15
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-0
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-message-port.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-message-port.js
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ const { MessageChannel, MessagePort } = require('worker_threads');
1818
}));
1919
}
2020

21+
{
22+
const { port1, port2 } = new MessageChannel();
23+
24+
port1.onmessage = common.mustCall((message) => {
25+
assert.strictEqual(message, 4);
26+
port2.close(common.mustCall());
27+
});
28+
29+
port1.postMessage(2);
30+
31+
port2.onmessage = common.mustCall((message) => {
32+
port2.postMessage(message * 2);
33+
});
34+
}
35+
2136
{
2237
const { port1, port2 } = new MessageChannel();
2338

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.