mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
LibWeb: Implement MessagePort.postMessage closer to the spec
Use a LocalSocket to represent the connection between two message ports. The concept of the port message queue is still missing, however. When that concept is implemented, the "steps" in step 7 of the message port transfer steps will need to send the serialized data over the connected socketpair and run in the event loop of the process that holds onto the other side of the message port. Doing this should allow centralizing the behavior of postMessage for Window, MessagePorts and Workers.
This commit is contained in:
committed by
Andreas Kling
parent
c7f7ee2c4b
commit
f68c67bf3f
@@ -1019,7 +1019,7 @@ static bool is_interface_exposed_on_target_realm(u8 name, JS::Realm& realm)
|
||||
return false;
|
||||
}
|
||||
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Bindings::PlatformObject>> create_transferred_value(TransferType name, JS::Realm& target_realm, TransferDataHolder const& transfer_data_holder)
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Bindings::PlatformObject>> create_transferred_value(TransferType name, JS::Realm& target_realm, TransferDataHolder& transfer_data_holder)
|
||||
{
|
||||
switch (name) {
|
||||
case TransferType::MessagePort: {
|
||||
@@ -1032,7 +1032,7 @@ static WebIDL::ExceptionOr<JS::NonnullGCPtr<Bindings::PlatformObject>> create_tr
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/structured-data.html#structureddeserializewithtransfer
|
||||
WebIDL::ExceptionOr<DeserializedTransferRecord> structured_deserialize_with_transfer(JS::VM& vm, SerializedTransferRecord const& serialize_with_transfer_result)
|
||||
WebIDL::ExceptionOr<DeserializedTransferRecord> structured_deserialize_with_transfer(JS::VM& vm, SerializedTransferRecord& serialize_with_transfer_result)
|
||||
{
|
||||
auto& target_realm = *vm.current_realm();
|
||||
|
||||
@@ -1068,7 +1068,7 @@ WebIDL::ExceptionOr<DeserializedTransferRecord> structured_deserialize_with_tran
|
||||
// 4. Otherwise:
|
||||
else {
|
||||
// 1. Let interfaceName be transferDataHolder.[[Type]].
|
||||
u8 const interface_name = transfer_data_holder.data[0];
|
||||
u8 const interface_name = transfer_data_holder.data.take_first();
|
||||
|
||||
// 2. If the interface identified by interfaceName is not exposed in targetRealm, then throw a "DataCloneError" DOMException.
|
||||
if (!is_interface_exposed_on_target_realm(interface_name, target_realm))
|
||||
|
||||
Reference in New Issue
Block a user