webdriver: Implement send alert text (#38140)

Implement webdriver `SendAlertText` command

Tests:
https://github.com/longvatrong111/servo/actions/runs/16342669929
https://github.com/longvatrong111/servo/actions/runs/16342671477

cc: @xiaochengh

---------

Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This commit is contained in:
batu_hoang 2025-07-18 05:24:50 +08:00 committed by GitHub
parent 3ce95b2ba5
commit f0e10e63e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 91 additions and 46 deletions

View file

@ -620,6 +620,9 @@ impl App {
warn!("Failed to send response of GetAlertText: {error}");
};
},
WebDriverCommandMsg::SendAlertText(webview_id, text) => {
running_state.set_alert_text_of_newest_dialog(webview_id, text);
},
WebDriverCommandMsg::TakeScreenshot(..) => {
warn!(
"WebDriverCommand {:?} is still not moved from constellation to embedder",

View file

@ -381,6 +381,14 @@ impl RunningAppState {
.and_then(|dialog| dialog.message())
}
pub(crate) fn set_alert_text_of_newest_dialog(&self, webview_id: WebViewId, text: String) {
if let Some(dialogs) = self.inner_mut().dialogs.get_mut(&webview_id) {
if let Some(dialog) = dialogs.last_mut() {
dialog.set_message(text);
}
}
}
pub(crate) fn get_focused_webview_index(&self) -> Option<usize> {
let focused_id = self.inner().focused_webview_id?;
self.webviews()

View file

@ -168,6 +168,12 @@ impl Dialog {
}
}
pub fn set_message(&mut self, text: String) {
if let Dialog::SimpleDialog(dialog) = self {
dialog.set_message(text);
}
}
pub fn update(&mut self, ctx: &egui::Context) -> bool {
match self {
Dialog::File {