diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index b613ebe28fd..84222389ccd 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -888,20 +888,6 @@ WindowProxy* Window::parent() return current->window_proxy(); } -// https://html.spec.whatwg.org/multipage/web-messaging.html#window-post-message-steps -WebIDL::ExceptionOr Window::post_message_impl(JS::Value message, DeprecatedString const&) -{ - // FIXME: This is an ad-hoc hack implementation instead, since we don't currently - // have serialization and deserialization of messages. - HTML::queue_global_task(HTML::Task::Source::PostedMessage, *this, [this, message] { - HTML::MessageEventInit event_init {}; - event_init.data = message; - event_init.origin = ""_string.release_value_but_fixme_should_propagate_errors(); - dispatch_event(HTML::MessageEvent::create(realm(), String::from_deprecated_string(HTML::EventNames::message).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors()); - }); - return {}; -} - // https://html.spec.whatwg.org/multipage/structured-data.html#dom-structuredclone WebIDL::ExceptionOr Window::structured_clone_impl(JS::VM& vm, JS::Value message) { @@ -1141,7 +1127,6 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badge Window::prompt(Optional const& message, Optionalouter_height()); } -JS_DEFINE_NATIVE_FUNCTION(Window::post_message) -{ - auto* impl = TRY(impl_from(vm)); - auto target_origin = TRY(vm.argument(1).to_deprecated_string(vm)); - TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { - return impl->post_message_impl(vm.argument(0), target_origin); - })); - return JS::js_undefined(); -} - JS_DEFINE_NATIVE_FUNCTION(Window::structured_clone) { auto* impl = TRY(impl_from(vm)); diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index b1819f22bc0..b88dad92e6c 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -119,7 +119,6 @@ public: // https://html.spec.whatwg.org/multipage/browsers.html#dom-parent WindowProxy* parent(); - WebIDL::ExceptionOr post_message_impl(JS::Value, DeprecatedString const& target_origin); WebIDL::ExceptionOr structured_clone_impl(JS::VM& vm, JS::Value); DeprecatedString name() const; @@ -145,6 +144,8 @@ public: bool confirm(Optional const& message); Optional prompt(Optional const& message, Optional const& default_); + void post_message(JS::Value message, String const&); + private: explicit Window(JS::Realm&); @@ -258,7 +259,6 @@ private: JS_DECLARE_NATIVE_FUNCTION(outer_width_getter); JS_DECLARE_NATIVE_FUNCTION(outer_height_getter); - JS_DECLARE_NATIVE_FUNCTION(post_message); JS_DECLARE_NATIVE_FUNCTION(structured_clone); JS_DECLARE_NATIVE_FUNCTION(local_storage_getter); diff --git a/Userland/Libraries/LibWeb/HTML/Window.idl b/Userland/Libraries/LibWeb/HTML/Window.idl index f8f891fde74..36989d95655 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.idl +++ b/Userland/Libraries/LibWeb/HTML/Window.idl @@ -9,6 +9,10 @@ interface Window : EventTarget { undefined alert(DOMString message); boolean confirm(optional DOMString message = ""); DOMString? prompt(optional DOMString message = "", optional DOMString default = ""); + + undefined postMessage(any message, USVString targetOrigin); + // FIXME: undefined postMessage(any message, USVString targetOrigin, optional sequence transfer = []); + // FIXME: undefined postMessage(any message, optional WindowPostMessageOptions options = {}); }; Window includes GlobalEventHandlers; Window includes WindowEventHandlers;