diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-04-07 13:06:40 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-04-08 11:15:16 +0100 |
commit | d04a683f854b6da974c02c52678141945fbb1ec9 (patch) | |
tree | a6fa33e0cc3603ed5efa6ba8be6b6d20145f2a84 | |
parent | 13d05403ffd5307e57a327915f34c73742dcdefb (diff) | |
download | serenity-d04a683f854b6da974c02c52678141945fbb1ec9.zip |
test-js: Define detachArrayBuffer global function
-rw-r--r-- | Tests/LibJS/test-js.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Tests/LibJS/test-js.cpp b/Tests/LibJS/test-js.cpp index ce9301576b..25df3404dd 100644 --- a/Tests/LibJS/test-js.cpp +++ b/Tests/LibJS/test-js.cpp @@ -5,6 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <LibJS/Runtime/ArrayBuffer.h> #include <LibTest/JavaScriptTestRunner.h> TEST_ROOT("Userland/Libraries/LibJS/Tests"); @@ -76,6 +77,16 @@ TESTJS_GLOBAL_FUNCTION(mark_as_garbage, markAsGarbage) return JS::js_undefined(); } +TESTJS_GLOBAL_FUNCTION(detach_array_buffer, detachArrayBuffer) +{ + auto array_buffer = vm.argument(0); + if (!array_buffer.is_object() || !is<JS::ArrayBuffer>(array_buffer.as_object())) + return vm.throw_completion<JS::TypeError>(global_object, JS::ErrorType::NotAnObjectOfType, "ArrayBuffer"); + + auto& array_buffer_object = static_cast<JS::ArrayBuffer&>(array_buffer.as_object()); + return JS::detach_array_buffer(global_object, array_buffer_object, vm.argument(1)); +} + TESTJS_RUN_FILE_FUNCTION(String const& test_file, JS::Interpreter& interpreter, JS::ExecutionContext&) { if (!test262_parser_tests) |