Skip to main content

run_named_tab

Function run_named_tab 

Source
pub async fn run_named_tab<T, F, Fut>(
    route: &Route,
    name: &str,
    no_external_msg: &str,
    op: F,
) -> Result<T>
where F: FnMut(TabBackend, String) -> Fut, Fut: Future<Output = Result<T>>,
Expand description

The named-tab routing arm, identical across eval/fetch/storage: resolve the registered browser name, open its TabBackend, and run the caller’s op against the named tab under with_named_tab_recovery (which recovers once if the tab dies between resolve and op).

name is the tab name; op evaluates the command-specific JS — the JS expression, await-promise flag, and timeout all live inside the closure, so they are the per-command variation point. no_external_msg is the bail! text used when the source is not a registered browser; it is passed in because the existing commands phrase it slightly differently and this is a behavior-preserving refactor.

The caller is responsible for trace.route("named-tab") / trace.tab_name(...) so the trace contract stays visible at the call site.