Expand description
Shared routing preamble + named-tab dispatch for the page-evaluating CLI
commands (eval, fetch, storage).
These commands all accept the unified <browser>[/<tab>] positional plus a
mutually-exclusive --target <regex> and fan out into the same three
routing paths, picked by (tab_name, target):
- named-tab (
<browser>/<tab>, no--target) — resolve<tab>in thetabstable via the engine-agnosticTabBackendand run the op underwith_named_tab_recovery, so a tab that dies between resolve and op is recovered once. Requires a registered browser. Seerun_named_tab. - bare browser (no
--target) — the per-command default. This arm differs per command (scratch tab foreval/storage, origin-bound attach forfetch, plus an external-endpoint fallback), so it stays in each command rather than here. - target-regex (
--target <regex>) — legacyPageSession::attachagainst a user tab matching the URL regex. Also per-command (it differs in await-promise flags / timeouts), so it stays in each command.
The genuinely shared pieces — the preamble (parse, mutual-exclusion check, browser resolution, registry handle, BiDi lock) and the named-tab arm — live here so the three commands cannot drift on them. The per-command variation (the JS expression, the await-promise flag, the timeout, and the bare-browser arm) is supplied by the caller.
Structs§
- Route
- Outcome of the shared routing preamble. Holds everything the per-command
dispatch needs: the resolved browser, the open
Registryhandle, the held BiDi lock guard (RAII — released when this struct drops), and the parsed(tab_name, browser_only)from the positional.
Functions§
- preamble
- Run the shared preamble: parse the
<browser>[/<tab>]positional, enforce the<tab>/--targetmutual exclusion (in ONE place with ONE message), resolve the browser, recordtrace.browser/trace.engine, open the registry, and acquire the BiDi lock if applicable. - run_
named_ tab - The named-tab routing arm, identical across
eval/fetch/storage: resolve the registered browser name, open itsTabBackend, and run the caller’sopagainst the named tab underwith_named_tab_recovery(which recovers once if the tab dies between resolve and op).