xref: /third_party/node/test/addons/worker-buffer-callback/test.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/addons/worker-buffer-callback/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst { MessageChannel } = require('worker_threads');
51cb0ef41Sopenharmony_ciconst { buffer } = require(`./build/${common.buildType}/binding`);
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci// Test that buffers allocated with a free callback through our APIs are not
81cb0ef41Sopenharmony_ci// transferred.
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst { port1 } = new MessageChannel();
111cb0ef41Sopenharmony_ciconst origByteLength = buffer.byteLength;
121cb0ef41Sopenharmony_ciport1.postMessage(buffer, [buffer.buffer]);
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciassert.strictEqual(buffer.byteLength, origByteLength);
151cb0ef41Sopenharmony_ciassert.notStrictEqual(buffer.byteLength, 0);
16

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