servoshell: Do handle prompts and other requests in headless mode when WebDriver is active (#37886)

Webdriver CI uses headless window, which skips the handling for alert
box.
It leads to unexpected `OK` in test results, which should be still
timeout.
This PR removes the skip, so test result in local and CI are
synchronized.

Testing:
7 unexpected `OK` are removed
https://github.com/longvatrong111/servo/actions/runs/16079192271
compared to CI on main:
https://github.com/longvatrong111/servo/actions/runs/16078898742

Fixes: https://github.com/servo/servo/issues/37875
Partially fixes: https://github.com/servo/servo/issues/37387

---------

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This commit is contained in:
batu_hoang 2025-07-07 21:23:00 +08:00 committed by GitHub
parent 71d97bd935
commit 9afe027567
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 409 additions and 26 deletions

View file

@ -452,7 +452,9 @@ impl WebViewDelegate for RunningAppState {
}
fn show_simple_dialog(&self, webview: servo::WebView, dialog: SimpleDialog) {
if self.servoshell_preferences.headless {
if self.servoshell_preferences.headless &&
self.servoshell_preferences.webdriver_port.is_none()
{
// TODO: Avoid copying this from the default trait impl?
// Return the DOM-specified default value for when we **cannot show simple dialogs**.
let _ = match dialog {
@ -477,7 +479,9 @@ impl WebViewDelegate for RunningAppState {
webview: WebView,
authentication_request: AuthenticationRequest,
) {
if self.servoshell_preferences.headless {
if self.servoshell_preferences.headless &&
self.servoshell_preferences.webdriver_port.is_none()
{
return;
}
@ -575,7 +579,9 @@ impl WebViewDelegate for RunningAppState {
}
fn request_permission(&self, webview: servo::WebView, permission_request: PermissionRequest) {
if self.servoshell_preferences.headless {
if self.servoshell_preferences.headless &&
self.servoshell_preferences.webdriver_port.is_none()
{
permission_request.deny();
return;
}
@ -635,7 +641,9 @@ impl WebViewDelegate for RunningAppState {
}
fn show_form_control(&self, webview: WebView, form_control: FormControl) {
if self.servoshell_preferences.headless {
if self.servoshell_preferences.headless &&
self.servoshell_preferences.webdriver_port.is_none()
{
return;
}