diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp
index 7de18b1fdf4..b613ebe28fd 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Window.cpp
@@ -430,13 +430,6 @@ WebIDL::ExceptionOr> Window::open_impl(StringView u
return target_browsing_context->window_proxy();
}
-DeprecatedString Window::prompt_impl(DeprecatedString const& message, DeprecatedString const& default_)
-{
- if (auto* page = this->page())
- return page->did_request_prompt(message, default_);
- return {};
-}
-
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
i32 Window::set_timeout_impl(TimerHandler handler, i32 timeout, JS::MarkedVector arguments)
{
@@ -1129,7 +1122,6 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badge const& message)
return false;
}
+// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-prompt
+Optional Window::prompt(Optional const& message, Optional const& default_)
+{
+ // FIXME: Make this fully spec compliant.
+ if (auto* page = this->page()) {
+ auto response = page->did_request_prompt(message->to_deprecated_string(), default_->to_deprecated_string());
+ if (response.is_null())
+ return {};
+ return String::from_deprecated_string(response).release_value_but_fixme_should_propagate_errors();
+ }
+ return {};
+}
+
JS_DEFINE_NATIVE_FUNCTION(Window::open)
{
auto* impl = TRY(impl_from(vm));
@@ -1274,21 +1279,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::open)
return TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return impl->open_impl(url, target, features); }));
}
-JS_DEFINE_NATIVE_FUNCTION(Window::prompt)
-{
- auto* impl = TRY(impl_from(vm));
- DeprecatedString message = "";
- DeprecatedString default_ = "";
- if (!vm.argument(0).is_undefined())
- message = TRY(vm.argument(0).to_deprecated_string(vm));
- if (!vm.argument(1).is_undefined())
- default_ = TRY(vm.argument(1).to_deprecated_string(vm));
- auto response = impl->prompt_impl(message, default_);
- if (response.is_null())
- return JS::js_null();
- return JS::PrimitiveString::create(vm, response);
-}
-
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 d6266a962b5..b1819f22bc0 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.h
+++ b/Userland/Libraries/LibWeb/HTML/Window.h
@@ -66,7 +66,6 @@ public:
void set_import_maps_allowed(bool import_maps_allowed) { m_import_maps_allowed = import_maps_allowed; }
WebIDL::ExceptionOr> open_impl(StringView url, StringView target, StringView features);
- DeprecatedString prompt_impl(DeprecatedString const&, DeprecatedString const&);
i32 request_animation_frame_impl(WebIDL::CallbackType& js_callback);
void cancel_animation_frame_impl(i32);
bool has_animation_frame_callbacks() const { return m_animation_frame_callback_driver.has_callbacks(); }
@@ -144,6 +143,7 @@ public:
// JS API functions
void alert(String const& message = {});
bool confirm(Optional const& message);
+ Optional prompt(Optional const& message, Optional const& default_);
private:
explicit Window(JS::Realm&);
@@ -267,7 +267,6 @@ private:
JS_DECLARE_NATIVE_FUNCTION(is_secure_context_getter);
JS_DECLARE_NATIVE_FUNCTION(open);
- JS_DECLARE_NATIVE_FUNCTION(prompt);
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 21cfe24f835..f8f891fde74 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.idl
+++ b/Userland/Libraries/LibWeb/HTML/Window.idl
@@ -8,6 +8,7 @@ interface Window : EventTarget {
undefined alert();
undefined alert(DOMString message);
boolean confirm(optional DOMString message = "");
+ DOMString? prompt(optional DOMString message = "", optional DOMString default = "");
};
Window includes GlobalEventHandlers;
Window includes WindowEventHandlers;