LibWeb: Implement ReadableStream transfer

This commit is contained in:
Timothy Flynn 2025-05-20 17:20:22 -04:00 committed by Tim Flynn
parent 7e225b496d
commit 312db85a84
Notes: github-actions[bot] 2025-05-21 10:56:01 +00:00
9 changed files with 511 additions and 28 deletions

View file

@ -49,6 +49,7 @@
#include <LibWeb/HTML/ImageData.h>
#include <LibWeb/HTML/MessagePort.h>
#include <LibWeb/HTML/StructuredSerialize.h>
#include <LibWeb/Streams/ReadableStream.h>
#include <LibWeb/WebIDL/DOMException.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
@ -1293,7 +1294,8 @@ static bool is_interface_exposed_on_target_realm(TransferType name, JS::Realm& r
switch (name) {
case TransferType::MessagePort:
return intrinsics.is_exposed("MessagePort"sv);
break;
case TransferType::ReadableStream:
return intrinsics.is_exposed("ReadableStream"sv);
case TransferType::Unknown:
dbgln("Unknown interface type for transfer: {}", to_underlying(name));
break;
@ -1311,6 +1313,11 @@ static WebIDL::ExceptionOr<GC::Ref<Bindings::PlatformObject>> create_transferred
TRY(message_port->transfer_receiving_steps(transfer_data_holder));
return message_port;
}
case TransferType::ReadableStream: {
auto readable_stream = target_realm.create<Streams::ReadableStream>(target_realm);
TRY(readable_stream->transfer_receiving_steps(transfer_data_holder));
return readable_stream;
}
case TransferType::ArrayBuffer:
case TransferType::ResizableArrayBuffer:
dbgln("ArrayBuffer ({}) is not a platform object.", to_underlying(name));