Skip to content

Commit 1aaadb9

Browse files
Jarred-Sumnertargos
authored andcommitted
test: ensure message event fires in worker message port test
Add assertion to verify that the MessagePort's message event is actually emitted in test-worker-message-port-infinite-message-loop.js. Previously, the test could pass even if the event was not fired. PR-URL: #59885 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 64e738a commit 1aaadb9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/parallel/test-worker-message-port-infinite-message-loop.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,14 @@ port2.postMessage(0);
2727
// This is part of the test -- the event loop should be available and not stall
2828
// out due to the recursive .postMessage() calls.
2929
setTimeout(common.mustCall(), 0);
30+
31+
// Assert that the 'message' handler was actually called.
32+
//
33+
// We do not want to assert a specific call count, so common.mustCall cannot be
34+
// used in the port1.on('message' callback directly.
35+
process.once(
36+
'beforeExit',
37+
common.mustCall(() => {
38+
assert(count > 0, 'count should be greater than 0');
39+
})
40+
);

0 commit comments

Comments
 (0)