mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Add some compression WPT tests
These are relevant for the next commits.
This commit is contained in:
parent
1612c1688e
commit
1c836588d9
Notes:
github-actions[bot]
2025-03-19 12:49:07 +00:00
Author: https://github.com/devgianlu
Commit: 1c836588d9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3755
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/trflynn89
14 changed files with 457 additions and 0 deletions
|
@ -0,0 +1,41 @@
|
|||
// META: global=window,worker,shadowrealm
|
||||
// META: script=third_party/pako/pako_inflate.min.js
|
||||
// META: script=resources/concatenate-stream.js
|
||||
// META: timeout=long
|
||||
|
||||
'use strict';
|
||||
|
||||
// This test verifies that a large flush output will not truncate the
|
||||
// final results.
|
||||
|
||||
async function compressData(chunk, format) {
|
||||
const cs = new CompressionStream(format);
|
||||
const writer = cs.writable.getWriter();
|
||||
writer.write(chunk);
|
||||
writer.close();
|
||||
return await concatenateStream(cs.readable);
|
||||
}
|
||||
|
||||
// JSON-encoded array of 10 thousands numbers ("[0,1,2,...]"). This produces 48_891 bytes of data.
|
||||
const fullData = new TextEncoder().encode(JSON.stringify(Array.from({ length: 10_000 }, (_, i) => i)));
|
||||
const data = fullData.subarray(0, 35_579);
|
||||
const expectedValue = data;
|
||||
|
||||
promise_test(async t => {
|
||||
const compressedData = await compressData(data, 'deflate');
|
||||
// decompress with pako, and check that we got the same result as our original string
|
||||
assert_array_equals(expectedValue, pako.inflate(compressedData), 'value should match');
|
||||
}, `deflate compression with large flush output`);
|
||||
|
||||
promise_test(async t => {
|
||||
const compressedData = await compressData(data, 'gzip');
|
||||
// decompress with pako, and check that we got the same result as our original string
|
||||
assert_array_equals(expectedValue, pako.inflate(compressedData), 'value should match');
|
||||
}, `gzip compression with large flush output`);
|
||||
|
||||
promise_test(async t => {
|
||||
const compressedData = await compressData(data, 'deflate-raw');
|
||||
// decompress with pako, and check that we got the same result as our original string
|
||||
assert_array_equals(expectedValue, pako.inflateRaw(compressedData), 'value should match');
|
||||
}, `deflate-raw compression with large flush output`);
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue