gecko-dev/testing/web-platform/mozilla/tests/compression/zstd/decompression-empty-input.tentative.any.js
Erik Nordin 331f3ae514 Bug 1947431 - Implement ZstdDecompressionAlgorithms r=saschanaz,jesup
This patch introduces a DecompressionStreamAlgorithms abstract base
class, which is implemented by ZLibDecompressionStreamAlgorithms and
ZstdDecompressionStreamAlgorithms.

It also introduces a new static pref for the "zstd" format to be used
with CompressionStream and DecompressionStream, and introduces new WPTs
for zstd DecompressionStream with equivalent coverage to those for ZLib.

Differential Revision: https://phabricator.services.mozilla.com/D238685
2025-03-03 21:26:53 +00:00

31 lines
906 B
JavaScript

// META: global=window,worker
"use strict";
// The zstd-compressed bytes for an empty string "".
const compressedZstdBytes = new Uint8Array([
0x28, 0xb5, 0x2f, 0xfd, 0x24, 0x00, 0x01, 0x00, 0x00, 0x99, 0xe9, 0xd8, 0x51,
]);
promise_test(async t => {
const ds = new DecompressionStream("zstd");
const writer = ds.writable.getWriter();
const reader = ds.readable.getReader();
const writePromise = writer.write(compressedZstdBytes);
const writerClosePromise = writer.close();
const { value, done } = await reader.read();
assert_true(done, "The done flag should be set after reading empty input");
await writePromise;
await writerClosePromise;
const decompressedText = new TextDecoder().decode(value);
assert_equals(
decompressedText,
"",
"The decompressed text should match the expected text"
);
}, "decompressing empty zstd input should yield an empty string");