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: https://github.com/nodejs/node/pull/59885
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Jarred Sumner 2025-10-01 05:46:47 -07:00 committed by GitHub
parent 3dc8c57204
commit 9790315e15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,3 +27,14 @@ port2.postMessage(0);
// This is part of the test -- the event loop should be available and not stall
// out due to the recursive .postMessage() calls.
setTimeout(common.mustCall(), 0);
// Assert that the 'message' handler was actually called.
//
// We do not want to assert a specific call count, so common.mustCall cannot be
// used in the port1.on('message' callback directly.
process.once(
'beforeExit',
common.mustCall(() => {
assert(count > 0, 'count should be greater than 0');
})
);