1'use strict'; 2require('../common'); 3const assert = require('assert'); 4 5const { MessageChannel, MessagePort } = require('worker_threads'); 6 7// Make sure that `MessagePort` is the constructor for MessagePort instances, 8// but not callable. 9const { port1 } = new MessageChannel(); 10 11assert(port1 instanceof MessagePort); 12assert.strictEqual(port1.constructor, MessagePort); 13 14assert.throws(() => MessagePort(), { 15 constructor: TypeError, 16 code: 'ERR_CONSTRUCT_CALL_INVALID' 17}); 18 19assert.throws(() => new MessagePort(), { 20 constructor: TypeError, 21 code: 'ERR_CONSTRUCT_CALL_INVALID' 22}); 23 24assert.throws(() => MessageChannel(), { 25 constructor: TypeError, 26 code: 'ERR_CONSTRUCT_CALL_REQUIRED' 27}); 28