mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
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:
parent
b18a65ed70
commit
bce9f06cf8
18 changed files with 372 additions and 369 deletions
|
@ -2436,9 +2436,6 @@ impl ScriptThread {
|
|||
WebDriverScriptCommand::RemoveLoadStatusSender(_) => {
|
||||
webdriver_handlers::handle_remove_load_status_sender(&documents, pipeline_id)
|
||||
},
|
||||
WebDriverScriptCommand::GetWindowHandle(reply) => {
|
||||
webdriver_handlers::handle_get_window_handle(pipeline_id, reply)
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -460,9 +460,7 @@ unsafe fn jsval_to_webdriver_inner(
|
|||
} else {
|
||||
let pipeline = window.pipeline_id();
|
||||
if window_proxy.browsing_context_id() == window_proxy.webview_id() {
|
||||
Ok(JSValue::Window(
|
||||
window.Document().upcast::<Node>().unique_id(pipeline),
|
||||
))
|
||||
Ok(JSValue::Window(window.webview_id().to_string()))
|
||||
} else {
|
||||
Ok(JSValue::Frame(
|
||||
window.Document().upcast::<Node>().unique_id(pipeline),
|
||||
|
@ -2076,16 +2074,3 @@ pub(crate) fn handle_remove_load_status_sender(
|
|||
window.set_webdriver_load_status_sender(None);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn handle_get_window_handle(
|
||||
pipeline_id: PipelineId,
|
||||
reply: IpcSender<Result<String, ErrorStatus>>,
|
||||
) {
|
||||
if let Some(res) = ScriptThread::find_document(pipeline_id)
|
||||
.map(|document| document.upcast::<Node>().unique_id(pipeline_id))
|
||||
{
|
||||
reply.send(Ok(res)).ok();
|
||||
} else {
|
||||
reply.send(Err(ErrorStatus::NoSuchWindow)).ok();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue