mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 18:24:45 -05: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
Notes:
sideshowbarker
2024-07-19 07:13:12 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/0a0ba64383e Pull-request: https://github.com/SerenityOS/serenity/pull/2004
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
Reference in a new issue