MCPcopy Create free account
hub / github.com/aeroxy/chrome-devtools-cli / go_forward

Function go_forward

src/commands/navigate.rs:107–141  ·  view source on GitHub ↗
(
    client: &mut CdpClient,
    session_id: &str,
    output: Option<&str>,
)

Source from the content-addressed store, hash-verified

105}
106
107async 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
143async fn do_reload(
144 client: &mut CdpClient,

Callers 1

navigateFunction · 0.85

Calls 4

wait_for_loadFunction · 0.85
send_to_targetMethod · 0.80
with_navigated_toMethod · 0.80
save_outputMethod · 0.80

Tested by

no test coverage detected