summaryrefslogtreecommitdiff
path: root/Userland/Services/WebContent/WebDriverConnection.cpp
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-11-16 07:15:57 -0500
committerLinus Groh <mail@linusgroh.de>2022-11-16 17:23:56 +0000
commit7cf2feb04739e79ef84b0585a1cdca26c111167f (patch)
tree208b30b018e357591511f49e28cf2287ed1e79ba /Userland/Services/WebContent/WebDriverConnection.cpp
parent159dcb950718ad5784a3172ec9fbefdb8e5d60d6 (diff)
downloadserenity-7cf2feb04739e79ef84b0585a1cdca26c111167f.zip
LibWeb+WebContent+WebDriver: Implement Dismiss Alert
Diffstat (limited to 'Userland/Services/WebContent/WebDriverConnection.cpp')
-rw-r--r--Userland/Services/WebContent/WebDriverConnection.cpp17
1 files changed, 17 insertions, 0 deletions
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()
{