mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +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> {
|
||||
debug!("Getting focused context.");
|
||||
let interval = 20;
|
||||
let iterations = 30_000 / interval;
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
for _ in 0..iterations {
|
||||
let msg =
|
||||
EmbedderToConstellationMessage::GetFocusTopLevelBrowsingContext(sender.clone());
|
||||
self.constellation_chan.send(msg).unwrap();
|
||||
// Wait until the document is ready before returning the top-level browsing context id.
|
||||
if let Some(x) = receiver.recv().unwrap() {
|
||||
debug!("Focused context is {}", x);
|
||||
return Ok(x);
|
||||
}
|
||||
thread::sleep(Duration::from_millis(interval));
|
||||
let msg = EmbedderToConstellationMessage::GetFocusTopLevelBrowsingContext(sender.clone());
|
||||
self.constellation_chan.send(msg).unwrap();
|
||||
// Wait until the document is ready before returning the top-level browsing context id.
|
||||
match wait_for_script_response(receiver)? {
|
||||
Some(webview_id) => Ok(webview_id),
|
||||
None => Err(WebDriverError::new(
|
||||
ErrorStatus::NoSuchWindow,
|
||||
"No focused webview found",
|
||||
)),
|
||||
}
|
||||
|
||||
debug!("Timed out getting focused context.");
|
||||
Err(WebDriverError::new(
|
||||
ErrorStatus::Timeout,
|
||||
"Failed to get window handle",
|
||||
))
|
||||
}
|
||||
|
||||
fn session(&self) -> WebDriverResult<&WebDriverSession> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue