diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index e581ea0700e..d60baa5bd1f 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -1057,7 +1057,6 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badge Window::frame_element() const return container; } +// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-open +WebIDL::ExceptionOr> Window::open(Optional const& url, Optional const& target, Optional const& features) +{ + // The open(url, target, features) method steps are to run the window open steps with url, target, and features. + return open_impl(*url, *target, *features); +} + // https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator JS::NonnullGCPtr Window::navigator() const { @@ -1335,28 +1341,6 @@ void Window::post_message(JS::Value message, String const&) }); } -JS_DEFINE_NATIVE_FUNCTION(Window::open) -{ - auto* impl = TRY(impl_from(vm)); - - // optional USVString url = "" - DeprecatedString url = ""; - if (!vm.argument(0).is_undefined()) - url = TRY(vm.argument(0).to_deprecated_string(vm)); - - // optional DOMString target = "_blank" - DeprecatedString target = "_blank"; - if (!vm.argument(1).is_undefined()) - target = TRY(vm.argument(1).to_deprecated_string(vm)); - - // optional [LegacyNullToEmptyString] DOMString features = "") - DeprecatedString features = ""; - if (!vm.argument(2).is_nullish()) - features = TRY(vm.argument(2).to_deprecated_string(vm)); - - return TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return impl->open_impl(url, target, features); })); -} - static JS::ThrowCompletionOr make_timer_handler(JS::VM& vm, JS::Value handler) { if (handler.is_function()) diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index c338175bd0a..20c059cc220 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -147,6 +147,7 @@ public: JS::GCPtr top() const; JS::GCPtr parent() const; JS::GCPtr frame_element() const; + WebIDL::ExceptionOr> open(Optional const& url, Optional const& target, Optional const& features); JS::NonnullGCPtr navigator() const; @@ -254,7 +255,6 @@ private: JS_DECLARE_NATIVE_FUNCTION(origin_getter); JS_DECLARE_NATIVE_FUNCTION(is_secure_context_getter); - JS_DECLARE_NATIVE_FUNCTION(open); JS_DECLARE_NATIVE_FUNCTION(set_interval); JS_DECLARE_NATIVE_FUNCTION(set_timeout); JS_DECLARE_NATIVE_FUNCTION(clear_interval); diff --git a/Userland/Libraries/LibWeb/HTML/Window.idl b/Userland/Libraries/LibWeb/HTML/Window.idl index f05044c0d6d..2adcf89de90 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.idl +++ b/Userland/Libraries/LibWeb/HTML/Window.idl @@ -20,6 +20,7 @@ interface Window : EventTarget { [LegacyUnforgeable] readonly attribute WindowProxy? top; [Replaceable] readonly attribute WindowProxy? parent; readonly attribute Element? frameElement; + WindowProxy? open(optional USVString url = "", optional DOMString target = "_blank", optional [LegacyNullToEmptyString] DOMString features = ""); // the user agent readonly attribute Navigator navigator;