Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

Commit

Permalink
test: add test against unsupported worker features
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyGu authored and addaleax committed Oct 22, 2017
1 parent 7d58ee9 commit 52e9497
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions test/parallel/test-worker-unsupported-things.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const { Worker, isMainThread, postMessage } = require('worker');

if (isMainThread) {
const w = new Worker(__filename);
w.on('message', common.mustCall((message) => {
assert.strictEqual(message, true);
}));
} else {
assert.throws(() => {
require('domain');
}, common.expectsError({
code: 'ERR_WORKER_DOMAIN',
type: TypeError
}));

assert.doesNotThrow(() => {
process.umask();
});
assert.throws(() => {
process.umask(0);
}, TypeError);

{
const before = process.title;
// This should throw...
process.title += ' in worker';
assert.strictEqual(process.title, before);
}

{
const before = process.debugPort;
// This should throw...
process.debugPort++;
assert.strictEqual(process.debugPort, before);
}

assert.strictEqual(process.stdin, null);
assert.strictEqual(process.stdout, null);
assert.strictEqual(process.stderr, null);

assert.strictEqual('abort' in process, false);
assert.strictEqual('chdir' in process, false);
assert.strictEqual('setuid' in process, false);
assert.strictEqual('seteuid' in process, false);
assert.strictEqual('setgid' in process, false);
assert.strictEqual('setegid' in process, false);
assert.strictEqual('setgroups' in process, false);
assert.strictEqual('initgroups' in process, false);

assert.strictEqual('_startProfilerIdleNotifier' in process, false);
assert.strictEqual('_stopProfilerIdleNotifier' in process, false);
assert.strictEqual('_debugProcess' in process, false);
assert.strictEqual('_debugPause' in process, false);
assert.strictEqual('_debugEnd' in process, false);

postMessage(true);
}

0 comments on commit 52e9497

Please sign in to comment.