summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Libraries/LibJS/Runtime/ObjectPrototype.cpp2
-rw-r--r--Libraries/LibJS/Tests/Object.prototype.hasOwnProperty.js6
2 files changed, 6 insertions, 2 deletions
diff --git a/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Libraries/LibJS/Runtime/ObjectPrototype.cpp
index 53a3c4f518..f6d5aee272 100644
--- a/Libraries/LibJS/Runtime/ObjectPrototype.cpp
+++ b/Libraries/LibJS/Runtime/ObjectPrototype.cpp
@@ -57,8 +57,6 @@ Value ObjectPrototype::has_own_property(Interpreter& interpreter)
auto* this_object = interpreter.this_value().to_object(interpreter.heap());
if (!this_object)
return {};
- if (!interpreter.argument_count())
- return {};
return Value(this_object->has_own_property(interpreter.argument(0).to_string()));
}
diff --git a/Libraries/LibJS/Tests/Object.prototype.hasOwnProperty.js b/Libraries/LibJS/Tests/Object.prototype.hasOwnProperty.js
index 0a12f2ee52..16dec1062c 100644
--- a/Libraries/LibJS/Tests/Object.prototype.hasOwnProperty.js
+++ b/Libraries/LibJS/Tests/Object.prototype.hasOwnProperty.js
@@ -5,6 +5,12 @@ try {
o.foo = 1;
assert(o.hasOwnProperty("foo") === true);
assert(o.hasOwnProperty("bar") === false);
+ assert(o.hasOwnProperty() === false);
+ assert(o.hasOwnProperty(undefined) === false);
+ o.undefined = 2;
+ assert(o.hasOwnProperty() === true);
+ assert(o.hasOwnProperty(undefined) === true);
+
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);