webdriver: Refactor webdriver session and improve window handles (#38745)

This PR contains 2 parts:

1. Refactor webdriver session.
2. Improve webdriver window handles:
- Webdriver always get window handles from script thread by default.
- If script thread is blocked by user prompt, embedder stores the window
handle before user prompt appears, then webdriver can get window handle
from embedder.

Testing: Clear timeout cause by user prompt blocking script thread:
https://github.com/longvatrong111/servo/actions/runs/17033900026

---------

Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Co-authored-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
batu_hoang 2025-08-22 06:46:13 +08:00 committed by GitHub
parent b18a65ed70
commit bce9f06cf8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 372 additions and 369 deletions

View file

@ -156,8 +156,8 @@ pub enum WebDriverCommandMsg {
FocusWebView(WebViewId, IpcSender<bool>),
/// Get focused webview. For now, this is only used when start new session.
GetFocusedWebView(IpcSender<Option<WebViewId>>),
/// Get all webviews
GetAllWebViews(IpcSender<Result<Vec<WebViewId>, ErrorStatus>>),
/// Get webviews state
GetAllWebViews(IpcSender<Vec<WebViewId>>),
/// Check whether top-level browsing context is open.
IsWebViewOpen(WebViewId, IpcSender<bool>),
/// Check whether browsing context is open.
@ -246,7 +246,6 @@ pub enum WebDriverScriptCommand {
WillSendKeys(String, String, bool, IpcSender<Result<bool, ErrorStatus>>),
AddLoadStatusSender(WebViewId, IpcSender<WebDriverLoadStatus>),
RemoveLoadStatusSender(WebViewId),
GetWindowHandle(IpcSender<Result<String, ErrorStatus>>),
}
#[derive(Debug, Deserialize, Serialize)]