summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.cpp15
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ProxyObject.cpp30
-rw-r--r--Userland/Libraries/LibJS/Runtime/ProxyObject.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ReflectObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArray.h2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp3
-rw-r--r--Userland/Services/WebContent/ConsoleGlobalObject.cpp4
-rw-r--r--Userland/Services/WebContent/ConsoleGlobalObject.h2
9 files changed, 31 insertions, 31 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp
index bff0be6cd1..cee28b6580 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Object.cpp
@@ -261,7 +261,7 @@ bool Object::has_property(PropertyName const& property_name) const
VERIFY(property_name.is_valid());
// 3. Return ? O.[[HasProperty]](P).
- return internal_has_property(property_name);
+ return TRY_OR_DISCARD(internal_has_property(property_name));
}
// 7.3.12 HasOwnProperty ( O, P ), https://tc39.es/ecma262/#sec-hasownproperty
@@ -616,25 +616,30 @@ ThrowCompletionOr<bool> Object::internal_define_own_property(PropertyName const&
}
// 10.1.7 [[HasProperty]] ( P ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-hasproperty-p
-bool Object::internal_has_property(PropertyName const& property_name) const
+ThrowCompletionOr<bool> Object::internal_has_property(PropertyName const& property_name) const
{
+ auto& vm = this->vm();
+
// 1. Assert: IsPropertyKey(P) is true.
VERIFY(property_name.is_valid());
// 2. Let hasOwn be ? O.[[GetOwnProperty]](P).
- auto has_own = TRY_OR_DISCARD(internal_get_own_property(property_name));
+ auto has_own = TRY(internal_get_own_property(property_name));
// 3. If hasOwn is not undefined, return true.
if (has_own.has_value())
return true;
// 4. Let parent be ? O.[[GetPrototypeOf]]().
- auto* parent = TRY_OR_DISCARD(internal_get_prototype_of());
+ auto* parent = TRY(internal_get_prototype_of());
// 5. If parent is not null, then
if (parent) {
// a. Return ? parent.[[HasProperty]](P).
- return parent->internal_has_property(property_name);
+ auto result = parent->internal_has_property(property_name);
+ if (auto* exception = vm.exception())
+ return throw_completion(exception->value());
+ return result;
}
// 6. Return false.
diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h
index a34cd26c23..a02b7395ef 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.h
+++ b/Userland/Libraries/LibJS/Runtime/Object.h
@@ -97,7 +97,7 @@ public:
virtual ThrowCompletionOr<bool> internal_prevent_extensions();
virtual ThrowCompletionOr<Optional<PropertyDescriptor>> internal_get_own_property(PropertyName const&) const;
virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyName const&, PropertyDescriptor const&);
- virtual bool internal_has_property(PropertyName const&) const;
+ virtual ThrowCompletionOr<bool> internal_has_property(PropertyName const&) const;
virtual Value internal_get(PropertyName const&, Value receiver) const;
virtual bool internal_set(PropertyName const&, Value value, Value receiver);
virtual bool internal_delete(PropertyName const&);
diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
index cb77da735c..398e3d46c4 100644
--- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
@@ -416,7 +416,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_define_own_property(PropertyName c
}
// 10.5.7 [[HasProperty]] ( P ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p
-bool ProxyObject::internal_has_property(PropertyName const& property_name) const
+ThrowCompletionOr<bool> ProxyObject::internal_has_property(PropertyName const& property_name) const
{
auto& vm = this->vm();
auto& global_object = this->global_object();
@@ -427,16 +427,14 @@ bool ProxyObject::internal_has_property(PropertyName const& property_name) const
// 2. Let handler be O.[[ProxyHandler]].
// 3. If handler is null, throw a TypeError exception.
- if (m_is_revoked) {
- vm.throw_exception<TypeError>(global_object, ErrorType::ProxyRevoked);
- return {};
- }
+ if (m_is_revoked)
+ return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked);
// 4. Assert: Type(handler) is Object.
// 5. Let target be O.[[ProxyTarget]].
// 6. Let trap be ? GetMethod(handler, "has").
- auto trap = TRY_OR_DISCARD(Value(&m_handler).get_method(global_object, vm.names.has));
+ auto trap = TRY(Value(&m_handler).get_method(global_object, vm.names.has));
// 7. If trap is undefined, then
if (!trap) {
@@ -445,31 +443,27 @@ bool ProxyObject::internal_has_property(PropertyName const& property_name) const
}
// 8. Let booleanTrapResult be ! ToBoolean(? Call(trap, handler, ยซ target, P ยป)).
- auto trap_result = TRY_OR_DISCARD(vm.call(*trap, &m_handler, &m_target, property_name_to_value(vm, property_name))).to_boolean();
+ auto trap_result = TRY(vm.call(*trap, &m_handler, &m_target, property_name_to_value(vm, property_name))).to_boolean();
// 9. If booleanTrapResult is false, then
if (!trap_result) {
// a. Let targetDesc be ? target.[[GetOwnProperty]](P).
- auto target_descriptor = TRY_OR_DISCARD(m_target.internal_get_own_property(property_name));
+ auto target_descriptor = TRY(m_target.internal_get_own_property(property_name));
// b. If targetDesc is not undefined, then
if (target_descriptor.has_value()) {
// i. If targetDesc.[[Configurable]] is false, throw a TypeError exception.
- if (!*target_descriptor->configurable) {
- vm.throw_exception<TypeError>(global_object, ErrorType::ProxyHasExistingNonConfigurable);
- return {};
- }
+ if (!*target_descriptor->configurable)
+ return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyHasExistingNonConfigurable);
// ii. Let extensibleTarget be ? IsExtensible(target).
auto extensible_target = m_target.is_extensible();
- if (vm.exception())
- return {};
+ if (auto* exception = vm.exception())
+ return throw_completion(exception->value());
// iii. If extensibleTarget is false, throw a TypeError exception.
- if (!extensible_target) {
- vm.throw_exception<TypeError>(global_object, ErrorType::ProxyHasExistingNonExtensible);
- return false;
- }
+ if (!extensible_target)
+ return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyHasExistingNonExtensible);
}
}
diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.h b/Userland/Libraries/LibJS/Runtime/ProxyObject.h
index e54025f47e..1b9bfec70e 100644
--- a/Userland/Libraries/LibJS/Runtime/ProxyObject.h
+++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.h
@@ -41,7 +41,7 @@ public:
virtual ThrowCompletionOr<bool> internal_prevent_extensions() override;
virtual ThrowCompletionOr<Optional<PropertyDescriptor>> internal_get_own_property(PropertyName const&) const override;
virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override;
- virtual bool internal_has_property(PropertyName const&) const override;
+ virtual ThrowCompletionOr<bool> internal_has_property(PropertyName const&) const override;
virtual Value internal_get(PropertyName const&, Value receiver) const override;
virtual bool internal_set(PropertyName const&, Value value, Value receiver) override;
virtual bool internal_delete(PropertyName const&) override;
diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp
index 262d40f171..3ac12b4236 100644
--- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp
@@ -231,7 +231,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::has)
return {};
// 3. Return ? target.[[HasProperty]](key).
- return Value(target.as_object().internal_has_property(key));
+ return Value(TRY_OR_DISCARD(target.as_object().internal_has_property(key)));
}
// 28.1.9 Reflect.isExtensible ( target ), https://tc39.es/ecma262/#sec-reflect.isextensible
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h
index f9be919cd2..e86b59048b 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArray.h
+++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h
@@ -228,7 +228,7 @@ public:
}
// 10.4.5.2 [[HasProperty]] ( P ), https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects-hasproperty-p
- virtual bool internal_has_property(PropertyName const& property_name) const override
+ virtual ThrowCompletionOr<bool> internal_has_property(PropertyName const& property_name) const override
{
// 1. Assert: IsPropertyKey(P) is true.
VERIFY(property_name.is_valid());
diff --git a/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp b/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp
index d00c808204..9707b93587 100644
--- a/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp
@@ -4,12 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibJS/Runtime/Completion.h>
#include <LibWeb/Bindings/CSSStyleDeclarationWrapper.h>
#include <LibWeb/DOM/Element.h>
namespace Web::Bindings {
-bool CSSStyleDeclarationWrapper::internal_has_property(JS::PropertyName const& name) const
+JS::ThrowCompletionOr<bool> CSSStyleDeclarationWrapper::internal_has_property(JS::PropertyName const& name) const
{
if (!name.is_string())
return Base::internal_has_property(name);
diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.cpp b/Userland/Services/WebContent/ConsoleGlobalObject.cpp
index 59427ecaf2..66f26b921d 100644
--- a/Userland/Services/WebContent/ConsoleGlobalObject.cpp
+++ b/Userland/Services/WebContent/ConsoleGlobalObject.cpp
@@ -70,9 +70,9 @@ JS::ThrowCompletionOr<bool> ConsoleGlobalObject::internal_define_own_property(JS
return m_window_object->internal_define_own_property(property_name, descriptor);
}
-bool ConsoleGlobalObject::internal_has_property(JS::PropertyName const& property_name) const
+JS::ThrowCompletionOr<bool> ConsoleGlobalObject::internal_has_property(JS::PropertyName const& property_name) const
{
- return Object::internal_has_property(property_name) || m_window_object->internal_has_property(property_name);
+ return TRY(Object::internal_has_property(property_name)) || TRY(m_window_object->internal_has_property(property_name));
}
JS::Value ConsoleGlobalObject::internal_get(JS::PropertyName const& property_name, JS::Value receiver) const
diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.h b/Userland/Services/WebContent/ConsoleGlobalObject.h
index ab03375236..1ff4832ff8 100644
--- a/Userland/Services/WebContent/ConsoleGlobalObject.h
+++ b/Userland/Services/WebContent/ConsoleGlobalObject.h
@@ -29,7 +29,7 @@ public:
virtual JS::ThrowCompletionOr<bool> internal_prevent_extensions() override;
virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyName const& name) const override;
virtual JS::ThrowCompletionOr<bool> internal_define_own_property(JS::PropertyName const& name, JS::PropertyDescriptor const& descriptor) override;
- virtual bool internal_has_property(JS::PropertyName const& name) const override;
+ virtual JS::ThrowCompletionOr<bool> internal_has_property(JS::PropertyName const& name) const override;
virtual JS::Value internal_get(JS::PropertyName const&, JS::Value) const override;
virtual bool internal_set(JS::PropertyName const&, JS::Value value, JS::Value receiver) override;
virtual bool internal_delete(JS::PropertyName const& name) override;