11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 71cb0ef41Sopenharmony_cicommon.skipIfWorker(); // This test requires both main and worker threads. 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst assert = require('assert'); 101cb0ef41Sopenharmony_ciconst { Worker, isMainThread } = require('worker_threads'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciif (isMainThread) { 131cb0ef41Sopenharmony_ci const name = 'Hello Thread'; 141cb0ef41Sopenharmony_ci const expectedTitle = `[worker 1] ${name}`; 151cb0ef41Sopenharmony_ci const worker = new Worker(fixtures.path('worker-name.js'), { 161cb0ef41Sopenharmony_ci name, 171cb0ef41Sopenharmony_ci }); 181cb0ef41Sopenharmony_ci worker.once('message', common.mustCall((message) => { 191cb0ef41Sopenharmony_ci assert.strictEqual(message, expectedTitle); 201cb0ef41Sopenharmony_ci worker.postMessage('done'); 211cb0ef41Sopenharmony_ci })); 221cb0ef41Sopenharmony_ci} 23