diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp index 0c4a03a5884..921bcd378bd 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp @@ -1417,7 +1417,7 @@ public: generator.append(R"~~~( virtual JS::ThrowCompletionOr> internal_get_own_property(JS::PropertyName const&) const override; virtual bool internal_set(JS::PropertyName const&, JS::Value, JS::Value) override; - virtual bool internal_define_own_property(JS::PropertyName const&, JS::PropertyDescriptor const&) override; + virtual JS::ThrowCompletionOr internal_define_own_property(JS::PropertyName const&, JS::PropertyDescriptor const&) override; virtual bool internal_delete(JS::PropertyName const&) override; virtual JS::ThrowCompletionOr internal_prevent_extensions() override; virtual JS::MarkedValueList internal_own_property_keys() const override; @@ -2051,7 +2051,7 @@ bool @class_name@::internal_set(JS::PropertyName const& property_name, JS::Value // 3.9.3. [[DefineOwnProperty]], https://heycam.github.io/webidl/#legacy-platform-object-defineownproperty scoped_generator.append(R"~~~( -bool @class_name@::internal_define_own_property(JS::PropertyName const& property_name, JS::PropertyDescriptor const& property_descriptor) +JS::ThrowCompletionOr @class_name@::internal_define_own_property(JS::PropertyName const& property_name, JS::PropertyDescriptor const& property_descriptor) { [[maybe_unused]] auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -2076,8 +2076,8 @@ bool @class_name@::internal_define_own_property(JS::PropertyName const& property scoped_generator.append(R"~~~( // 3. Invoke the indexed property setter on O with P and Desc.[[Value]]. invoke_indexed_property_setter(global_object, impl(), property_name, *property_descriptor.value); - if (vm.exception()) - return {}; + if (auto* exception = vm.exception()) + return JS::throw_completion(exception->value()); // 4. Return true. return true; @@ -2110,7 +2110,7 @@ bool @class_name@::internal_define_own_property(JS::PropertyName const& property if (!interface.extended_attributes.contains("LegacyOverrideBuiltIns")) { scoped_generator.append(R"~~~( // NOTE: This has to be done manually instead of using Object::has_own_property, as that would use the overrided internal_get_own_property. - auto own_property_named_p = TRY_OR_DISCARD(Object::internal_get_own_property(property_name)); + auto own_property_named_p = TRY(Object::internal_get_own_property(property_name)); if (!own_property_named_p.has_value()))~~~"); } @@ -2135,8 +2135,8 @@ bool @class_name@::internal_define_own_property(JS::PropertyName const& property // 2. Invoke the named property setter on O with P and Desc.[[Value]]. invoke_named_property_setter(global_object, impl(), property_name_as_string, *property_descriptor.value); - if (vm.exception()) - return {}; + if (auto* exception = vm.exception()) + return JS::throw_completion(exception->value()); // 3. Return true. return true; diff --git a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp index 4fc89d52ae5..9edd408f31a 100644 --- a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp @@ -123,7 +123,7 @@ ThrowCompletionOr> ArgumentsObject::internal_get_ow } // 10.4.4.2 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-arguments-exotic-objects-defineownproperty-p-desc -bool ArgumentsObject::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& descriptor) +ThrowCompletionOr ArgumentsObject::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& descriptor) { // 1. Let map be args.[[ParameterMap]]. auto& map = parameter_map(); @@ -146,9 +146,7 @@ bool ArgumentsObject::internal_define_own_property(PropertyName const& property_ } // 5. Let allowed be ? OrdinaryDefineOwnProperty(args, P, newArgDesc). - bool allowed = Object::internal_define_own_property(property_name, new_arg_desc); - if (vm().exception()) - return false; + bool allowed = TRY(Object::internal_define_own_property(property_name, new_arg_desc)); // 6. If allowed is false, return false. if (!allowed) diff --git a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h index 11e85076a58..947b3740917 100644 --- a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h +++ b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h @@ -24,7 +24,7 @@ public: Environment& environment() { return m_environment; } virtual ThrowCompletionOr> internal_get_own_property(PropertyName const&) const override; - virtual bool internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override; + virtual ThrowCompletionOr internal_define_own_property(PropertyName const&, PropertyDescriptor 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/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp index af20cd0c4b6..5133d139477 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.cpp +++ b/Userland/Libraries/LibJS/Runtime/Array.cpp @@ -24,7 +24,7 @@ Array* Array::create(GlobalObject& global_object, size_t length, Object* prototy if (!prototype) prototype = global_object.array_prototype(); auto* array = global_object.heap().allocate(global_object, *prototype); - array->internal_define_own_property(vm.names.length, { .value = Value(length), .writable = true, .enumerable = false, .configurable = false }); + (void)array->internal_define_own_property(vm.names.length, { .value = Value(length), .writable = true, .enumerable = false, .configurable = false }); return array; } @@ -168,7 +168,7 @@ ThrowCompletionOr> Array::internal_get_own_property } // 10.4.2.1 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-array-exotic-objects-defineownproperty-p-desc -bool Array::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) +ThrowCompletionOr Array::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) { auto& vm = this->vm(); @@ -178,7 +178,10 @@ bool Array::internal_define_own_property(PropertyName const& property_name, Prop // 2. If P is "length", then if (property_name.is_string() && property_name.as_string() == vm.names.length.as_string()) { // a. Return ? ArraySetLength(A, Desc). - return set_length(property_descriptor); + auto success = set_length(property_descriptor); + if (auto* exception = vm.exception()) + return throw_completion(exception->value()); + return success; } // 3. Else if P is an array index, then @@ -195,7 +198,7 @@ bool Array::internal_define_own_property(PropertyName const& property_name, Prop return false; // h. Let succeeded be ! OrdinaryDefineOwnProperty(A, P, Desc). - auto succeeded = Object::internal_define_own_property(property_name, property_descriptor); + auto succeeded = Object::internal_define_own_property(property_name, property_descriptor).release_value(); // i. If succeeded is false, return false. if (!succeeded) return false; diff --git a/Userland/Libraries/LibJS/Runtime/Array.h b/Userland/Libraries/LibJS/Runtime/Array.h index d8c432705c9..a89b4ff5fc5 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.h +++ b/Userland/Libraries/LibJS/Runtime/Array.h @@ -39,7 +39,7 @@ public: virtual ~Array() override; virtual ThrowCompletionOr> internal_get_own_property(PropertyName const&) const override; - virtual bool internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override; + virtual ThrowCompletionOr internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override; virtual bool internal_delete(PropertyName const&) override; virtual MarkedValueList internal_own_property_keys() const override; diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 78da28bf899..bff0be6cd1e 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -137,7 +137,7 @@ bool Object::create_data_property(PropertyName const& property_name, Value value }; // 4. Return ? O.[[DefineOwnProperty]](P, newDesc). - return internal_define_own_property(property_name, new_descriptor); + return TRY_OR_DISCARD(internal_define_own_property(property_name, new_descriptor)); } // 7.3.6 CreateMethodProperty ( O, P, V ), https://tc39.es/ecma262/#sec-createmethodproperty @@ -159,7 +159,7 @@ bool Object::create_method_property(PropertyName const& property_name, Value val }; // 4. Return ? O.[[DefineOwnProperty]](P, newDesc). - return internal_define_own_property(property_name, new_descriptor); + return TRY_OR_DISCARD(internal_define_own_property(property_name, new_descriptor)); } // 7.3.7 CreateDataPropertyOrThrow ( O, P, V ), https://tc39.es/ecma262/#sec-createdatapropertyorthrow @@ -213,9 +213,7 @@ bool Object::define_property_or_throw(PropertyName const& property_name, Propert VERIFY(property_name.is_valid()); // 3. Let success be ? O.[[DefineOwnProperty]](P, desc). - auto success = internal_define_own_property(property_name, property_descriptor); - if (vm.exception()) - return {}; + auto success = TRY_OR_DISCARD(internal_define_own_property(property_name, property_descriptor)); // 4. If success is false, throw a TypeError exception. if (!success) { @@ -600,18 +598,18 @@ ThrowCompletionOr> Object::internal_get_own_propert } // 10.1.6 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc -bool Object::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) +ThrowCompletionOr Object::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) { VERIFY(property_name.is_valid()); auto& vm = this->vm(); // 1. Let current be ? O.[[GetOwnProperty]](P). - auto current = TRY_OR_DISCARD(internal_get_own_property(property_name)); + auto current = TRY(internal_get_own_property(property_name)); // 2. Let extensible be ? IsExtensible(O). auto extensible = is_extensible(); - if (vm.exception()) - return {}; + if (auto* exception = vm.exception()) + return throw_completion(exception->value()); // 3. Return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current). return validate_and_apply_property_descriptor(this, property_name, extensible, property_descriptor, current); @@ -759,7 +757,7 @@ bool Object::ordinary_set_with_own_descriptor(PropertyName const& property_name, auto value_descriptor = PropertyDescriptor { .value = value }; // iv. Return ? Receiver.[[DefineOwnProperty]](P, valueDesc). - return receiver.as_object().internal_define_own_property(property_name, value_descriptor); + return TRY_OR_DISCARD(receiver.as_object().internal_define_own_property(property_name, value_descriptor)); } // e. Else, else { @@ -783,6 +781,8 @@ bool Object::ordinary_set_with_own_descriptor(PropertyName const& property_name, // 7. Perform ? Call(setter, Receiver, « V »). (void)vm.call(*setter, receiver, value); + if (vm.exception()) + return {}; // 8. Return true. return true; diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index ef1daa4de04..a34cd26c234 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -96,7 +96,7 @@ public: virtual ThrowCompletionOr internal_is_extensible() const; virtual ThrowCompletionOr internal_prevent_extensions(); virtual ThrowCompletionOr> internal_get_own_property(PropertyName const&) const; - virtual bool internal_define_own_property(PropertyName const&, PropertyDescriptor const&); + virtual ThrowCompletionOr internal_define_own_property(PropertyName const&, PropertyDescriptor const&); virtual 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); diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index c345b3788f6..cb77da735c9 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -330,7 +330,7 @@ ThrowCompletionOr> ProxyObject::internal_get_own_pr } // 10.5.6 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc -bool ProxyObject::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) +ThrowCompletionOr ProxyObject::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) { auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -341,16 +341,14 @@ bool ProxyObject::internal_define_own_property(PropertyName const& property_name // 2. Let handler be O.[[ProxyHandler]]. // 3. If handler is null, throw a TypeError exception. - if (m_is_revoked) { - vm.throw_exception(global_object, ErrorType::ProxyRevoked); - return {}; - } + if (m_is_revoked) + return vm.throw_completion(global_object, ErrorType::ProxyRevoked); // 4. Assert: Type(handler) is Object. // 5. Let target be O.[[ProxyTarget]]. // 6. Let trap be ? GetMethod(handler, "defineProperty"). - auto trap = TRY_OR_DISCARD(Value(&m_handler).get_method(global_object, vm.names.defineProperty)); + auto trap = TRY(Value(&m_handler).get_method(global_object, vm.names.defineProperty)); // 7. If trap is undefined, then if (!trap) { @@ -362,19 +360,19 @@ bool ProxyObject::internal_define_own_property(PropertyName const& property_name auto descriptor_object = from_property_descriptor(global_object, property_descriptor); // 9. Let booleanTrapResult be ! ToBoolean(? Call(trap, handler, « target, P, descObj »)). - auto trap_result = TRY_OR_DISCARD(vm.call(*trap, &m_handler, &m_target, property_name_to_value(vm, property_name), descriptor_object)).to_boolean(); + auto trap_result = TRY(vm.call(*trap, &m_handler, &m_target, property_name_to_value(vm, property_name), descriptor_object)).to_boolean(); // 10. If booleanTrapResult is false, return false. if (!trap_result) return false; // 11. 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)); // 12. 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()); // 14. Else, let settingConfigFalse be false. bool setting_config_false = false; @@ -388,35 +386,28 @@ bool ProxyObject::internal_define_own_property(PropertyName const& property_name // 15. If targetDesc is undefined, then if (!target_descriptor.has_value()) { // a. If extensibleTarget is false, throw a TypeError exception. - if (!extensible_target) { - vm.throw_exception(global_object, ErrorType::ProxyDefinePropNonExtensible); - return {}; - } + if (!extensible_target) + return vm.throw_completion(global_object, ErrorType::ProxyDefinePropNonExtensible); + // b. If settingConfigFalse is true, throw a TypeError exception. - if (setting_config_false) { - vm.throw_exception(global_object, ErrorType::ProxyDefinePropNonConfigurableNonExisting); - return {}; - } + if (setting_config_false) + return vm.throw_completion(global_object, ErrorType::ProxyDefinePropNonConfigurableNonExisting); } // 16. Else, else { // a. If IsCompatiblePropertyDescriptor(extensibleTarget, Desc, targetDesc) is false, throw a TypeError exception. - if (!is_compatible_property_descriptor(extensible_target, property_descriptor, target_descriptor)) { - vm.throw_exception(global_object, ErrorType::ProxyDefinePropIncompatibleDescriptor); - return {}; - } + if (!is_compatible_property_descriptor(extensible_target, property_descriptor, target_descriptor)) + return vm.throw_completion(global_object, ErrorType::ProxyDefinePropIncompatibleDescriptor); + // b. If settingConfigFalse is true and targetDesc.[[Configurable]] is true, throw a TypeError exception. - if (setting_config_false && *target_descriptor->configurable) { - vm.throw_exception(global_object, ErrorType::ProxyDefinePropExistingConfigurable); - return {}; - } + if (setting_config_false && *target_descriptor->configurable) + return vm.throw_completion(global_object, ErrorType::ProxyDefinePropExistingConfigurable); + // c. If IsDataDescriptor(targetDesc) is true, targetDesc.[[Configurable]] is false, and targetDesc.[[Writable]] is true, then if (target_descriptor->is_data_descriptor() && !*target_descriptor->configurable && *target_descriptor->writable) { // i. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, throw a TypeError exception. - if (property_descriptor.writable.has_value() && !*property_descriptor.writable) { - vm.throw_exception(global_object, ErrorType::ProxyDefinePropNonWritable); - return {}; - } + if (property_descriptor.writable.has_value() && !*property_descriptor.writable) + return vm.throw_completion(global_object, ErrorType::ProxyDefinePropNonWritable); } } diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.h b/Userland/Libraries/LibJS/Runtime/ProxyObject.h index c410a15c399..e54025f47ef 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.h +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.h @@ -40,7 +40,7 @@ public: virtual ThrowCompletionOr internal_is_extensible() const override; virtual ThrowCompletionOr internal_prevent_extensions() override; virtual ThrowCompletionOr> internal_get_own_property(PropertyName const&) const override; - virtual bool internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override; + virtual ThrowCompletionOr internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override; virtual 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; diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp index bec3c3c7462..262d40f171f 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp @@ -122,7 +122,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::define_property) return {}; // 4. Return ? target.[[DefineOwnProperty]](key, desc). - return Value(target.as_object().internal_define_own_property(key, descriptor)); + return Value(TRY_OR_DISCARD(target.as_object().internal_define_own_property(key, descriptor))); } // 28.1.4 Reflect.deleteProperty ( target, propertyKey ), https://tc39.es/ecma262/#sec-reflect.deleteproperty diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.cpp b/Userland/Libraries/LibJS/Runtime/StringObject.cpp index 6002d27e7a8..f5f8cea400f 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringObject.cpp @@ -108,7 +108,7 @@ ThrowCompletionOr> StringObject::internal_get_own_p } // 10.4.3.2 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-string-exotic-objects-defineownproperty-p-desc -bool StringObject::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) +ThrowCompletionOr StringObject::internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) { // 1. Assert: IsPropertyKey(P) is true. VERIFY(property_name.is_valid()); diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.h b/Userland/Libraries/LibJS/Runtime/StringObject.h index b0ef348f2b7..a8b5d107981 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.h +++ b/Userland/Libraries/LibJS/Runtime/StringObject.h @@ -28,7 +28,7 @@ public: private: virtual ThrowCompletionOr> internal_get_own_property(PropertyName const&) const override; - virtual bool internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override; + virtual ThrowCompletionOr internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override; virtual MarkedValueList internal_own_property_keys() const override; virtual bool is_string_object() const final { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h index 721b340aeab..f9be919cd20 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h @@ -254,7 +254,7 @@ public: } // 10.4.5.3 [[DefineOwnProperty]] ( P, Desc ), https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects-defineownproperty-p-desc - virtual bool internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) override + virtual ThrowCompletionOr internal_define_own_property(PropertyName const& property_name, PropertyDescriptor const& property_descriptor) override { // 1. Assert: IsPropertyKey(P) is true. VERIFY(property_name.is_valid()); @@ -295,8 +295,8 @@ public: // vi. If Desc has a [[Value]] field, perform ? IntegerIndexedElementSet(O, numericIndex, Desc.[[Value]]). if (property_descriptor.value.has_value()) { integer_indexed_element_set(*this, numeric_index, *property_descriptor.value); - if (vm().exception()) - return {}; + if (auto* exception = vm().exception()) + return throw_completion(exception->value()); } // vii. Return true. diff --git a/Userland/Libraries/LibWeb/Bindings/Replaceable.h b/Userland/Libraries/LibWeb/Bindings/Replaceable.h index 6617922fe95..fce41f813ca 100644 --- a/Userland/Libraries/LibWeb/Bindings/Replaceable.h +++ b/Userland/Libraries/LibWeb/Bindings/Replaceable.h @@ -6,11 +6,12 @@ #pragma once -#define REPLACEABLE_PROPERTY_SETTER(ObjectType, property) \ - auto this_value = vm.this_value(global_object); \ - if (!this_value.is_object() || !is(this_value.as_object())) { \ - vm.throw_exception(global_object, JS::ErrorType::NotAnObjectOfType, #ObjectType); \ - return {}; \ - } \ - this_value.as_object().internal_define_own_property(#property, JS::PropertyDescriptor { .value = vm.argument(0), .writable = true }); \ +#define REPLACEABLE_PROPERTY_SETTER(ObjectType, property) \ + auto this_value = vm.this_value(global_object); \ + if (!this_value.is_object() || !is(this_value.as_object())) { \ + vm.throw_exception(global_object, JS::ErrorType::NotAnObjectOfType, #ObjectType); \ + return {}; \ + } \ + TRY_OR_DISCARD(this_value.as_object().internal_define_own_property( \ + #property, JS::PropertyDescriptor { .value = vm.argument(0), .writable = true })); \ return JS::js_undefined(); diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.cpp b/Userland/Services/WebContent/ConsoleGlobalObject.cpp index e835bc520d6..59427ecaf27 100644 --- a/Userland/Services/WebContent/ConsoleGlobalObject.cpp +++ b/Userland/Services/WebContent/ConsoleGlobalObject.cpp @@ -65,7 +65,7 @@ JS::ThrowCompletionOr> ConsoleGlobalObject::int return Base::internal_get_own_property(property_name); } -bool ConsoleGlobalObject::internal_define_own_property(JS::PropertyName const& property_name, JS::PropertyDescriptor const& descriptor) +JS::ThrowCompletionOr ConsoleGlobalObject::internal_define_own_property(JS::PropertyName const& property_name, JS::PropertyDescriptor const& descriptor) { return m_window_object->internal_define_own_property(property_name, descriptor); } diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.h b/Userland/Services/WebContent/ConsoleGlobalObject.h index e0a54e43fec..ab03375236d 100644 --- a/Userland/Services/WebContent/ConsoleGlobalObject.h +++ b/Userland/Services/WebContent/ConsoleGlobalObject.h @@ -28,7 +28,7 @@ public: virtual JS::ThrowCompletionOr internal_is_extensible() const override; virtual JS::ThrowCompletionOr internal_prevent_extensions() override; virtual JS::ThrowCompletionOr> 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; + virtual JS::ThrowCompletionOr 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::Value internal_get(JS::PropertyName const&, JS::Value) const override; virtual bool internal_set(JS::PropertyName const&, JS::Value value, JS::Value receiver) override;