mirror of
https://github.com/servo/servo.git
synced 2025-07-17 12:23:40 +01:00
webdriver: Implement support for simple dialogs (#37913)
Implement webdriver user prompt: accept alert, dismiss alert, get alert text. Tests: https://github.com/longvatrong111/servo/actions/runs/16175408035 https://github.com/longvatrong111/servo/actions/runs/16175409545 Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This commit is contained in:
parent
84f0cd5801
commit
2e44aba753
9 changed files with 296 additions and 42 deletions
|
@ -160,6 +160,59 @@ pub enum SimpleDialog {
|
|||
},
|
||||
}
|
||||
|
||||
impl SimpleDialog {
|
||||
/// Returns the message of the dialog.
|
||||
pub fn message(&self) -> &str {
|
||||
match self {
|
||||
SimpleDialog::Alert { message, .. } => message,
|
||||
SimpleDialog::Confirm { message, .. } => message,
|
||||
SimpleDialog::Prompt { message, .. } => message,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dismiss(&self) {
|
||||
match self {
|
||||
SimpleDialog::Alert {
|
||||
response_sender, ..
|
||||
} => {
|
||||
let _ = response_sender.send(AlertResponse::Ok);
|
||||
},
|
||||
SimpleDialog::Confirm {
|
||||
response_sender, ..
|
||||
} => {
|
||||
let _ = response_sender.send(ConfirmResponse::Cancel);
|
||||
},
|
||||
SimpleDialog::Prompt {
|
||||
response_sender, ..
|
||||
} => {
|
||||
let _ = response_sender.send(PromptResponse::Cancel);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn accept(&self) {
|
||||
match self {
|
||||
SimpleDialog::Alert {
|
||||
response_sender, ..
|
||||
} => {
|
||||
let _ = response_sender.send(AlertResponse::Ok);
|
||||
},
|
||||
SimpleDialog::Confirm {
|
||||
response_sender, ..
|
||||
} => {
|
||||
let _ = response_sender.send(ConfirmResponse::Ok);
|
||||
},
|
||||
SimpleDialog::Prompt {
|
||||
default,
|
||||
response_sender,
|
||||
..
|
||||
} => {
|
||||
let _ = response_sender.send(PromptResponse::Ok(default.clone()));
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, PartialEq, Serialize)]
|
||||
pub struct AuthenticationResponse {
|
||||
/// Username for http request authentication
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue