mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:57:44 +00:00
LibJS: Implement missing checks for SharedArrayBuffer values
This commit is contained in:
parent
299c86db20
commit
526a74f2f1
6 changed files with 46 additions and 6 deletions
|
@ -201,7 +201,7 @@ size_t array_buffer_byte_length(ArrayBuffer const& array_buffer, ArrayBuffer::Or
|
|||
ThrowCompletionOr<void> detach_array_buffer(VM& vm, ArrayBuffer& array_buffer, Optional<Value> key)
|
||||
{
|
||||
// 1. Assert: IsSharedArrayBuffer(arrayBuffer) is false.
|
||||
// FIXME: Check for shared buffer
|
||||
VERIFY(!array_buffer.is_shared_array_buffer());
|
||||
|
||||
// 2. If key is not present, set key to undefined.
|
||||
if (!key.has_value())
|
||||
|
|
|
@ -174,7 +174,8 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::slice)
|
|||
auto array_buffer_object = TRY(typed_this_value(vm));
|
||||
|
||||
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
|
||||
// FIXME: Check for shared buffer
|
||||
if (array_buffer_object->is_shared_array_buffer())
|
||||
return vm.throw_completion<TypeError>(ErrorType::SharedArrayBuffer);
|
||||
|
||||
// 4. If IsDetachedBuffer(O) is true, throw a TypeError exception.
|
||||
if (array_buffer_object->is_detached())
|
||||
|
@ -226,7 +227,8 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::slice)
|
|||
auto* new_array_buffer_object = static_cast<ArrayBuffer*>(new_array_buffer.ptr());
|
||||
|
||||
// 18. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
|
||||
// FIXME: Check for shared buffer
|
||||
if (new_array_buffer_object->is_shared_array_buffer())
|
||||
return vm.throw_completion<TypeError>(ErrorType::SharedArrayBuffer);
|
||||
|
||||
// 19. If IsDetachedBuffer(new) is true, throw a TypeError exception.
|
||||
if (new_array_buffer_object->is_detached())
|
||||
|
|
|
@ -40,7 +40,8 @@ JS_DEFINE_NATIVE_FUNCTION(SharedArrayBufferPrototype::byte_length_getter)
|
|||
auto array_buffer_object = TRY(typed_this_value(vm));
|
||||
|
||||
// 3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
|
||||
// FIXME: Check for shared buffer
|
||||
if (!array_buffer_object->is_shared_array_buffer())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotASharedArrayBuffer);
|
||||
|
||||
// 4. Let length be O.[[ArrayBufferByteLength]].
|
||||
// 5. Return 𝔽(length).
|
||||
|
@ -60,7 +61,8 @@ JS_DEFINE_NATIVE_FUNCTION(SharedArrayBufferPrototype::slice)
|
|||
auto array_buffer_object = TRY(typed_this_value(vm));
|
||||
|
||||
// 3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
|
||||
// FIXME: Check for shared buffer
|
||||
if (!array_buffer_object->is_shared_array_buffer())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotASharedArrayBuffer);
|
||||
|
||||
// 4. Let len be O.[[ArrayBufferByteLength]].
|
||||
auto length = array_buffer_object->byte_length();
|
||||
|
@ -108,7 +110,8 @@ JS_DEFINE_NATIVE_FUNCTION(SharedArrayBufferPrototype::slice)
|
|||
auto* new_array_buffer_object = static_cast<ArrayBuffer*>(new_array_buffer.ptr());
|
||||
|
||||
// 17. If IsSharedArrayBuffer(new) is true, throw a TypeError exception.
|
||||
// FIXME: Check for shared buffer
|
||||
if (!new_array_buffer_object->is_shared_array_buffer())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotASharedArrayBuffer);
|
||||
|
||||
// 18. If new.[[ArrayBufferData]] is O.[[ArrayBufferData]], throw a TypeError exception.
|
||||
if (new_array_buffer == array_buffer_object)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue