summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-06-12 20:03:10 +0300
committerLinus Groh <mail@linusgroh.de>2021-06-12 18:39:23 +0100
commita2da3f97eff59dd6778de085b7d4d7d7ea0f250a (patch)
treeb829f06de85fcd7aa2436b1404888065bb6dfd7d /Userland
parentb9d4dd685022d11d1567f82e0b69333b0e2b3576 (diff)
downloadserenity-a2da3f97eff59dd6778de085b7d4d7d7ea0f250a.zip
LibJS: Remove argument count checks in Object.* methods
These are inconsistent with the specification.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorTypes.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp21
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/Object/Object.setPrototypeOf.js10
3 files changed, 0 insertions, 33 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h
index e73b7d5b3b..a1fe56b288 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h
+++ b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h
@@ -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") \
diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
index 72a4e19836..b2d1c81435 100644
--- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
@@ -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 {};
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Object/Object.setPrototypeOf.js b/Userland/Libraries/LibJS/Tests/builtins/Object/Object.setPrototypeOf.js
index 1b0b2888e7..612c5929e6 100644
--- a/Userland/Libraries/LibJS/Tests/builtins/Object/Object.setPrototypeOf.js
+++ b/Userland/Libraries/LibJS/Tests/builtins/Object/Object.setPrototypeOf.js
@@ -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");