diff options
9 files changed, 18 insertions, 22 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 7b860d1c32..61a2ee4bb7 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -72,7 +72,7 @@ Object::~Object() // 7.2.5 IsExtensible ( O ), https://tc39.es/ecma262/#sec-isextensible-o bool Object::is_extensible() const { - return internal_is_extensible(); + return TRY_OR_DISCARD(internal_is_extensible()); } // 7.3 Operations on Objects, https://tc39.es/ecma262/#sec-operations-on-objects @@ -547,7 +547,7 @@ ThrowCompletionOr<bool> Object::internal_set_prototype_of(Object* new_prototype) } // 10.1.3 [[IsExtensible]] ( ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-isextensible -bool Object::internal_is_extensible() const +ThrowCompletionOr<bool> Object::internal_is_extensible() const { // 1. Return O.[[Extensible]]. return m_is_extensible; diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index dfdb57db49..eb9a1f0c03 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -93,7 +93,7 @@ public: virtual ThrowCompletionOr<Object*> internal_get_prototype_of() const; virtual ThrowCompletionOr<bool> internal_set_prototype_of(Object* prototype); - virtual bool internal_is_extensible() const; + virtual ThrowCompletionOr<bool> internal_is_extensible() const; virtual bool internal_prevent_extensions(); virtual Optional<PropertyDescriptor> internal_get_own_property(PropertyName const&) const; virtual bool internal_define_own_property(PropertyName const&, PropertyDescriptor const&); diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index 92ea6aaca0..a3aa946465 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -148,7 +148,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_set_prototype_of(Object* prototype } // 10.5.3 [[IsExtensible]] ( ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-isextensible -bool ProxyObject::internal_is_extensible() const +ThrowCompletionOr<bool> ProxyObject::internal_is_extensible() const { auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -156,16 +156,14 @@ bool ProxyObject::internal_is_extensible() const // 1. Let handler be O.[[ProxyHandler]]. // 2. 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); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. // 5. Let trap be ? GetMethod(handler, "isExtensible"). - auto trap = TRY_OR_DISCARD(Value(&m_handler).get_method(global_object, vm.names.isExtensible)); + auto trap = TRY(Value(&m_handler).get_method(global_object, vm.names.isExtensible)); // 6. If trap is undefined, then if (!trap) { @@ -174,18 +172,16 @@ bool ProxyObject::internal_is_extensible() const } // 7. Let booleanTrapResult be ! ToBoolean(? Call(trap, handler, ยซ target ยป)). - auto trap_result = TRY_OR_DISCARD(vm.call(*trap, &m_handler, &m_target)).to_boolean(); + auto trap_result = TRY(vm.call(*trap, &m_handler, &m_target)).to_boolean(); // 8. Let targetResult be ? IsExtensible(target). auto target_result = m_target.is_extensible(); - if (vm.exception()) - return {}; + if (auto* exception = vm.exception()) + return throw_completion(exception->value()); // 9. If SameValue(booleanTrapResult, targetResult) is false, throw a TypeError exception. - if (trap_result != target_result) { - vm.throw_exception<TypeError>(global_object, ErrorType::ProxyIsExtensibleReturn); - return {}; - } + if (trap_result != target_result) + return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyIsExtensibleReturn); // 10. Return booleanTrapResult. return trap_result; diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.h b/Userland/Libraries/LibJS/Runtime/ProxyObject.h index d48954502d..faec553e70 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.h +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.h @@ -37,7 +37,7 @@ public: virtual ThrowCompletionOr<Object*> internal_get_prototype_of() const override; virtual ThrowCompletionOr<bool> internal_set_prototype_of(Object* prototype) override; - virtual bool internal_is_extensible() const override; + virtual ThrowCompletionOr<bool> internal_is_extensible() const override; virtual bool internal_prevent_extensions() override; virtual Optional<PropertyDescriptor> internal_get_own_property(PropertyName const&) const override; virtual bool internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override; diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp index bd9810e320..e4b32240a2 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp @@ -248,7 +248,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::is_extensible) } // 2. Return ? target.[[IsExtensible]](). - return Value(target.as_object().internal_is_extensible()); + return Value(TRY_OR_DISCARD(target.as_object().internal_is_extensible())); } // 28.1.10 Reflect.ownKeys ( target ), https://tc39.es/ecma262/#sec-reflect.ownkeys diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp index 86eeff93d9..df1b069154 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp @@ -133,7 +133,7 @@ JS::ThrowCompletionOr<bool> LocationObject::internal_set_prototype_of(Object* pr } // https://html.spec.whatwg.org/multipage/history.html#location-isextensible -bool LocationObject::internal_is_extensible() const +JS::ThrowCompletionOr<bool> LocationObject::internal_is_extensible() const { // 1. Return true. return true; diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.h b/Userland/Libraries/LibWeb/Bindings/LocationObject.h index 8f24d01a39..39af96818c 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationObject.h +++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.h @@ -22,7 +22,7 @@ public: virtual ~LocationObject() override; virtual JS::ThrowCompletionOr<bool> internal_set_prototype_of(Object* prototype) override; - virtual bool internal_is_extensible() const override; + virtual JS::ThrowCompletionOr<bool> internal_is_extensible() const override; virtual bool internal_prevent_extensions() override; // FIXME: There should also be a custom [[GetPrototypeOf]], [[GetOwnProperty]], [[DefineOwnProperty]], [[Get]], [[Set]], [[Delete]] and [[OwnPropertyKeys]], diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.cpp b/Userland/Services/WebContent/ConsoleGlobalObject.cpp index 2b5a61b6c5..9b9ae85335 100644 --- a/Userland/Services/WebContent/ConsoleGlobalObject.cpp +++ b/Userland/Services/WebContent/ConsoleGlobalObject.cpp @@ -47,7 +47,7 @@ JS::ThrowCompletionOr<bool> ConsoleGlobalObject::internal_set_prototype_of(JS::O return m_window_object->internal_set_prototype_of(prototype); } -bool ConsoleGlobalObject::internal_is_extensible() const +JS::ThrowCompletionOr<bool> ConsoleGlobalObject::internal_is_extensible() const { return m_window_object->internal_is_extensible(); } diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.h b/Userland/Services/WebContent/ConsoleGlobalObject.h index d92ec49cd8..c0ded11f0e 100644 --- a/Userland/Services/WebContent/ConsoleGlobalObject.h +++ b/Userland/Services/WebContent/ConsoleGlobalObject.h @@ -25,7 +25,7 @@ public: virtual JS::ThrowCompletionOr<Object*> internal_get_prototype_of() const override; virtual JS::ThrowCompletionOr<bool> internal_set_prototype_of(Object* prototype) override; - virtual bool internal_is_extensible() const override; + virtual JS::ThrowCompletionOr<bool> internal_is_extensible() const override; virtual bool internal_prevent_extensions() override; virtual Optional<JS::PropertyDescriptor> internal_get_own_property(JS::PropertyName const& name) const override; virtual bool internal_define_own_property(JS::PropertyName const& name, JS::PropertyDescriptor const& descriptor) override; |