1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:27:35 +00:00

LibJS: Add 'is detached' check to InitializeTypedArrayFromTypedArray()

Resolves a FIXME.
This commit is contained in:
Linus Groh 2021-06-27 20:53:29 +01:00
parent 48e7fd52e7
commit 93bae37dd9

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -103,10 +103,14 @@ static void initialize_typed_array_from_typed_array(GlobalObject& global_object,
return;
}
// FIXME: 17.b If IsDetachedBuffer(array_buffer) is true, throw a TypeError exception.
// FIXME: 17.c If src_array.[[ContentType]] != dest_array.[[ContentType]], throw a TypeError exception.
auto data = ArrayBuffer::create(global_object, byte_length.value());
if (src_data->is_detached()) {
vm.throw_exception<TypeError>(global_object, ErrorType::DetachedArrayBuffer);
return;
}
dest_array.set_viewed_array_buffer(data);
dest_array.set_byte_length(byte_length.value());
dest_array.set_byte_offset(0);