mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibJS: Remove argument count checks in Object.* methods
These are inconsistent with the specification.
This commit is contained in:
parent
b9d4dd6850
commit
a2da3f97ef
3 changed files with 0 additions and 33 deletions
|
@ -21,7 +21,6 @@
|
|||
M(ClassIsAbstract, "Abstract class {} cannot be constructed directly") \
|
||||
M(ConstructorWithoutNew, "{} constructor must be called with 'new'") \
|
||||
M(Convert, "Cannot convert {} to {}") \
|
||||
M(ConvertUndefinedToObject, "Cannot convert undefined to object") \
|
||||
M(DescChangeNonConfigurable, "Cannot change attributes of non-configurable property '{}'") \
|
||||
M(DescWriteNonWritable, "Cannot write to non-writable property '{}'") \
|
||||
M(DetachedArrayBuffer, "ArrayBuffer is detached") \
|
||||
|
@ -59,7 +58,6 @@
|
|||
M(ObjectFreezeFailed, "Could not freeze object") \
|
||||
M(ObjectSealFailed, "Could not seal object") \
|
||||
M(ObjectSetPrototypeOfReturnedFalse, "Object's [[SetPrototypeOf]] method returned false") \
|
||||
M(ObjectSetPrototypeOfTwoArgs, "Object.setPrototypeOf requires at least two arguments") \
|
||||
M(ObjectPreventExtensionsReturnedFalse, "Object's [[PreventExtensions]] method returned false") \
|
||||
M(ObjectPrototypeNullOrUndefinedOnSuperPropertyAccess, \
|
||||
"Object prototype must not be {} on a super property access") \
|
||||
|
|
|
@ -68,8 +68,6 @@ Value ObjectConstructor::construct(Function&)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_names)
|
||||
{
|
||||
if (!vm.argument_count())
|
||||
return {};
|
||||
auto* object = vm.argument(0).to_object(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
@ -78,8 +76,6 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_names)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_prototype_of)
|
||||
{
|
||||
if (!vm.argument_count())
|
||||
return {};
|
||||
auto* object = vm.argument(0).to_object(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
@ -88,10 +84,6 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_prototype_of)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::set_prototype_of)
|
||||
{
|
||||
if (vm.argument_count() < 2) {
|
||||
vm.throw_exception<TypeError>(global_object, ErrorType::ObjectSetPrototypeOfTwoArgs);
|
||||
return {};
|
||||
}
|
||||
auto* object = vm.argument(0).to_object(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
@ -247,11 +239,6 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::is)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::keys)
|
||||
{
|
||||
if (!vm.argument_count()) {
|
||||
vm.throw_exception<TypeError>(global_object, ErrorType::ConvertUndefinedToObject);
|
||||
return {};
|
||||
}
|
||||
|
||||
auto* obj_arg = vm.argument(0).to_object(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
@ -261,10 +248,6 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::keys)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::values)
|
||||
{
|
||||
if (!vm.argument_count()) {
|
||||
vm.throw_exception<TypeError>(global_object, ErrorType::ConvertUndefinedToObject);
|
||||
return {};
|
||||
}
|
||||
auto* obj_arg = vm.argument(0).to_object(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
@ -274,10 +257,6 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::values)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::entries)
|
||||
{
|
||||
if (!vm.argument_count()) {
|
||||
vm.throw_exception<TypeError>(global_object, ErrorType::ConvertUndefinedToObject);
|
||||
return {};
|
||||
}
|
||||
auto* obj_arg = vm.argument(0).to_object(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
|
|
@ -12,16 +12,6 @@ describe("correct behavior", () => {
|
|||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("requires two arguments", () => {
|
||||
expect(() => {
|
||||
Object.setPrototypeOf();
|
||||
}).toThrowWithMessage(TypeError, "Object.setPrototypeOf requires at least two arguments");
|
||||
|
||||
expect(() => {
|
||||
Object.setPrototypeOf({});
|
||||
}).toThrowWithMessage(TypeError, "Object.setPrototypeOf requires at least two arguments");
|
||||
});
|
||||
|
||||
test("prototype must be an object", () => {
|
||||
expect(() => {
|
||||
Object.setPrototypeOf({}, "foo");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue