tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

decompression-uint8array-output.tentative.any.js (801B)


      1 // META: global=window,worker
      2 
      3 "use strict";
      4 
      5 // The zstd-compressed bytes for the string "expected output".
      6 const zstdChunkValue = new Uint8Array([
      7  0x28, 0xb5, 0x2f, 0xfd, 0x04, 0x58, 0x79, 0x00, 0x00, 0x65, 0x78, 0x70, 0x65,
      8  0x63, 0x74, 0x65, 0x64, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5b, 0x11,
      9  0xc6, 0x85,
     10 ]);
     11 
     12 promise_test(async t => {
     13  const ds = new DecompressionStream("zstd");
     14  const writer = ds.writable.getWriter();
     15  const reader = ds.readable.getReader();
     16 
     17  const writePromise = writer.write(zstdChunkValue);
     18  const { value } = await reader.read();
     19 
     20  await writePromise;
     21  await writer.close();
     22 
     23  assert_equals(
     24    value.constructor.name,
     25    "Uint8Array",
     26    "The constructor should be Uint8Array"
     27  );
     28 }, "decompressing zstd output should give Uint8Array chunks");