summaryrefslogtreecommitdiff
path: root/Meta
diff options
context:
space:
mode:
authorKenneth Myhra <kennethmyhra@gmail.com>2022-07-21 22:41:59 +0200
committerLinus Groh <mail@linusgroh.de>2022-07-22 10:18:53 +0100
commit114120852de801fb83fc83c7357eff36a0d34ad2 (patch)
treedcb5d70b144d434e14183d60cfb204c9253dc33a /Meta
parentb8d4f8debf46e9591102bf8d609b4f32cab6b3f3 (diff)
downloadserenity-114120852de801fb83fc83c7357eff36a0d34ad2.zip
LibWeb/IDL: Handle passing ArrayBuffer to an IDL union type
This fixes a bug where an ArrayBuffer passed to the Blob constructor would just be stringified to: "[object ArrayBuffer]".
Diffstat (limited to 'Meta')
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
index b33ef70b06..8d267a4254 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
@@ -1001,9 +1001,22 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
)~~~");
}
- // FIXME: 6. If Type(V) is Object and V has an [[ArrayBufferData]] internal slot, then
- // 1. If types includes ArrayBuffer, then return the result of converting V to ArrayBuffer.
- // 2. If types includes object, then return the IDL value that is a reference to the object V.
+ // 6. If Type(V) is Object and V has an [[ArrayBufferData]] internal slot, then
+ // 1. If types includes ArrayBuffer, then return the result of converting V to ArrayBuffer.
+ for (auto& type : types) {
+ if (type.name == "BufferSource") {
+ union_generator.append(R"~~~(
+ if (is<JS::ArrayBuffer>(@js_name@@js_suffix@_object))
+ return JS::make_handle(@js_name@@js_suffix@_object);
+)~~~");
+ }
+ }
+ // 2. If types includes object, then return the IDL value that is a reference to the object V.
+ if (includes_object) {
+ union_generator.append(R"~~~(
+ return @js_name@@js_suffix@_object;
+)~~~");
+ }
// FIXME: 7. If Type(V) is Object and V has a [[DataView]] internal slot, then:
// 1. If types includes DataView, then return the result of converting V to DataView.
@@ -2835,6 +2848,7 @@ void generate_constructor_implementation(IDL::Interface const& interface)
#include <LibJS/Heap/Heap.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/IteratorOperations.h>
+#include <LibJS/Runtime/ArrayBuffer.h>
#include <LibWeb/Bindings/@constructor_class@.h>
#include <LibWeb/Bindings/@prototype_class@.h>
#include <LibWeb/Bindings/@wrapper_class@.h>