node/test/fixtures/wpt/compression/decompression-empty-input.any.js
Filip Skokan 7feff3a715 test: update WPT compression to ae05f5cb53
PR-URL: https://github.com/nodejs/node/pull/62107
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Mattias Buelens <mattias@buelens.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-03-06 22:08:55 +00:00

24 lines
870 B
JavaScript

// META: global=window,worker,shadowrealm
'use strict';
const emptyValues = [
["gzip", new Uint8Array([31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0])],
["deflate", new Uint8Array([120, 156, 3, 0, 0, 0, 0, 1])],
["deflate-raw", new Uint8Array([1, 0, 0, 255, 255])],
["brotli", new Uint8Array([0xa1, 0x01])],
];
for (const [format, emptyValue] of emptyValues) {
promise_test(async t => {
const ds = new DecompressionStream(format);
const reader = ds.readable.getReader();
const writer = ds.writable.getWriter();
const writePromise = writer.write(emptyValue);
writer.close();
const { value, done } = await reader.read();
assert_true(done, "read() should set done");
assert_equals(value, undefined, "value should be undefined");
await writePromise;
}, `decompressing ${format} empty input should work`);
}