(query: DevToolsQuery, params: &Value)
| 1502 | } |
| 1503 | |
| 1504 | async fn runtime_evaluate(query: DevToolsQuery, params: &Value) -> Value { |
| 1505 | let expression = params |
| 1506 | .get("expression") |
| 1507 | .and_then(Value::as_str) |
| 1508 | .unwrap_or("") |
| 1509 | .trim(); |
| 1510 | if expression.is_empty() { |
| 1511 | return json!({ "result": remote_object(&Value::Null) }); |
| 1512 | } |
| 1513 | |
| 1514 | let hierarchy = match query( |
| 1515 | "View.getHierarchy".to_owned(), |
| 1516 | json!({ |
| 1517 | "includeHidden": true, |
| 1518 | "maxDepth": 0, |
| 1519 | }), |
| 1520 | ) |
| 1521 | .await |
| 1522 | { |
| 1523 | Ok(value) => value, |
| 1524 | Err(error) => return exception_result(error), |
| 1525 | }; |
| 1526 | let Some(root_id) = first_inspector_id(&hierarchy) else { |
| 1527 | return exception_result("No inspectable root view is available.".to_owned()); |
| 1528 | }; |
| 1529 | match query( |
| 1530 | "View.evaluateScript".to_owned(), |
| 1531 | json!({ |
| 1532 | "id": root_id, |
| 1533 | "script": expression, |
| 1534 | }), |
| 1535 | ) |
| 1536 | .await |
| 1537 | { |
| 1538 | Ok(value) => json!({ "result": remote_object(value.get("result").unwrap_or(&value)) }), |
| 1539 | Err(error) => exception_result(error), |
| 1540 | } |
| 1541 | } |
| 1542 | |
| 1543 | fn runtime_get_properties(state: &mut CdpState, params: &Value) -> Value { |
| 1544 | let object_id = params |
no test coverage detected