mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
2d9bf91fe1
Fixes: https://github.com/nodejs/node/issues/41589 PR-URL: https://github.com/nodejs/node/pull/46832 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
23 lines
627 B
JavaScript
23 lines
627 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
common.skipIfInspectorDisabled();
|
|
common.skipIfWorker(); // This test requires both main and worker threads.
|
|
|
|
const assert = require('assert');
|
|
const { Worker, isMainThread } = require('worker_threads');
|
|
|
|
if (isMainThread) {
|
|
const name = 'Hello Thread';
|
|
const expectedTitle = `[worker 1] ${name}`;
|
|
const worker = new Worker(fixtures.path('worker-name.js'), {
|
|
name,
|
|
});
|
|
worker.once('message', common.mustCall((message) => {
|
|
assert.strictEqual(message, expectedTitle);
|
|
worker.postMessage('done');
|
|
}));
|
|
}
|