diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2022-02-08 21:36:58 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-02-08 23:08:43 +0000 |
commit | 9839e2eeb649590bbdc7ed5ddd191e45f347b737 (patch) | |
tree | 677a0de3898e10cb825cf745e4c6ae4d9acb84d9 /Userland/Libraries | |
parent | 20d3869182c25e1255ad57277cd9d84575564d83 (diff) | |
download | serenity-9839e2eeb649590bbdc7ed5ddd191e45f347b737.zip |
LibJS: Implement the missing step 20 in %TypedArray%.prototype.set
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp index d3ac4fdcdf..1cb47f9e5e 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp @@ -7,6 +7,7 @@ */ #include <LibJS/Runtime/AbstractOperations.h> +#include <LibJS/Runtime/ArrayBufferConstructor.h> #include <LibJS/Runtime/ArrayIterator.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/TypedArray.h> @@ -694,10 +695,14 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::set) // 20. If same is true, then if (same) { // a. Let srcByteLength be source.[[ByteLength]]. + auto source_byte_length = source_typed_array.byte_length(); + // b. Set srcBuffer to ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcByteLength, %ArrayBuffer%). + source_buffer = TRY(clone_array_buffer(global_object, *source_buffer, source_byte_offset, source_byte_length, *global_object.array_buffer_constructor())); // c. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not have any observable side-effects. + // d. Let srcByteIndex be 0. - TODO(); + source_byte_index = 0; } else { // 21. Else, let srcByteIndex be srcByteOffset. source_byte_index = source_byte_offset; |