Debian Codegraph @

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

raw
1 // META: global=window,worker
2
3 "use strict";
4
5 // The zstd-compressed bytes for the string "expected output".
6 const compressedZstdBytes = 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(compressedZstdBytes);
18 const writerClosePromise = writer.close();
19
20 const { value, done } = await reader.read();
21
22 assert_false(
23 done,
24 "The done flag should not be set after reading valid input"
25 );
26
27 await writePromise;
28 await writerClosePromise;
29
30 const decompressedText = new TextDecoder().decode(value);
31 assert_equals(
32 decompressedText,
33 "expected output",
34 "The decompressed text should match the expected text"
35 );
36 }, "decompressing valid zstd input should yield 'expected output'");