mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 18:15:18 +00:00

PR-URL: https://github.com/nodejs/node/pull/36360 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
21 lines
634 B
JavaScript
21 lines
634 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const { MessageChannel } = require('worker_threads');
|
|
|
|
// Make sure that the pools used by the Buffer implementation are not
|
|
// transferable.
|
|
// Refs: https://github.com/nodejs/node/issues/32752
|
|
|
|
const a = Buffer.from('hello world');
|
|
const b = Buffer.from('hello world');
|
|
assert.strictEqual(a.buffer, b.buffer);
|
|
const length = a.length;
|
|
|
|
const { port1 } = new MessageChannel();
|
|
port1.postMessage(a, [ a.buffer ]);
|
|
|
|
// Verify that the pool ArrayBuffer has not actually been transferred:
|
|
assert.strictEqual(a.buffer, b.buffer);
|
|
assert.strictEqual(a.length, length);
|