servoshell: Do not focus and raise new auxiliary WebDriver-created WebViews (#37284)

For Desktop port of `request_open_auxiliary_webview`, stay on the
original WebView if the request originates WebDriver.

This is to make sure `webdriver_server::handle_new_window` does not
focus the new window, according to spec. See
c7eba2dbba/tests/wpt/tests/webdriver/tests/classic/new_window/new_window.py (L31-L37)

**To clarify**: this won't change the behaviour when user interacts, but
only affects WebDriver [New
Window](https://w3c.github.io/webdriver/#new-window).

Testing: `./mach test-wpt -r --log-raw "D:/servo log/all.txt"
./tests/wpt/tests/webdriver/tests/classic --product servodriver` based
on 96b0973037

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
Euclid Ye 2025-06-09 19:07:09 +08:00 committed by GitHub
parent 0fa3de3937
commit a3c792e5aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 76 additions and 158 deletions

View file

@ -12,7 +12,7 @@ use image::{DynamicImage, ImageFormat};
use keyboard_types::{Key, KeyboardEvent, Modifiers, ShortcutMatcher};
use log::{error, info};
use servo::base::id::WebViewId;
use servo::config::pref;
use servo::config::{opts, pref};
use servo::ipc_channel::ipc::IpcSender;
use servo::webrender_api::ScrollLocation;
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
@ -477,9 +477,13 @@ impl WebViewDelegate for RunningAppState {
.build();
webview.notify_theme_change(self.inner().window.theme());
webview.focus();
webview.raise_to_top(true);
// When WebDriver is enabled, do not focus and raise the WebView to the top,
// as that is what the specification expects. Otherwise, we would like `window.open()`
// to create a new foreground tab
if opts::get().webdriver_port.is_some() {
webview.focus();
webview.raise_to_top(true);
}
self.add(webview.clone());
Some(webview)
}