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

Function inner_execute

src/commands/executor.rs:344–640  ·  view source on GitHub ↗

Execute a page-level command within an active session.

(
    client: &mut CdpClient,
    session_id: &str,
    req: &DaemonRequest,
)

Source from the content-addressed store, hash-verified

342
343/// Execute a page-level command within an active session.
344async fn inner_execute(
345 client: &mut CdpClient,
346 session_id: &str,
347 req: &DaemonRequest,
348) -> Result<CommandResult> {
349 let args = &req.args;
350 let cmd = req.command.as_str();
351
352 // Enable Page domain to receive dialog events for proactive rejection
353 client
354 .send_to_target(session_id, "Page.enable", json!({}))
355 .await?;
356
357 client.dialog_action = args
358 .get("dialog_action")
359 .and_then(|v| v.as_str())
360 .map(|s| s.to_string());
361
362 match cmd {
363 "navigate" => {
364 // Apply emulation before navigation if requested
365 let viewport = args.get("viewport").and_then(|v| v.as_str());
366 let geolocation = args.get("geolocation").and_then(|v| v.as_str());
367 let clear_all = args
368 .get("clear_all")
369 .and_then(|v| v.as_bool())
370 .unwrap_or(false);
371
372 let params = commands::emulation::EmulateParams {
373 viewport: viewport.map(|s| s.to_string()),
374 device_scale_factor: args.get("device_scale_factor").and_then(|v| v.as_f64()),
375 mobile: args
376 .get("mobile")
377 .and_then(|v| v.as_bool())
378 .unwrap_or(false),
379 geolocation: geolocation.map(|s| s.to_string()),
380 accuracy: args.get("accuracy").and_then(|v| v.as_f64()),
381 clear_viewport: false,
382 clear_geolocation: false,
383 clear_all,
384 block_url: req.block_url.clone(),
385 unblock_url: req.unblock_url.clone(),
386 clear_blocks: false,
387 };
388 params.validate()?;
389
390 if params.has_emulation() {
391 commands::emulation::emulate(client, session_id, params).await?;
392 }
393
394 commands::navigate::navigate(
395 client,
396 session_id,
397 args.get("url").and_then(|v| v.as_str()),
398 args.get("back").and_then(|v| v.as_bool()).unwrap_or(false),
399 args.get("forward")
400 .and_then(|v| v.as_bool())
401 .unwrap_or(false),

Callers 1

execute_commandFunction · 0.85

Calls 15

emulateFunction · 0.85
navigateFunction · 0.85
take_screenshotFunction · 0.85
evaluateFunction · 0.85
clickFunction · 0.85
click_atFunction · 0.85
fillFunction · 0.85
type_textFunction · 0.85
press_keyFunction · 0.85
hoverFunction · 0.85
take_snapshotFunction · 0.85
read_pageFunction · 0.85

Tested by

no test coverage detected