xref: /third_party/node/test/parallel/test-messaging-maketransferable.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ciconst common = require('../common');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ciconst {
81cb0ef41Sopenharmony_ci  JSTransferable,
91cb0ef41Sopenharmony_ci} = require('internal/worker/js_transferable');
101cb0ef41Sopenharmony_ciconst { E, F } = require('internal/test/transfer');
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci// Tests that F is transferable even tho it does not directly,
131cb0ef41Sopenharmony_ci// observably extend the JSTransferable class.
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciconst mc = new MessageChannel();
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_cimc.port1.onmessageerror = common.mustNotCall();
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_cimc.port1.onmessage = common.mustCall(({ data }) => {
201cb0ef41Sopenharmony_ci  assert(!(data instanceof JSTransferable));
211cb0ef41Sopenharmony_ci  assert(data instanceof F);
221cb0ef41Sopenharmony_ci  assert(data instanceof E);
231cb0ef41Sopenharmony_ci  assert.strictEqual(data.b, 1);
241cb0ef41Sopenharmony_ci  mc.port1.close();
251cb0ef41Sopenharmony_ci});
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_cimc.port2.postMessage(new F(1));
28

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