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

LibJS: Change error message for values that can't be a SharedArrayBuffer

This error will be used in contexts that apply to more than than the
|this| object.
This commit is contained in:
Timothy Flynn 2023-12-28 09:19:51 -05:00 committed by Andreas Kling
parent 834ced9ef8
commit 299c86db20
2 changed files with 5 additions and 5 deletions

View file

@ -48,7 +48,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::byte_length_getter)
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
if (array_buffer_object->is_shared_array_buffer())
return vm.throw_completion<TypeError>(ErrorType::ThisCannotBeSharedArrayBuffer);
return vm.throw_completion<TypeError>(ErrorType::SharedArrayBuffer);
// NOTE: These steps are done in byte_length()
// 4. If IsDetachedBuffer(O) is true, return +0𝔽.
@ -66,7 +66,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::max_byte_length)
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
if (array_buffer_object->is_shared_array_buffer())
return vm.throw_completion<TypeError>(ErrorType::ThisCannotBeSharedArrayBuffer);
return vm.throw_completion<TypeError>(ErrorType::SharedArrayBuffer);
// 4. If IsDetachedBuffer(O) is true, return +0𝔽.
if (array_buffer_object->is_detached())
@ -98,7 +98,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::resizable)
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
if (array_buffer_object->is_shared_array_buffer())
return vm.throw_completion<TypeError>(ErrorType::ThisCannotBeSharedArrayBuffer);
return vm.throw_completion<TypeError>(ErrorType::SharedArrayBuffer);
// 4. If IsFixedLengthArrayBuffer(O) is false, return true; otherwise return false.
return Value { !array_buffer_object->is_fixed_length() };
@ -118,7 +118,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::resize)
// 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
if (array_buffer_object->is_shared_array_buffer())
return vm.throw_completion<TypeError>(ErrorType::ThisCannotBeSharedArrayBuffer);
return vm.throw_completion<TypeError>(ErrorType::SharedArrayBuffer);
// 4. Let newByteLength be ? ToIndex(newLength).
auto new_byte_length = TRY(new_length.to_index(vm));

View file

@ -224,6 +224,7 @@
M(RestrictedGlobalProperty, "Cannot declare global property '{}'") \
M(ShadowRealmEvaluateAbruptCompletion, "The evaluated script did not complete normally") \
M(ShadowRealmWrappedValueNonFunctionObject, "Wrapped value must be primitive or a function object, got {}") \
M(SharedArrayBuffer, "The array buffer object cannot be a SharedArrayBuffer") \
M(SpeciesConstructorDidNotCreate, "Species constructor did not create {}") \
M(SpeciesConstructorReturned, "Species constructor returned {}") \
M(StringNonGlobalRegExp, "RegExp argument is non-global") \
@ -298,7 +299,6 @@
M(TemporalUnknownCriticalAnnotation, "Unknown annotation key in critical annotation: '{}'") \
M(TemporalZonedDateTimeRoundZeroOrNegativeLengthDay, "Cannot round a ZonedDateTime in a calendar or time zone that has zero or " \
"negative length days") \
M(ThisCannotBeSharedArrayBuffer, "|this| cannot be a SharedArrayBuffer") \
M(ThisHasNotBeenInitialized, "|this| has not been initialized") \
M(ThisIsAlreadyInitialized, "|this| is already initialized") \
M(ToObjectNullOrUndefined, "ToObject on null or undefined") \