From 9d1fb85f939d2553df18bfff161bb766cb1db0c5 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sun, 31 Oct 2021 17:05:46 +0200 Subject: [PATCH] WebContent: Convert ConsoleGlobalObject functions to ThrowCompletionOr --- Userland/Services/WebContent/ConsoleGlobalObject.cpp | 12 +++++------- Userland/Services/WebContent/ConsoleGlobalObject.h | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.cpp b/Userland/Services/WebContent/ConsoleGlobalObject.cpp index 82ad66fd56e..f424223b4c5 100644 --- a/Userland/Services/WebContent/ConsoleGlobalObject.cpp +++ b/Userland/Services/WebContent/ConsoleGlobalObject.cpp @@ -28,7 +28,7 @@ void ConsoleGlobalObject::initialize_global_object() Base::initialize_global_object(); // $0 magic variable - define_old_native_accessor("$0", inspected_node_getter, nullptr, 0); + define_native_accessor("$0", inspected_node_getter, nullptr, 0); } void ConsoleGlobalObject::visit_edges(Visitor& visitor) @@ -98,14 +98,12 @@ JS::ThrowCompletionOr ConsoleGlobalObject::internal_own_pro return m_window_object->internal_own_property_keys(); } -JS_DEFINE_OLD_NATIVE_FUNCTION(ConsoleGlobalObject::inspected_node_getter) +JS_DEFINE_NATIVE_FUNCTION(ConsoleGlobalObject::inspected_node_getter) { - auto* this_object = TRY_OR_DISCARD(vm.this_value(global_object).to_object(global_object)); + auto* this_object = TRY(vm.this_value(global_object).to_object(global_object)); - if (!is(this_object)) { - vm.throw_exception(global_object, JS::ErrorType::NotAnObjectOfType, "ConsoleGlobalObject"); - return {}; - } + if (!is(this_object)) + return vm.throw_completion(global_object, JS::ErrorType::NotAnObjectOfType, "ConsoleGlobalObject"); auto console_global_object = static_cast(this_object); auto& window = console_global_object->m_window_object->impl(); diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.h b/Userland/Services/WebContent/ConsoleGlobalObject.h index 055f8290ff3..32a19cdd4fa 100644 --- a/Userland/Services/WebContent/ConsoleGlobalObject.h +++ b/Userland/Services/WebContent/ConsoleGlobalObject.h @@ -41,7 +41,7 @@ private: virtual void visit_edges(Visitor&) override; // Because $0 is not a nice C++ function name - JS_DECLARE_OLD_NATIVE_FUNCTION(inspected_node_getter); + JS_DECLARE_NATIVE_FUNCTION(inspected_node_getter); Web::Bindings::WindowObject* m_window_object; };