tor-browser

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

decompression-empty-input.any.js (870B)


      1 // META: global=window,worker,shadowrealm
      2 
      3 'use strict';
      4 
      5 const emptyValues = [
      6  ["gzip", new Uint8Array([31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0])],
      7  ["deflate", new Uint8Array([120, 156, 3, 0, 0, 0, 0, 1])],
      8  ["deflate-raw", new Uint8Array([1, 0, 0, 255, 255])],
      9  ["brotli", new Uint8Array([0xa1, 0x01])],
     10 ];
     11 
     12 for (const [format, emptyValue] of emptyValues) {
     13  promise_test(async t => {
     14    const ds = new DecompressionStream(format);
     15    const reader = ds.readable.getReader();
     16    const writer = ds.writable.getWriter();
     17    const writePromise = writer.write(emptyValue);
     18    writer.close();
     19    const { value, done } = await reader.read();
     20    assert_true(done, "read() should set done");
     21    assert_equals(value, undefined, "value should be undefined");
     22    await writePromise;
     23  }, `decompressing ${format} empty input should work`);
     24 }