mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
LibWeb: Use (de)serialization with transfer AOs for structured cloning
This is important, for example, to detach transferred array buffers.
This commit is contained in:
parent
5eab109d85
commit
60f667fc5a
Notes:
github-actions[bot]
2025-04-17 17:47:36 +00:00
Author: https://github.com/trflynn89
Commit: 60f667fc5a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4386
2 changed files with 6 additions and 9 deletions
|
@ -93,19 +93,16 @@ void UniversalGlobalScopeMixin::queue_microtask(WebIDL::CallbackType& callback)
|
|||
// https://html.spec.whatwg.org/multipage/structured-data.html#dom-structuredclone
|
||||
WebIDL::ExceptionOr<JS::Value> UniversalGlobalScopeMixin::structured_clone(JS::Value value, StructuredSerializeOptions const& options) const
|
||||
{
|
||||
auto& vm = this_impl().vm();
|
||||
(void)options;
|
||||
auto& realm = HTML::relevant_realm(this_impl());
|
||||
|
||||
// 1. Let serialized be ? StructuredSerializeWithTransfer(value, options["transfer"]).
|
||||
// FIXME: Use WithTransfer variant of the AO
|
||||
auto serialized = TRY(structured_serialize(vm, value));
|
||||
auto serialized = TRY(structured_serialize_with_transfer(realm.vm(), value, options.transfer));
|
||||
|
||||
// 2. Let deserializeRecord be ? StructuredDeserializeWithTransfer(serialized, this's relevant realm).
|
||||
// FIXME: Use WithTransfer variant of the AO
|
||||
auto deserialized = TRY(structured_deserialize(vm, serialized, relevant_realm(this_impl())));
|
||||
auto deserialized = TRY(structured_deserialize_with_transfer(serialized, realm));
|
||||
|
||||
// 3. Return deserializeRecord.[[Deserialized]].
|
||||
return deserialized;
|
||||
return deserialized.deserialized;
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#count-queuing-strategy-size-function
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue