mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Webdriver get focused webview id only request once (#37506)
The retry in previous implementation doesn't have a good reason, it seems like webdriver just want to try its luck. If get focused webview return None, better just return it. There is a case webdriver still runs when all webview are closed. cc: @xiaochengh Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This commit is contained in:
parent
50531026a8
commit
152467bc67
1 changed files with 9 additions and 18 deletions
|
@ -464,27 +464,18 @@ impl Handler {
|
||||||
|
|
||||||
fn focus_webview_id(&self) -> WebDriverResult<WebViewId> {
|
fn focus_webview_id(&self) -> WebDriverResult<WebViewId> {
|
||||||
debug!("Getting focused context.");
|
debug!("Getting focused context.");
|
||||||
let interval = 20;
|
|
||||||
let iterations = 30_000 / interval;
|
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
|
|
||||||
for _ in 0..iterations {
|
let msg = EmbedderToConstellationMessage::GetFocusTopLevelBrowsingContext(sender.clone());
|
||||||
let msg =
|
self.constellation_chan.send(msg).unwrap();
|
||||||
EmbedderToConstellationMessage::GetFocusTopLevelBrowsingContext(sender.clone());
|
// Wait until the document is ready before returning the top-level browsing context id.
|
||||||
self.constellation_chan.send(msg).unwrap();
|
match wait_for_script_response(receiver)? {
|
||||||
// Wait until the document is ready before returning the top-level browsing context id.
|
Some(webview_id) => Ok(webview_id),
|
||||||
if let Some(x) = receiver.recv().unwrap() {
|
None => Err(WebDriverError::new(
|
||||||
debug!("Focused context is {}", x);
|
ErrorStatus::NoSuchWindow,
|
||||||
return Ok(x);
|
"No focused webview found",
|
||||||
}
|
)),
|
||||||
thread::sleep(Duration::from_millis(interval));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Timed out getting focused context.");
|
|
||||||
Err(WebDriverError::new(
|
|
||||||
ErrorStatus::Timeout,
|
|
||||||
"Failed to get window handle",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn session(&self) -> WebDriverResult<&WebDriverSession> {
|
fn session(&self) -> WebDriverResult<&WebDriverSession> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue