From 2692db869963ed10947b05f13eade5fcbd5951dc Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sat, 28 Jan 2023 12:33:35 -0500 Subject: 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. --- Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.cpp | 6 ++++-- Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'Userland/Services') diff --git a/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.cpp b/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.cpp index e9c1e63a8f..33a82dbc8c 100644 --- a/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.cpp +++ b/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.cpp @@ -21,14 +21,16 @@ ConsoleGlobalEnvironmentExtensions::ConsoleGlobalEnvironmentExtensions(JS::Realm { } -void ConsoleGlobalEnvironmentExtensions::initialize(JS::Realm& realm) +JS::ThrowCompletionOr ConsoleGlobalEnvironmentExtensions::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_native_accessor(realm, "$0", $0_getter, nullptr, 0); define_native_accessor(realm, "$_", $__getter, nullptr, 0); define_native_function(realm, "$", $_function, 2, JS::default_attributes); define_native_function(realm, "$$", $$_function, 2, JS::default_attributes); + + return {}; } void ConsoleGlobalEnvironmentExtensions::visit_edges(Visitor& visitor) diff --git a/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.h b/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.h index 476000ad85..fc9d5e74b9 100644 --- a/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.h +++ b/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.h @@ -18,7 +18,7 @@ class ConsoleGlobalEnvironmentExtensions final : public JS::Object { public: ConsoleGlobalEnvironmentExtensions(JS::Realm&, Web::HTML::Window&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; virtual ~ConsoleGlobalEnvironmentExtensions() override = default; void set_most_recent_result(JS::Value result) { m_most_recent_result = move(result); } -- cgit v1.2.3