webdriver: Raise WebView to top when focus (#38909)

- Add a helper function `focus_and_raise_to_top` to `WebView`.
- For webdriver, raise webview to top when focus, to make it consistent
with user interaction.

Testing: Should reduce some flaky TIMEOUT when combined with another PR
later.
Fixes: A small patch before the PR for #38906.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
Euclid Ye 2025-08-26 15:48:38 +08:00 committed by GitHub
parent 01a9b317d4
commit 8683f97fcc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 14 additions and 16 deletions

View file

@ -406,12 +406,8 @@ impl Window {
})
.shortcut(Modifiers::CONTROL, Key::Named(NamedKey::PageUp), || {
if let Some(index) = state.get_focused_webview_index() {
let new_index = if index == 0 {
state.webviews().len() - 1
} else {
index - 1
};
state.focus_webview_by_index(new_index)
let len = state.webviews().len();
state.focus_webview_by_index((index + len - 1) % len);
}
})
.shortcut(CMD_OR_CONTROL, 'T', || {