1'use strict'; 2 3const common = require('../common'); 4const assert = require('assert'); 5const { MessageChannel } = require('worker_threads'); 6 7const { port1, port2 } = new MessageChannel(); 8 9const arrayBuf = new ArrayBuffer(10); 10 11common.expectWarning('Warning', 12 'The target port was posted to itself, and the ' + 13 'communication channel was lost'); 14port2.onmessage = common.mustNotCall(); 15port2.postMessage(null, [port1, arrayBuf]); 16 17// arrayBuf must be transferred, despite the fact that port2 never received the 18// message. 19assert.strictEqual(arrayBuf.byteLength, 0); 20 21setTimeout(common.mustNotCall('The communication channel is still open'), 22 common.platformTimeout(1000)).unref(); 23