summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Contrib/Test262
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-01-28 12:33:35 -0500
committerLinus Groh <mail@linusgroh.de>2023-01-29 00:02:45 +0000
commit2692db869963ed10947b05f13eade5fcbd5951dc (patch)
treeef12b9e76ff4edb64571819643a92d8e6c33a2fe /Userland/Libraries/LibJS/Contrib/Test262
parent1c1b902a6a0c1c7017fdc6d9748018317a554c9b (diff)
downloadserenity-2692db869963ed10947b05f13eade5fcbd5951dc.zip
LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors
Note that as of this commit, there aren't any such throwers, and the call site in Heap::allocate will drop exceptions on the floor. This commit only serves to change the declaration of the overrides, make sure they return an empty value, and to propagate OOM errors frm their base initialize invocations.
Diffstat (limited to 'Userland/Libraries/LibJS/Contrib/Test262')
-rw-r--r--Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp6
-rw-r--r--Userland/Libraries/LibJS/Contrib/Test262/$262Object.h2
-rw-r--r--Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp6
-rw-r--r--Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h2
-rw-r--r--Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp6
-rw-r--r--Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h2
6 files changed, 15 insertions, 9 deletions
diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp
index 9fff14e5ad..e655200342 100644
--- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp
+++ b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp
@@ -24,9 +24,9 @@ $262Object::$262Object(Realm& realm)
{
}
-void $262Object::initialize(Realm& realm)
+ThrowCompletionOr<void> $262Object::initialize(Realm& realm)
{
- Base::initialize(realm);
+ MUST_OR_THROW_OOM(Base::initialize(realm));
m_agent = vm().heap().allocate<AgentObject>(realm, realm);
m_is_htmldda = vm().heap().allocate<IsHTMLDDA>(realm, realm);
@@ -41,6 +41,8 @@ void $262Object::initialize(Realm& realm)
define_direct_property("gc", realm.global_object().get_without_side_effects("gc"), attr);
define_direct_property("global", &realm.global_object(), attr);
define_direct_property("IsHTMLDDA", m_is_htmldda, attr);
+
+ return {};
}
void $262Object::visit_edges(Cell::Visitor& visitor)
diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h
index ac4a21d947..831d761090 100644
--- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h
+++ b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h
@@ -17,7 +17,7 @@ class $262Object final : public Object {
JS_OBJECT($262Object, Object);
public:
- virtual void initialize(JS::Realm&) override;
+ virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~$262Object() override = default;
private:
diff --git a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp
index f38b229cb9..0408867e07 100644
--- a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp
+++ b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp
@@ -17,9 +17,9 @@ AgentObject::AgentObject(Realm& realm)
{
}
-void AgentObject::initialize(JS::Realm& realm)
+JS::ThrowCompletionOr<void> AgentObject::initialize(JS::Realm& realm)
{
- Base::initialize(realm);
+ MUST_OR_THROW_OOM(Base::initialize(realm));
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, "monotonicNow", monotonic_now, 0, attr);
@@ -27,6 +27,8 @@ void AgentObject::initialize(JS::Realm& realm)
// TODO: broadcast
// TODO: getReport
// TODO: start
+
+ return {};
}
JS_DEFINE_NATIVE_FUNCTION(AgentObject::monotonic_now)
diff --git a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h
index 3daf6e166d..fe84604096 100644
--- a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h
+++ b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h
@@ -15,7 +15,7 @@ class AgentObject final : public Object {
JS_OBJECT(AgentObject, Object);
public:
- virtual void initialize(JS::Realm&) override;
+ virtual JS::ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~AgentObject() override = default;
private:
diff --git a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp
index 8dd7dca8d7..2175b0c6dd 100644
--- a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp
+++ b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp
@@ -14,9 +14,9 @@
namespace JS::Test262 {
-void GlobalObject::initialize(Realm& realm)
+ThrowCompletionOr<void> GlobalObject::initialize(Realm& realm)
{
- Base::initialize(realm);
+ MUST_OR_THROW_OOM(Base::initialize(realm));
m_$262 = vm().heap().allocate<$262Object>(realm, realm);
@@ -24,6 +24,8 @@ void GlobalObject::initialize(Realm& realm)
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, "print", print, 1, attr);
define_direct_property("$262", m_$262, attr);
+
+ return {};
}
void GlobalObject::visit_edges(Cell::Visitor& visitor)
diff --git a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h
index 84cbdb5889..618fea6a5a 100644
--- a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h
+++ b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h
@@ -15,7 +15,7 @@ class GlobalObject final : public JS::GlobalObject {
JS_OBJECT(GlobalObject, JS::GlobalObject);
public:
- virtual void initialize(Realm&) override;
+ virtual ThrowCompletionOr<void> initialize(Realm&) override;
virtual ~GlobalObject() override = default;
$262Object* $262() const { return m_$262; }