mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-04 15:09:40 +00:00
LibWeb: Implement the StructuredClone AO
This commit is contained in:
parent
59716f807f
commit
5ccd1ff1bf
|
@ -16,6 +16,7 @@
|
|||
#include <LibJS/Runtime/TypedArray.h>
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/DOM/AbortSignal.h>
|
||||
#include <LibWeb/HTML/StructuredSerialize.h>
|
||||
#include <LibWeb/Streams/AbstractOperations.h>
|
||||
#include <LibWeb/Streams/QueuingStrategy.h>
|
||||
#include <LibWeb/Streams/ReadableByteStreamController.h>
|
||||
|
@ -3923,6 +3924,18 @@ bool can_transfer_array_buffer(JS::ArrayBuffer const& array_buffer)
|
|||
return true;
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#abstract-opdef-structuredclone
|
||||
WebIDL::ExceptionOr<JS::Value> structured_clone(JS::Realm& realm, JS::Value value)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
|
||||
// 1. Let serialized be ? StructuredSerialize(v).
|
||||
auto serialized = TRY(HTML::structured_serialize(vm, value));
|
||||
|
||||
// 2. Return ? StructuredDeserialize(serialized, the current Realm).
|
||||
return TRY(HTML::structured_deserialize(vm, serialized, realm, {}));
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#close-sentinel
|
||||
// Non-standard function that implements the "close sentinel" value.
|
||||
JS::Value create_close_sentinel()
|
||||
|
|
|
@ -175,6 +175,7 @@ WebIDL::ExceptionOr<void> transform_stream_set_backpressure(TransformStream&, bo
|
|||
|
||||
bool is_non_negative_number(JS::Value);
|
||||
bool can_transfer_array_buffer(JS::ArrayBuffer const& array_buffer);
|
||||
WebIDL::ExceptionOr<JS::Value> structured_clone(JS::Realm&, JS::Value value);
|
||||
|
||||
JS::Value create_close_sentinel();
|
||||
bool is_close_sentinel(JS::Value);
|
||||
|
|
Loading…
Reference in a new issue