MCPcopy Index your code
hub / github.com/nodejs/node / testSingle

Function testSingle

test/parallel/test-worker-message-port-transfer-closed.js:16–36  ·  view source on GitHub ↗
(closedPort, potentiallyOpenPort)

Source from the content-addressed store, hash-verified

14port2.onmessage = common.mustNotCall();
15
16function testSingle(closedPort, potentiallyOpenPort) {
17 assert.throws(common.mustCall(() => {
18 potentiallyOpenPort.postMessage(null, [arrayBuf, closedPort]);
19 }), common.mustCall((err) => {
20 assert.strictEqual(err.name, 'DataCloneError');
21 assert.strictEqual(err.message,
22 'MessagePort in transfer list is already detached');
23 assert.strictEqual(err.code, 25);
24 assert.ok(err instanceof Error);
25
26 const DOMException = err.constructor;
27 assert.ok(err instanceof DOMException);
28 assert.strictEqual(DOMException.name, 'DOMException');
29
30 return true;
31 }));
32
33 // arrayBuf must not be transferred, even though it is present earlier in the
34 // transfer list than the closedPort.
35 assert.strictEqual(arrayBuf.byteLength, 10);
36}
37
38function testBothClosed() {
39 testSingle(port1, port2);

Calls 2

postMessageMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…