INNER CODE UNIT · Rust
current_target
keon/browser-control · src/cdp.rs:189
pub async fn current_target(&mut self) -> Result<String> {
if let Some(id) = read_current_tab() {
let targets = self.send("Target.getTargets", json!({}), None).await?;
if targets["targetInfos"]
.as_array()
.into_iter()
.flatten()
.any(|t| t["targetId"].as_str() == Some(&id) && t["type"] == "page")
{
return Ok(id);
}
clear_current_tab()?;
}
self.first_tab().await?.context("tab not found")
}
pub async fn wait_network_idle(&mut self, timeout: Duration, idle: Duration) -> Result<bool> {
if self.session.is_none() {