diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 22a35e17d7..2bf1f05785 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -299,8 +299,6 @@ MarkedValueList Object::get_own_properties(PropertyKind kind, bool only_enumerab if (vm().exception()) return MarkedValueList { heap() }; } - - return properties; } if (return_type != GetOwnPropertyReturnType::SymbolOnly) { diff --git a/Userland/Libraries/LibJS/Tests/builtins/Object/Object.getOwnPropertyNames.js b/Userland/Libraries/LibJS/Tests/builtins/Object/Object.getOwnPropertyNames.js index da7bccbeba..45d537b47b 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Object/Object.getOwnPropertyNames.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Object/Object.getOwnPropertyNames.js @@ -12,3 +12,8 @@ test("use with object with symbol keys", () => { let names = Object.getOwnPropertyNames({ foo: 1, [Symbol("bar")]: 2, baz: 3 }); expect(names).toEqual(["foo", "baz"]); }); + +test("use with String object", () => { + let names = Object.getOwnPropertyNames(new String("foo")); + expect(names).toEqual(["0", "1", "2", "length"]); +});