LibWeb: Treat BufferSource as a DataView/ArrayBuffer/TA in IDL overloads

Required by WebAssembly.instantiate.
This commit is contained in:
Luke Wilde 2023-11-14 02:43:44 +00:00 committed by Andreas Kling
parent 54972e3ceb
commit 7e8d3e370f
Notes: sideshowbarker 2024-07-17 09:41:18 +09:00
3 changed files with 130 additions and 3 deletions

View file

@ -186,7 +186,7 @@ JS::ThrowCompletionOr<ResolvedOverload> resolve_overload(JS::VM& vm, IDL::Effect
// then remove from S all other entries.
else if (value.is_object() && is<JS::ArrayBuffer>(value.as_object())
&& has_overload_with_argument_type_or_subtype_matching(overloads, i, [](IDL::Type const& type) {
if (type.is_plain() && type.name() == "ArrayBuffer")
if (type.is_plain() && (type.name() == "ArrayBuffer" || type.name() == "BufferSource"))
return true;
if (type.is_object())
return true;
@ -204,7 +204,7 @@ JS::ThrowCompletionOr<ResolvedOverload> resolve_overload(JS::VM& vm, IDL::Effect
// then remove from S all other entries.
else if (value.is_object() && is<JS::DataView>(value.as_object())
&& has_overload_with_argument_type_or_subtype_matching(overloads, i, [](IDL::Type const& type) {
if (type.is_plain() && type.name() == "DataView")
if (type.is_plain() && (type.name() == "DataView" || type.name() == "BufferSource"))
return true;
if (type.is_object())
return true;
@ -222,7 +222,7 @@ JS::ThrowCompletionOr<ResolvedOverload> resolve_overload(JS::VM& vm, IDL::Effect
// then remove from S all other entries.
else if (value.is_object() && value.as_object().is_typed_array()
&& has_overload_with_argument_type_or_subtype_matching(overloads, i, [&](IDL::Type const& type) {
if (type.is_plain() && type.name() == static_cast<JS::TypedArrayBase const&>(value.as_object()).element_name())
if (type.is_plain() && (type.name() == static_cast<JS::TypedArrayBase const&>(value.as_object()).element_name() || type.name() == "BufferSource"))
return true;
if (type.is_object())
return true;