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:
batu_hoang 2025-07-10 11:15:46 +08:00 committed by GitHub
parent 84f0cd5801
commit 2e44aba753
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 296 additions and 42 deletions

View file

@ -28,6 +28,12 @@ use crate::{MouseButton, MouseButtonAction};
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct WebDriverMessageId(pub usize);
#[derive(Debug, Deserialize, Serialize)]
pub enum WebDriverUserPromptAction {
Accept,
Dismiss,
}
/// Messages to the constellation originating from the WebDriver server.
#[derive(Debug, Deserialize, Serialize)]
pub enum WebDriverCommandMsg {
@ -115,6 +121,12 @@ pub enum WebDriverCommandMsg {
IsWebViewOpen(WebViewId, IpcSender<bool>),
/// Check whether browsing context is open.
IsBrowsingContextOpen(BrowsingContextId, IpcSender<bool>),
HandleUserPrompt(
WebViewId,
WebDriverUserPromptAction,
IpcSender<Result<(), ()>>,
),
GetAlertText(WebViewId, IpcSender<Result<String, ()>>),
}
#[derive(Debug, Deserialize, Serialize)]
@ -237,4 +249,5 @@ pub enum WebDriverLoadStatus {
Complete,
Timeout,
Canceled,
Blocked,
}