mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-04 16:11:54 +00:00
Instead of checking the header in ZlibDecompressor::create(), we now check it in read_some() when it is called for the first time. This resolves a FIXME in the new DecompressionStream implementation.
36 lines
1.2 KiB
HTML
36 lines
1.2 KiB
HTML
<script src="../include.js"></script>
|
|
<script>
|
|
asyncTest(async done => {
|
|
const data = [
|
|
{ format: "deflate", text: "eJwLT83JUchIzcnJV0grykzNSylWBABGEQb1" },
|
|
{ format: "deflate-raw", text: "C0/NyVHISM3JyVdIK8pMzUspVgQA" },
|
|
{ format: "gzip", text: "H4sIAAAAAAADAwtPzclRyEjNyclXSCvKTM1LKVYEAHN0w4sTAAAA" },
|
|
];
|
|
|
|
for (const test of data) {
|
|
const text = Uint8Array.fromBase64(test.text);
|
|
let stream = new Blob([text]).stream();
|
|
|
|
let decompressor = stream.pipeThrough(new DecompressionStream(test.format));
|
|
let reader = decompressor.getReader();
|
|
|
|
let buffer = new ArrayBuffer(256);
|
|
let offset = 0;
|
|
|
|
while (true) {
|
|
let result = await reader.read();
|
|
if (result.done) {
|
|
break;
|
|
}
|
|
|
|
new Uint8Array(buffer).set(result.value, offset);
|
|
offset += result.value.byteLength;
|
|
}
|
|
|
|
let result = String.fromCharCode.apply(null, new Uint8Array(buffer, 0, offset));
|
|
println(`format=${test.format}: ${result}`);
|
|
}
|
|
|
|
done();
|
|
});
|
|
</script>
|