Skip to content

Commit 0a0ba64

Browse files
linusgawesomekling
authored andcommitted
LibJS: Handle Object.prototype.hasOwnProperty() with no arg correctly
I.e. the same as hasOwnProperty(undefined) or hasOwnProperty("undefined") :^)
1 parent 4419685 commit 0a0ba64

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Libraries/LibJS/Runtime/ObjectPrototype.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ Value ObjectPrototype::has_own_property(Interpreter& interpreter)
5757
auto* this_object = interpreter.this_value().to_object(interpreter.heap());
5858
if (!this_object)
5959
return {};
60-
if (!interpreter.argument_count())
61-
return {};
6260
return Value(this_object->has_own_property(interpreter.argument(0).to_string()));
6361
}
6462

Libraries/LibJS/Tests/Object.prototype.hasOwnProperty.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ try {
55
o.foo = 1;
66
assert(o.hasOwnProperty("foo") === true);
77
assert(o.hasOwnProperty("bar") === false);
8+
assert(o.hasOwnProperty() === false);
9+
assert(o.hasOwnProperty(undefined) === false);
10+
o.undefined = 2;
11+
assert(o.hasOwnProperty() === true);
12+
assert(o.hasOwnProperty(undefined) === true);
13+
814
console.log("PASS");
915
} catch (e) {
1016
console.log("FAIL: " + e);

0 commit comments

Comments
 (0)