mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
PR-URL: https://github.com/nodejs/node/pull/59214 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
30 lines
639 B
JavaScript
30 lines
639 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const {
|
|
Worker,
|
|
isMainThread,
|
|
} = require('worker_threads');
|
|
|
|
if (!isMainThread) {
|
|
common.skip('This test only works on a main thread');
|
|
}
|
|
|
|
const assert = require('assert');
|
|
|
|
if (isMainThread) {
|
|
const name = 'Hello\0Thread';
|
|
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');
|
|
}));
|
|
}
|