diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-11-17 16:45:19 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-11-18 12:21:57 +0000 |
commit | 37c4bf3afdfb9a8690ddd752e68e604ed260c945 (patch) | |
tree | 66510af79edc2063a1ee6da6bed42702d20de38e /Userland | |
parent | adc7977ec76e3c90e5aa01f034aa7bc62fb0caf1 (diff) | |
download | serenity-37c4bf3afdfb9a8690ddd752e68e604ed260c945.zip |
WebDriver: Implement all modes for handling the current user prompt
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Services/WebContent/WebDriverConnection.cpp | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index 8540ad8133..c41b3c40fe 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -1527,27 +1527,40 @@ ErrorOr<void, Web::WebDriver::Error> WebDriverConnection::handle_any_user_prompt return {}; // 2. Perform the following substeps based on the current session’s user prompt handler: - - // FIXME: The user prompt handler is a capability-level configuration, which we have no support - // for yet. It defaults to "dismiss and notify", so that is all that is handled here. - + switch (m_unhandled_prompt_behavior) { // -> dismiss state - // Dismiss the current user prompt. + case Web::WebDriver::UnhandledPromptBehavior::Dismiss: + // Dismiss the current user prompt. + m_page_host.dismiss_dialog(); + break; + // -> accept state - // Accept the current user prompt. + case Web::WebDriver::UnhandledPromptBehavior::Accept: + // Accept the current user prompt. + m_page_host.accept_dialog(); + break; + // -> dismiss and notify state - if (true) { + case Web::WebDriver::UnhandledPromptBehavior::DismissAndNotify: // Dismiss the current user prompt. m_page_host.dismiss_dialog(); // Return an annotated unexpected alert open error. return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnexpectedAlertOpen, "A user dialog is open"sv); - } + // -> accept and notify state - // Accept the current user prompt. - // Return an annotated unexpected alert open error. + case Web::WebDriver::UnhandledPromptBehavior::AcceptAndNotify: + // Accept the current user prompt. + m_page_host.accept_dialog(); + + // Return an annotated unexpected alert open error. + return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnexpectedAlertOpen, "A user dialog is open"sv); + // -> ignore state - // Return an annotated unexpected alert open error. + case Web::WebDriver::UnhandledPromptBehavior::Ignore: + // Return an annotated unexpected alert open error. + return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnexpectedAlertOpen, "A user dialog is open"sv); + } // 3. Return success. return {}; |