summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-10-03 19:52:13 +0100
committerLinus Groh <mail@linusgroh.de>2021-10-04 09:52:15 +0100
commit0a49a2db60212df1a92ad96170ef9497632ab6da (patch)
treee8a22146341f5177617d269811fd3966b60ead92
parenta7b1c7eb16ea531bd845905df0f3c841f3e6dd87 (diff)
downloadserenity-0a49a2db60212df1a92ad96170ef9497632ab6da.zip
LibJS: Convert set_immutable_prototype() to ThrowCompletionOr
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp1
-rw-r--r--Userland/Libraries/LibWeb/Bindings/LocationObject.cpp2
4 files changed, 5 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp
index 50c751ed37..4e93771321 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Object.cpp
@@ -841,12 +841,12 @@ ThrowCompletionOr<MarkedValueList> Object::internal_own_property_keys() const
}
// 10.4.7.2 SetImmutablePrototype ( O, V ), https://tc39.es/ecma262/#sec-set-immutable-prototype
-bool Object::set_immutable_prototype(Object* prototype)
+ThrowCompletionOr<bool> Object::set_immutable_prototype(Object* prototype)
{
// 1. Assert: Either Type(V) is Object or Type(V) is Null.
// 2. Let current be ? O.[[GetPrototypeOf]]().
- auto* current = TRY_OR_DISCARD(internal_get_prototype_of());
+ auto* current = TRY(internal_get_prototype_of());
// 3. If SameValue(V, current) is true, return true.
if (prototype == current)
diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h
index ad1b142174..1fb370c8ae 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.h
+++ b/Userland/Libraries/LibJS/Runtime/Object.h
@@ -108,7 +108,7 @@ public:
// 10.4.7 Immutable Prototype Exotic Objects, https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects
- bool set_immutable_prototype(Object* prototype);
+ ThrowCompletionOr<bool> set_immutable_prototype(Object* prototype);
// 20.1 Object Objects, https://tc39.es/ecma262/#sec-object-objects
diff --git a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp
index 9e9b578bf7..76f4f43316 100644
--- a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp
@@ -55,6 +55,7 @@ ObjectPrototype::~ObjectPrototype()
// 10.4.7.1 [[SetPrototypeOf]] ( V ), https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects-setprototypeof-v
ThrowCompletionOr<bool> ObjectPrototype::internal_set_prototype_of(Object* prototype)
{
+ // 1. Return ? SetImmutablePrototype(O, V).
return set_immutable_prototype(prototype);
}
diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp
index e9160e2296..6573383e93 100644
--- a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp
@@ -141,7 +141,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::replace)
JS::ThrowCompletionOr<bool> LocationObject::internal_set_prototype_of(Object* prototype)
{
// 1. Return ! SetImmutablePrototype(this, V).
- return set_immutable_prototype(prototype);
+ return MUST(set_immutable_prototype(prototype));
}
// https://html.spec.whatwg.org/multipage/history.html#location-isextensible