mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-14 23:22:52 +00:00
These files seem to have been marked as executable by error. Found by running the command: find \( -name WPT -or -name Toolchain -or -name Build \) \ -prune -or -executable \! -type d -print \ | grep -Pv '\.(sh|py)$'
43 lines
1.3 KiB
HTML
43 lines
1.3 KiB
HTML
<script src="../include.js"></script>
|
|
<script>
|
|
function makeReadableByteStream() {
|
|
return new ReadableStream({
|
|
type: "bytes",
|
|
start(controller) {
|
|
const array = new Uint8Array([60, 61, 62, 63, 64, 65, 66, 67, 68, 69]);
|
|
println(`Enqueuing array ${array} onto ${controller}`);
|
|
controller.enqueue(array);
|
|
},
|
|
async pull(controller) {
|
|
println(`${controller.byobRequest} view: '${controller.byobRequest.view}'`);
|
|
const v = controller.byobRequest.view;
|
|
println(`Got view of buffer: ${new Uint8Array(v.buffer)}, offset ${v.byteOffset}, length ${v.byteLength}`);
|
|
controller.byobRequest.respond(1);
|
|
},
|
|
});
|
|
}
|
|
|
|
asyncTest(async done => {
|
|
let readableStream = makeReadableByteStream();
|
|
const reader = readableStream.getReader({ mode: "byob" });
|
|
let startingAB = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
|
|
const buffer = await readInto(startingAB);
|
|
println(`Final data: ${new Uint8Array(buffer)}`);
|
|
done();
|
|
|
|
async function readInto(buffer) {
|
|
let offset = 0;
|
|
while (offset < buffer.byteLength) {
|
|
let u8 = new Uint8Array(buffer, offset, buffer.byteLength - offset)
|
|
const { value: view, done } = await reader.read(u8);
|
|
buffer = view.buffer;
|
|
if (done) {
|
|
break;
|
|
}
|
|
offset += view.byteLength;
|
|
}
|
|
|
|
return buffer;
|
|
}
|
|
});
|
|
</script>
|