mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
f4f8ec2b65
This ports `test/addons/worker-buffer-callback` to N-API, with the small exception of using external `ArrayBuffer`s rather than external Node.js `Buffer`s. PR-URL: https://github.com/nodejs/node/pull/30551 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
16 lines
524 B
JavaScript
16 lines
524 B
JavaScript
'use strict';
|
|
const common = require('../../common');
|
|
const assert = require('assert');
|
|
const { MessageChannel } = require('worker_threads');
|
|
const { buffer } = require(`./build/${common.buildType}/binding`);
|
|
|
|
// Test that buffers allocated with a free callback through our APIs are not
|
|
// transferred.
|
|
|
|
const { port1 } = new MessageChannel();
|
|
const origByteLength = buffer.byteLength;
|
|
port1.postMessage(buffer, [buffer]);
|
|
|
|
assert.strictEqual(buffer.byteLength, origByteLength);
|
|
assert.notStrictEqual(buffer.byteLength, 0);
|