webdriver: Implement the "Get Window Handles" command (#38622)

Implment get window handles according to
[spec](https://w3c.github.io/webdriver/#dfn-window-handles).
- Window handles are supposed to identify `browsing context`. However,
based on `get window handle command` and `get window handles command`,
we only need to care about top level browsing context.
- Back then, we use a random generated uuid for eacch webview id, it is
not correct but still work because all commands depend on `webview id`
and `browsing context id`. The only case we need window handle is is
when webdriver gets window object with js script. Since the object is
converted to the id of window's document node, `get window handle`
should return the same thing.

Action run (with updated expectation):
https://github.com/longvatrong111/servo/actions/runs/16957610535
https://github.com/longvatrong111/servo/actions/runs/16957612027

Some tests may sporadically timeout due to unstable hit test.

cc: @xiaochengh

---------

Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
This commit is contained in:
batu_hoang 2025-08-15 11:30:56 +08:00 committed by GitHub
parent dafb0abf31
commit f24f225db8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 116 additions and 98 deletions

View file

@ -381,6 +381,17 @@ impl App {
running_state.set_pending_focus(focus_id, response_sender);
}
},
WebDriverCommandMsg::GetAllWebViews(response_sender) => {
let webviews = running_state
.webviews()
.iter()
.map(|(id, _)| *id)
.collect::<Vec<_>>();
if let Err(error) = response_sender.send(Ok(webviews)) {
warn!("Failed to send response of GetAllWebViews: {error}");
}
},
WebDriverCommandMsg::GetWindowRect(_webview_id, response_sender) => {
let window = self
.windows