1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

LibJS: Add ErrorTypes for Promise ownKeys trap invariant violations

This commit is contained in:
Linus Groh 2021-10-20 17:57:01 +01:00
parent ca09f20dcf
commit cf109533de
3 changed files with 65 additions and 3 deletions

View file

@ -728,7 +728,7 @@ ThrowCompletionOr<MarkedValueList> ProxyObject::internal_own_property_keys() con
for (auto& key : target_nonconfigurable_keys) {
// a. If key is not an element of uncheckedResultKeys, throw a TypeError exception.
if (!unchecked_result_keys.contains_slow(key))
return vm.throw_completion<TypeError>(global_object, ErrorType::FixmeAddAnErrorString);
return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyOwnPropertyKeysSkippedNonconfigurableProperty, key.to_string_without_side_effects());
// b. Remove key from uncheckedResultKeys.
unchecked_result_keys.remove_first_matching([&](auto& value) {
@ -744,7 +744,7 @@ ThrowCompletionOr<MarkedValueList> ProxyObject::internal_own_property_keys() con
for (auto& key : target_configurable_keys) {
// a. If key is not an element of uncheckedResultKeys, throw a TypeError exception.
if (!unchecked_result_keys.contains_slow(key))
return vm.throw_completion<TypeError>(global_object, ErrorType::FixmeAddAnErrorString);
return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyOwnPropertyKeysNonExtensibleSkippedProperty, key.to_string_without_side_effects());
// b. Remove key from uncheckedResultKeys.
unchecked_result_keys.remove_first_matching([&](auto& value) {
@ -754,7 +754,7 @@ ThrowCompletionOr<MarkedValueList> ProxyObject::internal_own_property_keys() con
// 22. If uncheckedResultKeys is not empty, throw a TypeError exception.
if (!unchecked_result_keys.is_empty())
return vm.throw_completion<TypeError>(global_object, ErrorType::FixmeAddAnErrorString);
return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyOwnPropertyKeysNonExtensibleNewProperty, unchecked_result_keys[0].to_string_without_side_effects());
// 23. Return trapResult.
return { move(trap_result) };