summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Myhra <kennethmyhra@gmail.com>2023-02-15 19:27:35 +0100
committerLinus Groh <mail@linusgroh.de>2023-02-18 00:52:47 +0100
commit193de231e05cf4c6fb9f30637f364ec3b8cd4aad (patch)
tree089023f5a6c26baad1e3a7da193db04adef8e4b5
parent86b7f148b98937e13ac5a2b370128065e0fc33f3 (diff)
downloadserenity-193de231e05cf4c6fb9f30637f364ec3b8cd4aad.zip
LibWeb: Make factory method of HTML::WorkerNavigator fallible
-rw-r--r--Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp5
-rw-r--r--Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp4
-rw-r--r--Userland/Libraries/LibWeb/HTML/WorkerNavigator.h2
3 files changed, 7 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp
index 98194d8ea8..de252ae32c 100644
--- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp
+++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp
@@ -10,6 +10,7 @@
#include <AK/Vector.h>
#include <LibJS/Runtime/Completion.h>
#include <LibTextCodec/Decoder.h>
+#include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/WorkerGlobalScopePrototype.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/EventHandler.h>
@@ -33,7 +34,9 @@ WorkerGlobalScope::~WorkerGlobalScope() = default;
JS::ThrowCompletionOr<void> WorkerGlobalScope::initialize(JS::Realm& realm)
{
MUST_OR_THROW_OOM(Base::initialize(realm));
- m_navigator = WorkerNavigator::create(*this);
+ m_navigator = TRY(Bindings::throw_dom_exception_if_needed(realm.vm(), [&]() {
+ return WorkerNavigator::create(*this);
+ }));
return {};
}
diff --git a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp
index e43ef7b7b1..d868d46930 100644
--- a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp
+++ b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp
@@ -11,9 +11,9 @@
namespace Web::HTML {
-JS::NonnullGCPtr<WorkerNavigator> WorkerNavigator::create(WorkerGlobalScope& global_scope)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<WorkerNavigator>> WorkerNavigator::create(WorkerGlobalScope& global_scope)
{
- return global_scope.heap().allocate<WorkerNavigator>(global_scope.realm(), global_scope).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(global_scope.heap().allocate<WorkerNavigator>(global_scope.realm(), global_scope));
}
WorkerNavigator::WorkerNavigator(WorkerGlobalScope& global_scope)
diff --git a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h
index d111884375..323cd82523 100644
--- a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h
+++ b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h
@@ -22,7 +22,7 @@ class WorkerNavigator : public Bindings::PlatformObject
WEB_PLATFORM_OBJECT(WorkerNavigator, Bindings::PlatformObject);
public:
- static JS::NonnullGCPtr<WorkerNavigator> create(WorkerGlobalScope&);
+ static WebIDL::ExceptionOr<JS::NonnullGCPtr<WorkerNavigator>> create(WorkerGlobalScope&);
virtual ~WorkerNavigator() override;