mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
LibJS: Handle Object.prototype.hasOwnProperty() with no arg correctly
I.e. the same as hasOwnProperty(undefined) or hasOwnProperty("undefined") :^)
This commit is contained in:
parent
4419685b7e
commit
0a0ba64383
2 changed files with 6 additions and 2 deletions
|
@ -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()));
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue