LibWeb: Provide an UInt8Array to AO writable_stream_default_writer_write

ReadLoopReadRequest::on_chunk expects an UInt8Array, so make sure we
convert the passed in ByteBuffer to an UInt8Array before passing it to
the AO writable_stream_default_writer_write.

Co-authored-by: Timothy Flynn <trflynn89@pm.me>
This commit is contained in:
Kenneth Myhra 2024-05-17 15:07:47 +02:00 committed by Tim Flynn
commit 15b677385c
Notes: sideshowbarker 2024-07-17 10:16:43 +09:00

View file

@ -306,9 +306,11 @@ JS::NonnullGCPtr<WebIDL::Promise> readable_stream_pipe_to(ReadableStream& source
// FIXME: Currently a naive implementation that uses ReadableStreamDefaultReader::read_all_chunks() to read all chunks
// from the source and then through the callback success_steps writes those chunks to the destination.
auto chunk_steps = [&realm, writer](ByteBuffer chunk) {
auto buffer = JS::ArrayBuffer::create(realm, move(chunk));
auto promise = writable_stream_default_writer_write(writer, JS::Value { buffer });
auto chunk_steps = [&realm, writer](ByteBuffer buffer) {
auto array_buffer = JS::ArrayBuffer::create(realm, move(buffer));
auto chunk = JS::Uint8Array::create(realm, array_buffer->byte_length(), *array_buffer);
auto promise = writable_stream_default_writer_write(writer, chunk);
WebIDL::resolve_promise(realm, promise, JS::js_undefined());
};