mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
LibWeb/HTML: Port Window.structuredClone() to IDL
This commit is contained in:
parent
a31c561a5a
commit
129ab02470
8 changed files with 42 additions and 25 deletions
|
@ -12,6 +12,8 @@
|
|||
#include <LibTextCodec/Decoder.h>
|
||||
#include <LibWeb/Fetch/FetchMethod.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/StructuredSerialize.h>
|
||||
#include <LibWeb/HTML/WindowOrWorkerGlobalScope.h>
|
||||
#include <LibWeb/Infra/Base64.h>
|
||||
#include <LibWeb/WebIDL/DOMException.h>
|
||||
|
@ -84,6 +86,24 @@ WebIDL::ExceptionOr<String> WindowOrWorkerGlobalScopeMixin::atob(String const& d
|
|||
return TRY_OR_THROW_OOM(vm, decoder->to_utf8(decoded_data.value()));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/structured-data.html#dom-structuredclone
|
||||
WebIDL::ExceptionOr<JS::Value> WindowOrWorkerGlobalScopeMixin::structured_clone(JS::Value value, StructuredSerializeOptions const& options) const
|
||||
{
|
||||
auto& vm = this_impl().vm();
|
||||
(void)options;
|
||||
|
||||
// 1. Let serialized be ? StructuredSerializeWithTransfer(value, options["transfer"]).
|
||||
// FIXME: Use WithTransfer variant of the AO
|
||||
auto serialized = TRY(structured_serialize(vm, value));
|
||||
|
||||
// 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()), {}));
|
||||
|
||||
// 3. Return deserializeRecord.[[Deserialized]].
|
||||
return deserialized;
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<JS::Promise> WindowOrWorkerGlobalScopeMixin::fetch(Fetch::RequestInfo const& input, Fetch::RequestInit const& init) const
|
||||
{
|
||||
auto& vm = this_impl().vm();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue