Helper to join console API arguments into a single string. Chrome's `Runtime.consoleAPICalled` returns arguments as an array of RemoteObjects.
(args: &[Value])
| 863 | /// Helper to join console API arguments into a single string. |
| 864 | /// Chrome's `Runtime.consoleAPICalled` returns arguments as an array of RemoteObjects. |
| 865 | pub fn join_console_args(args: &[Value]) -> String { |
| 866 | args.iter() |
| 867 | .map(|arg| match arg.get("value") { |
| 868 | // String primitives: emit the raw text (no quotes). |
| 869 | Some(v) if v.is_string() => v.as_str().unwrap_or("").to_string(), |
| 870 | // Other primitives (number, bool, null): stringify directly. |
| 871 | Some(v) => v.to_string(), |
| 872 | // Objects have no `value` — fall back to their description. |
| 873 | None => arg["description"] |
| 874 | .as_str() |
| 875 | .unwrap_or("<object>") |
| 876 | .to_string(), |
| 877 | }) |
| 878 | .collect::<Vec<String>>() |
| 879 | .join(" ") |
| 880 | } |
| 881 | |
| 882 | #[cfg(test)] |
| 883 | mod tests { |
no outgoing calls
no test coverage detected