LibJS: Object.getOwnPropertyNames() should enumerate String's .length

We were incorrectly aborting property name enumeration after generating
names for all the indexable properties in the underlying string.
This commit is contained in:
Andreas Kling 2021-06-19 11:46:08 +02:00
commit f86e241699
Notes: sideshowbarker 2024-07-18 12:02:11 +09:00
2 changed files with 5 additions and 2 deletions

View file

@ -299,8 +299,6 @@ MarkedValueList Object::get_own_properties(PropertyKind kind, bool only_enumerab
if (vm().exception()) if (vm().exception())
return MarkedValueList { heap() }; return MarkedValueList { heap() };
} }
return properties;
} }
if (return_type != GetOwnPropertyReturnType::SymbolOnly) { if (return_type != GetOwnPropertyReturnType::SymbolOnly) {

View file

@ -12,3 +12,8 @@ test("use with object with symbol keys", () => {
let names = Object.getOwnPropertyNames({ foo: 1, [Symbol("bar")]: 2, baz: 3 }); let names = Object.getOwnPropertyNames({ foo: 1, [Symbol("bar")]: 2, baz: 3 });
expect(names).toEqual(["foo", "baz"]); expect(names).toEqual(["foo", "baz"]);
}); });
test("use with String object", () => {
let names = Object.getOwnPropertyNames(new String("foo"));
expect(names).toEqual(["0", "1", "2", "length"]);
});