blob: 23c8de7c7b0cfb199723f55b45328a898e585b29 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
'use strict';
const common = require('../common');
const assert = require('assert');
const { Worker, isMainThread } = require('worker_threads');
if (isMainThread) {
const w = new Worker(__filename, {
stdin: true,
stdout: true,
stderr: true
});
w.on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0);
// `postMessage` should not throw after termination
// (this mimics the browser behavior).
w.postMessage('foobar');
w.ref();
w.unref();
// Although not browser specific, probably wise to
// make sure the stream getters don't throw either.
w.stdin;
w.stdout;
w.stderr;
// Sanity check.
assert.strictEqual(w.threadId, -1);
assert.strictEqual(w.stdin, null);
assert.strictEqual(w.stdout, null);
assert.strictEqual(w.stderr, null);
}));
} else {
process.exit(0);
}
|