webdriver: Focus browsing context when switch frame (#39086)

#38889 adds back the mechanism to focus the window when [switch to
window](https://w3c.github.io/webdriver/#switch-to-window). After that,
it causes many flaky TIMEOUT. Turns out the real reason is same as the
phenomenon which I thought was unrelated:
https://github.com/servo/servo/pull/38889#issuecomment-3217512339: we
need to focus the browsing context as well according to spec. This is
important for Servo because it relies on
f4dd2960b8/components/constellation/constellation_webview.rs (L64)
to determine which pipeline to send `InputEvent` to.

Testing: Before, there are 9 ~ 13 flaky results. [Before
1](https://github.com/yezhizhen/servo/actions/runs/17379170889), [Before
2](https://github.com/yezhizhen/servo/actions/runs/17392219417), [Before
3](https://github.com/yezhizhen/servo/actions/runs/17379172612).
Now there are 2 ~ 4 flaky results. [After
1](https://github.com/yezhizhen/servo/actions/runs/17394359570), [After
2](https://github.com/yezhizhen/servo/actions/runs/17394358218), [After
3](https://github.com/yezhizhen/servo/actions/runs/17394357400).
Fixes: https://github.com/servo/servo/pull/38889#issuecomment-3218600566
Fixes: #38906, which is last blocking point to enable WebDriver CI.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
Euclid Ye 2025-09-02 16:57:45 +08:00 committed by GitHub
parent 069ddbfd12
commit 802fdd9068
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 1 deletions

View file

@ -380,6 +380,9 @@ impl App {
running_state.set_pending_focus(focus_id, response_sender);
}
},
WebDriverCommandMsg::FocusBrowsingContext(..) => {
running_state.servo().execute_webdriver_command(msg);
},
WebDriverCommandMsg::GetAllWebViews(response_sender) => {
let webviews = running_state.webviews().iter().map(|(id, _)| *id).collect();