From 7e8d3e370f34fd935be7ad2c35176fb50d23b12a Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Tue, 14 Nov 2023 02:43:44 +0000 Subject: [PATCH] LibWeb: Treat BufferSource as a DataView/ArrayBuffer/TA in IDL overloads Required by WebAssembly.instantiate. --- .../expected/Wasm/WebAssembly-instantiate.txt | 16 +++ .../input/Wasm/WebAssembly-instantiate.html | 111 ++++++++++++++++++ .../LibWeb/WebIDL/OverloadResolution.cpp | 6 +- 3 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/Wasm/WebAssembly-instantiate.txt create mode 100644 Tests/LibWeb/Text/input/Wasm/WebAssembly-instantiate.html diff --git a/Tests/LibWeb/Text/expected/Wasm/WebAssembly-instantiate.txt b/Tests/LibWeb/Text/expected/Wasm/WebAssembly-instantiate.txt new file mode 100644 index 00000000000..a10952f22b1 --- /dev/null +++ b/Tests/LibWeb/Text/expected/Wasm/WebAssembly-instantiate.txt @@ -0,0 +1,16 @@ +------------- +ArrayBuffer +------------- +Hello from wasm!!!!!! +FIXME: Run test for Uint8Array. Not running due to flakiness. +FIXME: Run test for Uint8ClampedArray. Not running due to flakiness. +FIXME: Run test for Uint16Array. Not running due to flakiness. +FIXME: Run test for Uint32Array. Not running due to flakiness. +FIXME: Run test for Int8Array. Not running due to flakiness. +FIXME: Run test for Int16Array. Not running due to flakiness. +FIXME: Run test for Float32Array. Not running due to flakiness. +FIXME: Run test for Float64Array. Not running due to flakiness. +FIXME: Run test for BigUint64Array. Not running due to flakiness. +FIXME: Run test for BigInt64Array. Not running due to flakiness. +FIXME: Run test for DataView. Not running due to flakiness. +FIXME: Run test for WebAssembly.Module. Not running due to flakiness. \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/Wasm/WebAssembly-instantiate.html b/Tests/LibWeb/Text/input/Wasm/WebAssembly-instantiate.html new file mode 100644 index 00000000000..7015f87bb90 --- /dev/null +++ b/Tests/LibWeb/Text/input/Wasm/WebAssembly-instantiate.html @@ -0,0 +1,111 @@ + + diff --git a/Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp b/Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp index 8678c460b27..3a5007b4bab 100644 --- a/Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp +++ b/Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp @@ -186,7 +186,7 @@ JS::ThrowCompletionOr resolve_overload(JS::VM& vm, IDL::Effect // then remove from S all other entries. else if (value.is_object() && is(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 resolve_overload(JS::VM& vm, IDL::Effect // then remove from S all other entries. else if (value.is_object() && is(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 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(value.as_object()).element_name()) + if (type.is_plain() && (type.name() == static_cast(value.as_object()).element_name() || type.name() == "BufferSource")) return true; if (type.is_object()) return true;