Debian Codegraph @

testing/web-platform/mozilla/tests/compression/zstd/decompression-empty-input.tentative.any.js

raw
1 // META: global=window,worker
2
3 "use strict";
4
5 // The zstd-compressed bytes for an empty string "".
6 const compressedZstdBytes = new Uint8Array([
7 0x28, 0xb5, 0x2f, 0xfd, 0x24, 0x00, 0x01, 0x00, 0x00, 0x99, 0xe9, 0xd8, 0x51,
8 ]);
9
10 promise_test(async t => {
11 const ds = new DecompressionStream("zstd");
12 const writer = ds.writable.getWriter();
13 const reader = ds.readable.getReader();
14
15 const writePromise = writer.write(compressedZstdBytes);
16 const writerClosePromise = writer.close();
17
18 const { value, done } = await reader.read();
19
20 assert_true(done, "The done flag should be set after reading empty input");
21
22 await writePromise;
23 await writerClosePromise;
24
25 const decompressedText = new TextDecoder().decode(value);
26 assert_equals(
27 decompressedText,
28 "",
29 "The decompressed text should match the expected text"
30 );
31 }, "decompressing empty zstd input should yield an empty string");