mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-30 05:09:01 +00:00
LibJS: Throw TypeError on non-object this value in ArrayBuffer methods
`1. If Type(O) is not Object, throw a TypeError exception.`
This commit is contained in:
parent
bc95201aaf
commit
7d6db3f09b
Notes:
sideshowbarker
2024-07-18 12:28:18 +09:00
Author: https://github.com/IdanHo
Commit: 7d6db3f09b
Pull-request: https://github.com/SerenityOS/serenity/pull/7974
Reviewed-by: https://github.com/linusg
1 changed files with 2 additions and 5 deletions
|
@ -37,14 +37,11 @@ static ArrayBuffer* array_buffer_object_from(VM& vm, GlobalObject& global_object
|
||||||
{
|
{
|
||||||
// ArrayBuffer.prototype.* deliberately don't coerce |this| value to object.
|
// ArrayBuffer.prototype.* deliberately don't coerce |this| value to object.
|
||||||
auto this_value = vm.this_value(global_object);
|
auto this_value = vm.this_value(global_object);
|
||||||
if (!this_value.is_object())
|
if (!this_value.is_object() || !is<ArrayBuffer>(this_value.as_object())) {
|
||||||
return nullptr;
|
|
||||||
auto& this_object = this_value.as_object();
|
|
||||||
if (!is<ArrayBuffer>(this_object)) {
|
|
||||||
vm.throw_exception<TypeError>(global_object, ErrorType::NotAn, "ArrayBuffer");
|
vm.throw_exception<TypeError>(global_object, ErrorType::NotAn, "ArrayBuffer");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return static_cast<ArrayBuffer*>(&this_object);
|
return static_cast<ArrayBuffer*>(&this_value.as_object());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 25.1.5.3 ArrayBuffer.prototype.slice, https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice
|
// 25.1.5.3 ArrayBuffer.prototype.slice, https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue