summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/WebDriver/Client.cpp1
-rw-r--r--Userland/Libraries/LibWeb/WebDriver/Client.h3
-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
7 files changed, 33 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/WebDriver/Client.cpp b/Userland/Libraries/LibWeb/WebDriver/Client.cpp
index 291cbbe3f3..c3f1db095a 100644
--- a/Userland/Libraries/LibWeb/WebDriver/Client.cpp
+++ b/Userland/Libraries/LibWeb/WebDriver/Client.cpp
@@ -93,6 +93,7 @@ static constexpr auto s_webdriver_endpoints = Array {
ROUTE(POST, "/session/:session_id/cookie"sv, add_cookie),
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(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 e9b203615e..fcde92d2ba 100644
--- a/Userland/Libraries/LibWeb/WebDriver/Client.h
+++ b/Userland/Libraries/LibWeb/WebDriver/Client.h
@@ -86,6 +86,9 @@ public:
virtual Response delete_cookie(Parameters parameters, JsonValue payload) = 0;
virtual Response delete_all_cookies(Parameters parameters, JsonValue payload) = 0;
+ // 16. User prompts, https://w3c.github.io/webdriver/#user-prompts
+ virtual Response dismiss_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;
virtual Response take_element_screenshot(Parameters parameters, JsonValue payload) = 0;
diff --git a/Userland/Services/WebContent/WebDriverClient.ipc b/Userland/Services/WebContent/WebDriverClient.ipc
index 570cc133c9..39a6430608 100644
--- a/Userland/Services/WebContent/WebDriverClient.ipc
+++ b/Userland/Services/WebContent/WebDriverClient.ipc
@@ -43,6 +43,7 @@ endpoint WebDriverClient {
add_cookie(JsonValue payload) => (Web::WebDriver::Response response)
delete_cookie(String name) => (Web::WebDriver::Response response)
delete_all_cookies() => (Web::WebDriver::Response response)
+ dismiss_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 d63b1da4bc..984221f543 100644
--- a/Userland/Services/WebContent/WebDriverConnection.cpp
+++ b/Userland/Services/WebContent/WebDriverConnection.cpp
@@ -1343,6 +1343,23 @@ Messages::WebDriverClient::DeleteAllCookiesResponse WebDriverConnection::delete_
return JsonValue {};
}
+// 16.1 Dismiss Alert, https://w3c.github.io/webdriver/#dismiss-alert
+Messages::WebDriverClient::DismissAlertResponse WebDriverConnection::dismiss_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. Dismiss the current user prompt.
+ m_page_host.dismiss_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 6c31d61c95..d010c9bf3b 100644
--- a/Userland/Services/WebContent/WebDriverConnection.h
+++ b/Userland/Services/WebContent/WebDriverConnection.h
@@ -78,6 +78,7 @@ private:
virtual Messages::WebDriverClient::AddCookieResponse add_cookie(JsonValue const& payload) override;
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::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 bde5912f22..935e2a5523 100644
--- a/Userland/Services/WebDriver/Client.cpp
+++ b/Userland/Services/WebDriver/Client.cpp
@@ -539,6 +539,15 @@ Web::WebDriver::Response Client::delete_all_cookies(Web::WebDriver::Parameters p
return session->web_content_connection().delete_all_cookies();
}
+// 16.1 Dismiss Alert, https://w3c.github.io/webdriver/#dismiss-alert
+// POST /session/{session id}/alert/dismiss
+Web::WebDriver::Response Client::dismiss_alert(Web::WebDriver::Parameters parameters, JsonValue)
+{
+ dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/alert/dismiss");
+ auto* session = TRY(find_session_with_id(parameters[0]));
+ return session->web_content_connection().dismiss_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 2b168d8494..e0efa85b22 100644
--- a/Userland/Services/WebDriver/Client.h
+++ b/Userland/Services/WebDriver/Client.h
@@ -76,6 +76,7 @@ private:
virtual Web::WebDriver::Response add_cookie(Web::WebDriver::Parameters parameters, JsonValue payload) override;
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 take_screenshot(Web::WebDriver::Parameters parameters, JsonValue payload) override;
virtual Web::WebDriver::Response take_element_screenshot(Web::WebDriver::Parameters parameters, JsonValue payload) override;