summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibWeb/WebDriver/Client.cpp1
-rw-r--r--Userland/Libraries/LibWeb/WebDriver/Client.h1
-rw-r--r--Userland/Services/WebContent/PageHost.cpp13
-rw-r--r--Userland/Services/WebContent/PageHost.h1
-rw-r--r--Userland/Services/WebContent/WebDriverClient.ipc1
-rw-r--r--Userland/Services/WebContent/WebDriverConnection.cpp17
-rw-r--r--Userland/Services/WebContent/WebDriverConnection.h1
-rw-r--r--Userland/Services/WebDriver/Client.cpp9
-rw-r--r--Userland/Services/WebDriver/Client.h1
9 files changed, 45 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/WebDriver/Client.cpp b/Userland/Libraries/LibWeb/WebDriver/Client.cpp
index c3f1db095a..3c048eefec 100644
--- a/Userland/Libraries/LibWeb/WebDriver/Client.cpp
+++ b/Userland/Libraries/LibWeb/WebDriver/Client.cpp
@@ -94,6 +94,7 @@ static constexpr auto s_webdriver_endpoints = Array {
ROUTE(DELETE, "/session/:session_id/cookie/:name"sv, delete_cookie),
ROUTE(DELETE, "/session/:session_id/cookie"sv, delete_all_cookies),
ROUTE(POST, "/session/:session_id/alert/dismiss"sv, dismiss_alert),
+ ROUTE(POST, "/session/:session_id/alert/accept"sv, accept_alert),
ROUTE(GET, "/session/:session_id/screenshot"sv, take_screenshot),
ROUTE(GET, "/session/:session_id/element/:element_id/screenshot"sv, take_element_screenshot),
};
diff --git a/Userland/Libraries/LibWeb/WebDriver/Client.h b/Userland/Libraries/LibWeb/WebDriver/Client.h
index fcde92d2ba..0766c41fdd 100644
--- a/Userland/Libraries/LibWeb/WebDriver/Client.h
+++ b/Userland/Libraries/LibWeb/WebDriver/Client.h
@@ -88,6 +88,7 @@ public:
// 16. User prompts, https://w3c.github.io/webdriver/#user-prompts
virtual Response dismiss_alert(Parameters parameters, JsonValue payload) = 0;
+ virtual Response accept_alert(Parameters parameters, JsonValue payload) = 0;
// 17. Screen capture, https://w3c.github.io/webdriver/#screen-capture
virtual Response take_screenshot(Parameters parameters, JsonValue payload) = 0;
diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp
index 71d9f39c7f..6f813bed0d 100644
--- a/Userland/Services/WebContent/PageHost.cpp
+++ b/Userland/Services/WebContent/PageHost.cpp
@@ -320,6 +320,19 @@ void PageHost::dismiss_dialog()
}
}
+void PageHost::accept_dialog()
+{
+ switch (m_pending_dialog) {
+ case PendingDialog::None:
+ break;
+ case PendingDialog::Alert:
+ case PendingDialog::Confirm:
+ case PendingDialog::Prompt:
+ m_client.async_did_request_accept_dialog();
+ break;
+ }
+}
+
void PageHost::page_did_change_favicon(Gfx::Bitmap const& favicon)
{
m_client.async_did_change_favicon(favicon.to_shareable_bitmap());
diff --git a/Userland/Services/WebContent/PageHost.h b/Userland/Services/WebContent/PageHost.h
index a63c5be750..1d8ba75446 100644
--- a/Userland/Services/WebContent/PageHost.h
+++ b/Userland/Services/WebContent/PageHost.h
@@ -56,6 +56,7 @@ public:
bool has_pending_dialog() const { return m_pending_dialog != PendingDialog::None; }
PendingDialog pending_dialog() const { return m_pending_dialog; }
void dismiss_dialog();
+ void accept_dialog();
private:
// ^PageClient
diff --git a/Userland/Services/WebContent/WebDriverClient.ipc b/Userland/Services/WebContent/WebDriverClient.ipc
index 39a6430608..4a84d5cdec 100644
--- a/Userland/Services/WebContent/WebDriverClient.ipc
+++ b/Userland/Services/WebContent/WebDriverClient.ipc
@@ -44,6 +44,7 @@ endpoint WebDriverClient {
delete_cookie(String name) => (Web::WebDriver::Response response)
delete_all_cookies() => (Web::WebDriver::Response response)
dismiss_alert() => (Web::WebDriver::Response response)
+ accept_alert() => (Web::WebDriver::Response response)
take_screenshot() => (Web::WebDriver::Response response)
take_element_screenshot(String element_id) => (Web::WebDriver::Response response)
}
diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp
index 984221f543..19aac72617 100644
--- a/Userland/Services/WebContent/WebDriverConnection.cpp
+++ b/Userland/Services/WebContent/WebDriverConnection.cpp
@@ -1360,6 +1360,23 @@ Messages::WebDriverClient::DismissAlertResponse WebDriverConnection::dismiss_ale
return JsonValue {};
}
+// 16.2 Accept Alert, https://w3c.github.io/webdriver/#accept-alert
+Messages::WebDriverClient::AcceptAlertResponse WebDriverConnection::accept_alert()
+{
+ // 1. If the current top-level browsing context is no longer open, return error with error code no such window.
+ TRY(ensure_open_top_level_browsing_context());
+
+ // 2. If there is no current user prompt, return error with error code no such alert.
+ if (!m_page_host.has_pending_dialog())
+ return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchAlert, "No user dialog is currently open"sv);
+
+ // 3. Accept the current user prompt.
+ m_page_host.accept_dialog();
+
+ // 4. Return success with data null.
+ return JsonValue {};
+}
+
// 17.1 Take Screenshot, https://w3c.github.io/webdriver/#take-screenshot
Messages::WebDriverClient::TakeScreenshotResponse WebDriverConnection::take_screenshot()
{
diff --git a/Userland/Services/WebContent/WebDriverConnection.h b/Userland/Services/WebContent/WebDriverConnection.h
index d010c9bf3b..3d8d1e9932 100644
--- a/Userland/Services/WebContent/WebDriverConnection.h
+++ b/Userland/Services/WebContent/WebDriverConnection.h
@@ -79,6 +79,7 @@ private:
virtual Messages::WebDriverClient::DeleteCookieResponse delete_cookie(String const& name) override;
virtual Messages::WebDriverClient::DeleteAllCookiesResponse delete_all_cookies() override;
virtual Messages::WebDriverClient::DismissAlertResponse dismiss_alert() override;
+ virtual Messages::WebDriverClient::AcceptAlertResponse accept_alert() override;
virtual Messages::WebDriverClient::TakeScreenshotResponse take_screenshot() override;
virtual Messages::WebDriverClient::TakeElementScreenshotResponse take_element_screenshot(String const& element_id) override;
diff --git a/Userland/Services/WebDriver/Client.cpp b/Userland/Services/WebDriver/Client.cpp
index 935e2a5523..f6ff10263f 100644
--- a/Userland/Services/WebDriver/Client.cpp
+++ b/Userland/Services/WebDriver/Client.cpp
@@ -548,6 +548,15 @@ Web::WebDriver::Response Client::dismiss_alert(Web::WebDriver::Parameters parame
return session->web_content_connection().dismiss_alert();
}
+// 16.2 Accept Alert, https://w3c.github.io/webdriver/#accept-alert
+// POST /session/{session id}/alert/accept
+Web::WebDriver::Response Client::accept_alert(Web::WebDriver::Parameters parameters, JsonValue)
+{
+ dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/alert/accept");
+ auto* session = TRY(find_session_with_id(parameters[0]));
+ return session->web_content_connection().accept_alert();
+}
+
// 17.1 Take Screenshot, https://w3c.github.io/webdriver/#take-screenshot
// GET /session/{session id}/screenshot
Web::WebDriver::Response Client::take_screenshot(Web::WebDriver::Parameters parameters, JsonValue)
diff --git a/Userland/Services/WebDriver/Client.h b/Userland/Services/WebDriver/Client.h
index e0efa85b22..c4e47879ce 100644
--- a/Userland/Services/WebDriver/Client.h
+++ b/Userland/Services/WebDriver/Client.h
@@ -77,6 +77,7 @@ private:
virtual Web::WebDriver::Response delete_cookie(Web::WebDriver::Parameters parameters, JsonValue payload) override;
virtual Web::WebDriver::Response delete_all_cookies(Web::WebDriver::Parameters parameters, JsonValue payload) override;
virtual Web::WebDriver::Response dismiss_alert(Web::WebDriver::Parameters parameters, JsonValue payload) override;
+ virtual Web::WebDriver::Response accept_alert(Web::WebDriver::Parameters parameters, JsonValue payload) override;
virtual Web::WebDriver::Response take_screenshot(Web::WebDriver::Parameters parameters, JsonValue payload) override;
virtual Web::WebDriver::Response take_element_screenshot(Web::WebDriver::Parameters parameters, JsonValue payload) override;