xref: /third_party/node/test/parallel/test-worker-message-port-constructor.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_cirequire('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst { MessageChannel, MessagePort } = require('worker_threads');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci// Make sure that `MessagePort` is the constructor for MessagePort instances,
81cb0ef41Sopenharmony_ci// but not callable.
91cb0ef41Sopenharmony_ciconst { port1 } = new MessageChannel();
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciassert(port1 instanceof MessagePort);
121cb0ef41Sopenharmony_ciassert.strictEqual(port1.constructor, MessagePort);
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciassert.throws(() => MessagePort(), {
151cb0ef41Sopenharmony_ci  constructor: TypeError,
161cb0ef41Sopenharmony_ci  code: 'ERR_CONSTRUCT_CALL_INVALID'
171cb0ef41Sopenharmony_ci});
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciassert.throws(() => new MessagePort(), {
201cb0ef41Sopenharmony_ci  constructor: TypeError,
211cb0ef41Sopenharmony_ci  code: 'ERR_CONSTRUCT_CALL_INVALID'
221cb0ef41Sopenharmony_ci});
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ciassert.throws(() => MessageChannel(), {
251cb0ef41Sopenharmony_ci  constructor: TypeError,
261cb0ef41Sopenharmony_ci  code: 'ERR_CONSTRUCT_CALL_REQUIRED'
271cb0ef41Sopenharmony_ci});
28

Indexes created Thu Nov 07 10:32:03 CST 2024