tor-browser

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

decompression-extra-input.any.js (772B)


      1 // META: global=window,worker,shadowrealm
      2 // META: script=resources/decompression-input.js
      3 
      4 'use strict';
      5 
      6 const tests = compressedBytes.map(
      7  ([format, chunk]) => [format, new Uint8Array([...chunk, 0])]
      8 );
      9 
     10 for (const [format, chunk] of tests) {
     11  promise_test(async t => {
     12    const ds = new DecompressionStream(format);
     13    const reader = ds.readable.getReader();
     14    const writer = ds.writable.getWriter();
     15    writer.write(chunk).catch(() => { });
     16    const { done, value } = await reader.read();
     17    assert_array_equals(Array.from(value), expectedChunkValue, "value should match");
     18    await promise_rejects_js(t, TypeError, reader.read(), "Extra input should eventually throw");
     19  }, `decompressing ${format} input with extra pad should still give the output`);
     20 }