diff options
4 files changed, 10 insertions, 14 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index e0e6c4dc29..2bc19b33a1 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -273,7 +273,7 @@ ThrowCompletionOr<bool> Object::has_own_property(PropertyName const& property_na } // 7.3.15 SetIntegrityLevel ( O, level ), https://tc39.es/ecma262/#sec-setintegritylevel -bool Object::set_integrity_level(IntegrityLevel level) +ThrowCompletionOr<bool> Object::set_integrity_level(IntegrityLevel level) { auto& global_object = this->global_object(); @@ -283,14 +283,14 @@ bool Object::set_integrity_level(IntegrityLevel level) VERIFY(level == IntegrityLevel::Sealed || level == IntegrityLevel::Frozen); // 3. Let status be ? O.[[PreventExtensions]](). - auto status = TRY_OR_DISCARD(internal_prevent_extensions()); + auto status = TRY(internal_prevent_extensions()); // 4. If status is false, return false. if (!status) return false; // 5. Let keys be ? O.[[OwnPropertyKeys]](). - auto keys = TRY_OR_DISCARD(internal_own_property_keys()); + auto keys = TRY(internal_own_property_keys()); // 6. If level is sealed, then if (level == IntegrityLevel::Sealed) { @@ -299,7 +299,7 @@ bool Object::set_integrity_level(IntegrityLevel level) auto property_name = PropertyName::from_value(global_object, key); // i. Perform ? DefinePropertyOrThrow(O, k, PropertyDescriptor { [[Configurable]]: false }). - TRY_OR_DISCARD(define_property_or_throw(property_name, { .configurable = false })); + TRY(define_property_or_throw(property_name, { .configurable = false })); } } // 7. Else, @@ -311,7 +311,7 @@ bool Object::set_integrity_level(IntegrityLevel level) auto property_name = PropertyName::from_value(global_object, key); // i. Let currentDesc be ? O.[[GetOwnProperty]](k). - auto current_descriptor = TRY_OR_DISCARD(internal_get_own_property(property_name)); + auto current_descriptor = TRY(internal_get_own_property(property_name)); // ii. If currentDesc is not undefined, then if (!current_descriptor.has_value()) @@ -331,7 +331,7 @@ bool Object::set_integrity_level(IntegrityLevel level) } // 3. Perform ? DefinePropertyOrThrow(O, k, desc). - TRY_OR_DISCARD(define_property_or_throw(property_name, descriptor)); + TRY(define_property_or_throw(property_name, descriptor)); } } diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index 95b33c34fb..d6b13ba82c 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -85,7 +85,7 @@ public: ThrowCompletionOr<bool> delete_property_or_throw(PropertyName const&); ThrowCompletionOr<bool> has_property(PropertyName const&) const; ThrowCompletionOr<bool> has_own_property(PropertyName const&) const; - bool set_integrity_level(IntegrityLevel); + ThrowCompletionOr<bool> set_integrity_level(IntegrityLevel); bool test_integrity_level(IntegrityLevel) const; MarkedValueList enumerable_own_property_names(PropertyKind kind) const; ThrowCompletionOr<Object*> copy_data_properties(Value source, HashTable<PropertyName, PropertyNameTraits> const& seen_names, GlobalObject& global_object); diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp index 5890d49697..efd4cafbe2 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -221,9 +221,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::freeze) auto argument = vm.argument(0); if (!argument.is_object()) return argument; - auto status = argument.as_object().set_integrity_level(Object::IntegrityLevel::Frozen); - if (vm.exception()) - return {}; + auto status = TRY_OR_DISCARD(argument.as_object().set_integrity_level(Object::IntegrityLevel::Frozen)); if (!status) { vm.throw_exception<TypeError>(global_object, ErrorType::ObjectFreezeFailed); return {}; @@ -272,9 +270,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::seal) auto argument = vm.argument(0); if (!argument.is_object()) return argument; - auto status = argument.as_object().set_integrity_level(Object::IntegrityLevel::Sealed); - if (vm.exception()) - return {}; + auto status = TRY_OR_DISCARD(argument.as_object().set_integrity_level(Object::IntegrityLevel::Sealed)); if (!status) { vm.throw_exception<TypeError>(global_object, ErrorType::ObjectSealFailed); return {}; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp index c916c47299..48b79c3532 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp @@ -54,7 +54,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object) }); } - m_exports_object->set_integrity_level(IntegrityLevel::Frozen); + MUST(m_exports_object->set_integrity_level(IntegrityLevel::Frozen)); } void WebAssemblyInstanceObject::visit_edges(Visitor& visitor) |