mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-17 07:50:04 +00:00
LibWeb: Implement the CompressionStream interface
This commit is contained in:
parent
c0da3e356a
commit
638a8aecad
Notes:
github-actions[bot]
2024-11-17 22:21:57 +00:00
Author: https://github.com/trflynn89
Commit: 638a8aecad
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2370
10 changed files with 303 additions and 1 deletions
31
Tests/LibWeb/Text/input/Compression/CompressionStream.html
Normal file
31
Tests/LibWeb/Text/input/Compression/CompressionStream.html
Normal file
|
@ -0,0 +1,31 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
asyncTest(async done => {
|
||||
const text = "Well hello friends!";
|
||||
|
||||
for (const format of ["deflate", "deflate-raw", "gzip"]) {
|
||||
let stream = new Blob([text]).stream();
|
||||
|
||||
let compressor = stream.pipeThrough(new CompressionStream(format));
|
||||
let reader = compressor.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 = new Uint8Array(buffer, 0, offset).toBase64();
|
||||
println(`format=${format}: ${result}`);
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue