xref: /third_party/node/test/parallel/test-worker-message-port-transfer-target.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst { MessageChannel } = require('worker_threads');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst { port1, port2 } = new MessageChannel();
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst arrayBuf = new ArrayBuffer(10);
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cicommon.expectWarning('Warning',
121cb0ef41Sopenharmony_ci                     'The target port was posted to itself, and the ' +
131cb0ef41Sopenharmony_ci                     'communication channel was lost');
141cb0ef41Sopenharmony_ciport2.onmessage = common.mustNotCall();
151cb0ef41Sopenharmony_ciport2.postMessage(null, [port1, arrayBuf]);
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci// arrayBuf must be transferred, despite the fact that port2 never received the
181cb0ef41Sopenharmony_ci// message.
191cb0ef41Sopenharmony_ciassert.strictEqual(arrayBuf.byteLength, 0);
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_cisetTimeout(common.mustNotCall('The communication channel is still open'),
221cb0ef41Sopenharmony_ci           common.platformTimeout(1000)).unref();
23

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