webdriver: Add handle any user prompts step for all commands (#38035)

- Add `handler any user prompt` step for all commands.
- Enable webdriver tests which were blocked by `handle any user prompt`
step.

---------

Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
This commit is contained in:
batu_hoang 2025-07-17 17:47:47 +08:00 committed by GitHub
parent 18d1a62add
commit 345733a5c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 859 additions and 472 deletions

View file

@ -577,8 +577,17 @@ impl App {
webdriver_script_command,
));
},
WebDriverCommandMsg::CurrentUserPrompt(webview_id, response_sender) => {
let current_dialog =
running_state.get_current_active_dialog_webdriver_type(webview_id);
if let Err(error) = response_sender.send(current_dialog) {
warn!("Failed to send response of CurrentUserPrompt: {error}");
};
},
WebDriverCommandMsg::HandleUserPrompt(webview_id, action, response_sender) => {
let response = if running_state.webview_has_active_dialog(webview_id) {
let alert_text = running_state.alert_text_of_newest_dialog(webview_id);
match action {
WebDriverUserPromptAction::Accept => {
running_state.accept_active_dialogs(webview_id)
@ -586,9 +595,14 @@ impl App {
WebDriverUserPromptAction::Dismiss => {
running_state.dismiss_active_dialogs(webview_id)
},
WebDriverUserPromptAction::Ignore => {},
};
Ok(())
// Return success for AcceptAlert and DismissAlert commands.
Ok(alert_text)
} else {
// Return error for AcceptAlert and DismissAlert commands
// if there is no active dialog.
Err(())
};
@ -622,7 +636,8 @@ impl App {
running_state: &RunningAppState,
) {
match msg {
WebDriverScriptCommand::ExecuteScript(_webview_id, response_sender) => {
WebDriverScriptCommand::ExecuteScript(_webview_id, response_sender) |
WebDriverScriptCommand::ExecuteAsyncScript(_webview_id, response_sender) => {
// Give embedder a chance to interrupt the script command.
// Webdriver only handles 1 script command at a time, so we can
// safely set a new interrupt sender and remove the previous one here.