diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2023-02-12 22:05:32 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-02-18 00:52:47 +0100 |
commit | 7ec444047ccc9a9c4c1d80f3e48f6fd52408c600 (patch) | |
tree | 602a7e63156303614c5c38879be9a3e26e3554df | |
parent | 3d79cdf09599f0a5f85fe73656ad79b8814d528b (diff) | |
download | serenity-7ec444047ccc9a9c4c1d80f3e48f6fd52408c600.zip |
LibWeb: Make factory methods of HTML::MessageEvent fallible
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Document.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/MessageEvent.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/MessageEvent.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/MessagePort.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Window.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Worker.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp | 4 |
7 files changed, 11 insertions, 11 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index e2730c4d47..2484426c2a 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1294,7 +1294,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Document::create_event(DeprecatedSt } else if (interface_lowercase == "keyboardevent") { event = UIEvents::KeyboardEvent::create(realm, ""); } else if (interface_lowercase == "messageevent") { - event = HTML::MessageEvent::create(realm, ""); + event = TRY(HTML::MessageEvent::create(realm, "")); } else if (interface_lowercase.is_one_of("mouseevent", "mouseevents")) { event = UIEvents::MouseEvent::create(realm, ""); } else if (interface_lowercase == "storageevent") { diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp index 4aaba0bc05..639cad228a 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp @@ -9,12 +9,12 @@ namespace Web::HTML { -MessageEvent* MessageEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, MessageEventInit const& event_init) +WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> MessageEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, MessageEventInit const& event_init) { - return realm.heap().allocate<MessageEvent>(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors(); + return MUST_OR_THROW_OOM(realm.heap().allocate<MessageEvent>(realm, realm, event_name, event_init)); } -MessageEvent* MessageEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, MessageEventInit const& event_init) +WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> MessageEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, MessageEventInit const& event_init) { return create(realm, event_name, event_init); } diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.h b/Userland/Libraries/LibWeb/HTML/MessageEvent.h index 3a62c071aa..838f25bbb6 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageEvent.h +++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.h @@ -21,8 +21,8 @@ class MessageEvent : public DOM::Event { WEB_PLATFORM_OBJECT(MessageEvent, DOM::Event); public: - static MessageEvent* create(JS::Realm&, DeprecatedFlyString const& event_name, MessageEventInit const& event_init = {}); - static MessageEvent* construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, MessageEventInit const& event_init); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> create(JS::Realm&, DeprecatedFlyString const& event_name, MessageEventInit const& event_init = {}); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, MessageEventInit const& event_init); MessageEvent(JS::Realm&, DeprecatedFlyString const& event_name, MessageEventInit const& event_init); virtual ~MessageEvent() override; diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp index 48d83203fc..25040cfb29 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp @@ -99,7 +99,7 @@ void MessagePort::post_message(JS::Value message) MessageEventInit event_init {}; event_init.data = message; event_init.origin = "<origin>"; - target_port->dispatch_event(*MessageEvent::create(target_port->realm(), HTML::EventNames::message, event_init)); + target_port->dispatch_event(MessageEvent::create(target_port->realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); })); } diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index df10d27f3a..9b92cf3a92 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -913,7 +913,7 @@ WebIDL::ExceptionOr<void> Window::post_message_impl(JS::Value message, Deprecate HTML::MessageEventInit event_init {}; event_init.data = message; event_init.origin = "<origin>"; - dispatch_event(*HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init)); + dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); }); return {}; } diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index a430fd579b..def9f1598e 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -166,7 +166,7 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti MessageEventInit event_init {}; event_init.data = message; event_init.origin = "<origin>"; - dispatch_event(*MessageEvent::create(*m_worker_realm, HTML::EventNames::message, event_init)); + dispatch_event(MessageEvent::create(*m_worker_realm, HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); })); return JS::js_undefined(); diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index e0fa3f6ad9..7551f2c1b7 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -235,7 +235,7 @@ void WebSocket::on_message(ByteBuffer message, bool is_text) HTML::MessageEventInit event_init; event_init.data = JS::PrimitiveString::create(vm(), text_message); event_init.origin = url(); - dispatch_event(*HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init)); + dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); return; } @@ -247,7 +247,7 @@ void WebSocket::on_message(ByteBuffer message, bool is_text) HTML::MessageEventInit event_init; event_init.data = JS::ArrayBuffer::create(realm(), message); event_init.origin = url(); - dispatch_event(*HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init)); + dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); return; } |