LibWeb: Implement WritableStream transfer

This commit is contained in:
Timothy Flynn 2025-05-20 17:27:51 -04:00 committed by Tim Flynn
parent 312db85a84
commit cca08ad833
Notes: github-actions[bot] 2025-05-21 10:55:54 +00:00
6 changed files with 260 additions and 26 deletions

View file

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