diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp index 6d972329e8..f18fda4dff 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp @@ -176,8 +176,7 @@ ThrowCompletionOr clone_array_buffer(VM& vm, ArrayBuffer& source_b auto& target_block = target_buffer->buffer(); // 5. Perform CopyDataBlockBytes(targetBlock, 0, srcBlock, srcByteOffset, srcLength). - // FIXME: This is only correct for ArrayBuffers, once SharedArrayBuffer is implemented, the AO has to be implemented - target_block.overwrite(0, source_block.offset_pointer(source_byte_offset), source_length); + copy_data_block_bytes(target_block, 0, source_block, source_byte_offset, source_length); // 6. Return targetBuffer. return target_buffer; diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp index ef6f085737..e8246897a1 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp @@ -115,10 +115,13 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::slice) return vm.throw_completion(ErrorType::DetachedArrayBuffer); // 24. Let fromBuf be O.[[ArrayBufferData]]. + auto& from_buf = array_buffer_object->buffer(); + // 25. Let toBuf be new.[[ArrayBufferData]]. + auto& to_buf = new_array_buffer_object->buffer(); + // 26. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, newLen). - // FIXME: Implement this to specification - array_buffer_object->buffer().span().slice(first, new_length).copy_to(new_array_buffer_object->buffer().span()); + copy_data_block_bytes(to_buf, 0, from_buf, first, new_length); // 27. Return new. return new_array_buffer_object;