Revert "LibJS+LibWeb: Return Vector<PropertyKey> from…
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

internal_own_property_keys"

This reverts commit 5ee810f772.
This commit is contained in:
Tim Ledbetter 2025-05-16 04:14:12 +01:00 committed by Tim Ledbetter
parent 8cd9275416
commit 2903defcfc
Notes: github-actions[bot] 2025-05-16 05:34:06 +00:00
24 changed files with 155 additions and 134 deletions

View file

@ -400,19 +400,21 @@ JS::ThrowCompletionOr<bool> PlatformObject::internal_prevent_extensions()
}
// https://webidl.spec.whatwg.org/#legacy-platform-object-ownpropertykeys
JS::ThrowCompletionOr<Vector<JS::PropertyKey>> PlatformObject::internal_own_property_keys() const
JS::ThrowCompletionOr<GC::RootVector<JS::Value>> PlatformObject::internal_own_property_keys() const
{
if (!m_legacy_platform_object_flags.has_value() || m_legacy_platform_object_flags->has_global_interface_extended_attribute)
return Base::internal_own_property_keys();
auto& vm = this->vm();
// 1. Let keys be a new empty list of ECMAScript String and Symbol values.
Vector<JS::PropertyKey> keys;
GC::RootVector<JS::Value> keys { heap() };
// 2. If O supports indexed properties, then for each index of Os supported property indices, in ascending numerical order, append ! ToString(index) to keys.
if (m_legacy_platform_object_flags->supports_indexed_properties) {
for (u64 index = 0; index <= NumericLimits<u32>::max(); ++index) {
if (is_supported_property_index(index))
keys.append(String::number(index));
keys.append(JS::PrimitiveString::create(vm, String::number(index)));
else
break;
}
@ -420,22 +422,22 @@ JS::ThrowCompletionOr<Vector<JS::PropertyKey>> PlatformObject::internal_own_prop
// 3. If O supports named properties, then for each P of Os supported property names that is visible according to the named property visibility algorithm, append P to keys.
if (m_legacy_platform_object_flags->supports_named_properties) {
for (auto const& named_property : supported_property_names()) {
for (auto& named_property : supported_property_names()) {
if (TRY(is_named_property_exposed_on_object(named_property)))
keys.append(named_property);
keys.append(JS::PrimitiveString::create(vm, named_property));
}
}
// 4. For each P of Os own property keys that is a String, in ascending chronological order of property creation, append P to keys.
for (auto const& it : shape().property_table()) {
for (auto& it : shape().property_table()) {
if (it.key.is_string())
keys.append(it.key);
keys.append(it.key.to_value(vm));
}
// 5. For each P of Os own property keys that is a Symbol, in ascending chronological order of property creation, append P to keys.
for (auto const& it : shape().property_table()) {
for (auto& it : shape().property_table()) {
if (it.key.is_symbol())
keys.append(it.key);
keys.append(it.key.to_value(vm));
}
// FIXME: 6. Assert: keys has no duplicate items.