2019-11-19 20:39:07 +00:00
|
|
|
'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;
|
2023-05-05 11:22:42 +00:00
|
|
|
assert.throws(() => port1.postMessage(buffer, [buffer]), {
|
|
|
|
code: 25,
|
|
|
|
name: 'DataCloneError',
|
|
|
|
});
|
2019-11-19 20:39:07 +00:00
|
|
|
|
|
|
|
assert.strictEqual(buffer.byteLength, origByteLength);
|
|
|
|
assert.notStrictEqual(buffer.byteLength, 0);
|