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

@ -949,6 +949,7 @@ impl Handler {
)))
}
/// <https://w3c.github.io/webdriver/#new-window>
fn handle_new_window(
&mut self,
_parameters: &NewWindowParameters,
@ -956,11 +957,16 @@ impl Handler {
let (sender, receiver) = ipc::channel().unwrap();
let session = self.session().unwrap();
// Step 2. (TODO) If session's current top-level browsing context is no longer open,
// return error with error code no such window.
let cmd_msg = WebDriverCommandMsg::NewWebView(
session.webview_id,
sender,
self.load_status_sender.clone(),
);
// Step 5. Create a new top-level browsing context by running the window open steps.
// This MUST be done without invoking the focusing steps.
self.constellation_chan
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
.unwrap();
@ -968,8 +974,6 @@ impl Handler {
let mut handle = self.session.as_ref().unwrap().id.to_string();
if let Ok(new_webview_id) = receiver.recv() {
let session = self.session_mut().unwrap();
session.webview_id = new_webview_id;
session.browsing_context_id = BrowsingContextId::from(new_webview_id);
let new_handle = Uuid::new_v4().to_string();
handle = new_handle.clone();
session.window_handles.insert(new_webview_id, new_handle);