(
client: &mut CdpClient,
session_id: &str,
output: Option<&str>,
)
| 105 | } |
| 106 | |
| 107 | async fn go_forward( |
| 108 | client: &mut CdpClient, |
| 109 | session_id: &str, |
| 110 | output: Option<&str>, |
| 111 | ) -> Result<CommandResult> { |
| 112 | let history = client |
| 113 | .send_to_target(session_id, "Page.getNavigationHistory", json!({})) |
| 114 | .await?; |
| 115 | |
| 116 | let current_index = history["currentIndex"].as_i64().unwrap_or(0) as usize; |
| 117 | let entries = history["entries"] |
| 118 | .as_array() |
| 119 | .ok_or_else(|| anyhow::anyhow!("No navigation history entries"))?; |
| 120 | |
| 121 | if current_index + 1 >= entries.len() { |
| 122 | bail!("Already at the end of history"); |
| 123 | } |
| 124 | |
| 125 | let next_entry = &entries[current_index + 1]; |
| 126 | let entry_id = next_entry["id"].as_i64().unwrap_or(0); |
| 127 | |
| 128 | client |
| 129 | .send_to_target( |
| 130 | session_id, |
| 131 | "Page.navigateToHistoryEntry", |
| 132 | json!({"entryId": entry_id}), |
| 133 | ) |
| 134 | .await?; |
| 135 | |
| 136 | wait_for_load(client, session_id, NAVIGATION_TIMEOUT_MS).await?; |
| 137 | let url = next_entry["url"].as_str().unwrap_or("unknown"); |
| 138 | let result = CommandResult::output(format!("Navigated forward to {url}")) |
| 139 | .with_navigated_to(url.to_string()); |
| 140 | Ok(result.save_output(output).await?) |
| 141 | } |
| 142 | |
| 143 | async fn do_reload( |
| 144 | client: &mut CdpClient, |
no test coverage detected