mirror of
https://github.com/vercel-labs/agent-browser.git
synced 2026-12-03 10:07:50 +08:00
main
629
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
31c66694b2 |
fix(state): clear and restore only the exact session name (#2177)
* fix(state): clear and restore only the exact session name state clear <name> sent the name as sessionName, but the daemon read only path, so it deleted every saved state. Restore matched saved files by the prefix "<name>-", so the name auth could load the newer state saved under auth-admin. New saves are named <name>.<session-id>.json. A session name cannot contain ".", so the name part is exact. One matcher serves clear and restore, and older <name>-<id>.json files still match when the id has no "-". state clear now needs a name or --all instead of deleting everything. * fix(state): match legacy state files by exact suffix * test(state): cover state clear across CLI and MCP * fix(state): require a session id in new-format state file names A legacy auth-default.json, saved for name auth with session default, also matched the new "<name>." rule for the name auth-default, so that name could restore or clear another name's state. New-format names now need a non-empty session id before the .json suffix. * fix(state): keep legacy state files that have hyphenated session ids Legacy saves are named <key>-<session>.json, and both parts may contain "-". The exact matcher rejected auth-worker-one.json (key auth, session worker-one), so after upgrading, restoring auth found nothing, state clear auth left the file behind, and the key auth-worker claimed it instead. Legacy files are matched by the <key>- prefix again, as before. Restore prefers a file that can only belong to the key (the new <key>.<session>.json, or a legacy name with a single "-") over a legacy name another key could also own, and state clear removes both kinds. * fix(state): skip ambiguous legacy state on auto-restore * fix(state): resolve legacy state names with the running session Legacy state files are named <key>-<session>.json and both halves can contain a hyphen, so a name like my-app-default.json fitted two restore keys. Restore skipped it and state clear refused to touch it, which broke hyphenated keys after an upgrade. The running session now decides those names: a legacy file whose session part is the current session belongs to the key in front of it, so auth saved in worker-one is restored and cleared from worker-one and is never claimed by auth-worker. Files saved by another session stay ambiguous, and are still skipped by restore and reported by state clear. The CLI and the daemon pass the session id down to the state matcher, the docs describe the new rule, and mcp-tools.json is regenerated. * fix(state): keep ambiguous legacy files instead of failing state clear state clear <name> refused to run whenever a legacy file fitted more than one restore key, so `state clear my-app` failed on my-app-default.json and a second session's files blocked it again. Named clear now deletes only the files that the name alone owns, keeps the ambiguous legacy files and their backups, and lists them in `skipped`, in JSON and in the text output. Nothing is silently deleted and nothing is silently kept. This also drops the session-suffix rule from the last commit. A legacy name like auth-worker-one.json fits both auth in session worker-one and auth-worker in session one, so reading it from the running session handed the file to the wrong key and broke e2e_ambiguous_legacy_state_is_skipped_and_migrated_to_v2_on_close. Restore keeps skipping ambiguous files and reporting skipped_ambiguous. |
||
|
|
ae5570a116 |
fix(firefox): reject insecure owned launches on Windows (#2829)
* fix(firefox): reject insecure owned launches on Windows Co-authored-by: Lahfir <70215676+lahfir@users.noreply.github.com> * test(mcp): strip global flags before parsing Firefox tool args cli_tool_args prepends --json, so passing raw args to parse_command failed with UnknownCommand { command: "--json" }. Pass clean_args(&args) to match CLI dispatch, remove the two inline comments added in the previous commit, and align the --engine help text with the MCP and Firefox docs. --------- Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com> |
||
|
|
15298d6aa8 |
fix(tabs): follow new tabs only during activating commands (#2603)
* fix(tabs): follow only tabs the running command opened The daemon switched the session to every tab it discovered, so a popup a page opened on a timer took over, and refs from the old tab then resolved by role and name on the new one. A click could report success on the wrong page. A discovered tab is now followed only when the active tab opened it while a command that sends input or script to the page was running. Any other new tab stays in the background and the response warning names it. When the active tab changes without a tab command, refs and frame scope are cleared and the warning names the tab the session is on. Co-Authored-By: HeapSmasher <98077186+las7@users.noreply.github.com> * docs(tabs): document which new tabs are followed Explain when a new tab becomes active, the background-tab and active-tab warnings, and that refs belong to the tab they were snapshotted on. Add an e2e test for a timer popup and a click-opened tab. * fix(tabs): report a discovered tab as background when the pinned tab is gone A pinned session whose tab was closed keeps no active tab, so a tab discovered in that state is a background tab. Two e2e tests relied on any externally created tab becoming active; they now open the tab from the active page. * fix(tabs): count find, paste and multiselect as commands that open tabs A find with a click, fill, check or hover action, a clipboard paste and multiselect send input to the page, so a tab they open is followed. A find that only reads text is not. Add the new tab rule to the tab help. * fix(tabs): keep page-controlled text out of tab warnings The background-tab and active-tab warnings included the tab's URL, which the page controls, and warnings print outside the content boundary markers. The warnings now carry only the daemon-assigned tab id; the URL stays in tab list. * fix(tabs): never follow a discovered tab in a pinned session A session launched with --pin-tab still followed a tab its click opened, because the pin was only checked on the browser manager, which a fresh launch does not set. The follow rule now checks the session's pin where it is decided. The docs, help and skill text now say a tab is followed when the active tab opens it while an input command runs, which includes a popup the page opens during that command, and that a tab opened after the command returned stays in the background. * fix(tabs): follow new tabs only during activating commands Restrict tab-follow eligibility to activating commands (click, tap, key presses, mouse press or release, dispatch, eval, and find click) so non-activating commands like slow type --delay, fill, hover, scroll, and paste do not let timer popups hijack the active tab or clear refs. Add unit coverage for should_follow_opened_tabs, add an e2e test for a timer popup firing during slow typing, and align CLI help, docs, and skill references. * fix(tabs): align Firefox popup following and drop stale tab notices Gate Firefox BiDi popup adoption on follow_opened_tabs so popups opened outside activating commands stay in the background, keep refs valid, and report the same background and active-tab warnings as Chrome. Store pending tab notices as typed events and filter them against live tab state at flush time, skip CDP targets destroyed in the same drain batch, prune closed tabs during Firefox tab listing, and clear pending notices on browser close so closed popups never produce stale switch warnings. * chore(bidi): satisfy clippy filter_map_bool_then lint in tab_list --------- Co-authored-by: HeapSmasher <98077186+las7@users.noreply.github.com> |
||
|
|
1db5fe0ee5 |
test(settings): cover the CDP endpoint rollback after a failed connect (#2757)
A `connect` names its endpoint in the launch body rather than the settings patch. Assert that when flow capture fails after the attach, the endpoint is rolled back together with the restore key, so the next command does not reattach to it under the previous identity. |
||
|
|
3daa20ab12 |
fix(tab): send Target.closeTarget before mutating tab state (#2816)
* fix(tab): close the target before forgetting the tab Target.closeTarget ran after the tab was already dropped from the page list, and its result was ignored, so a rejected close still reported success and every background close re-probed the active tab. Send the close first, fail without mutating local state when Chrome rejects it, and rebuild refs, frame scope, iframe sessions and WebMCP state only when the active tab actually changed. Fixes #2407 Recreates #2408 Co-authored-by: yunhao-tech <77528839+yunhao-tech@users.noreply.github.com> * fix(tab): close the target before forgetting the tab Target.closeTarget ran after the tab was already dropped from the page list and its result was ignored, so a refused close still reported success, a background close re-probed the active tab, and a browser-level timeout was treated as a renderer strike on it. Send the close first and fail on a CDP error or {"success": false} without touching local state. Rebuild refs, frame scope, iframe sessions and WebMCP state only when the active tab changed, retire the closed session once the close commits, and keep tab close out of the wedge and frame-tree paths. Fixes #2407 Recreates #2408 Co-authored-by: yunhao-tech <77528839+yunhao-tech@users.noreply.github.com> * fix(tab): only rebuild the frame scope for the active tab Target.detachedFromTarget queued every detached session, including a closed background tab and its OOPIFs, as a reason to rebuild the active page's iframe sessions, which probed the unchanged active tab with Page.getFrameTree. Refresh only when the active tab changed or lost one of its own iframes, and keep dropping the detached session's bookkeeping. Fixes #2407 Recreates #2408 Co-authored-by: yunhao-tech <77528839+yunhao-tech@users.noreply.github.com> --------- Co-authored-by: yunhao-tech <77528839+yunhao-tech@users.noreply.github.com> |
||
|
|
c38b566281 |
feat(webdriver): snapshot refs on the WebDriver backends (#2754)
* feat(webdriver): snapshot refs on the WebDriver backends snapshot, snapshot -i, click, hover and fill work on the WebDriver backends (Ladybird, Safari, iOS) with the same output and @eN surface as CDP, and no new flags. Each frame is walked in the page, including open shadow roots, with iframes nested under their Iframe node. The walker returns the browser's own element references, which become @eN and stay stable across snapshots; each one is stored with its iframe path so actions can switch to its frame. Click and hover scroll into view and use a pointer action, which also reaches open shadow DOM where WebDriver Element Click fails. The client used to discard WebDriver error payloads, so a stale click looked like it succeeded. Errors are now surfaced, and an element or frame that left the page reports a stale ref. eval now runs the script as an expression instead of a WebDriver function body, so bare expressions return values rather than null. Verified end to end against Ladybird 2026.47.7 on Linux: snapshot -i matches Chrome role for role on a form with an iframe and open shadow root (23 refs), a 900-control table (1802), and a page of tricky cases (24); refs, actions in shadow DOM and iframes, stale refs, and the snapshot options all work. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * - Only treat WebDriver response value.error as an error on non-2xx HTTP status so eval returning objects with an error field succeeds. - Evaluate bare expressions directly with return (...) instead of (0, eval) so strict CSP pages work, falling back to a WebDriver function body only on SyntaxError. - Run actionability and hit-test blocker checks before WebDriver click pointer actions so covered elements report an intercepted-click error. - Walk LabelText elements normally in WALKER_JS instead of redirecting to el.control so nested controls and hidden-input label promotion both work. - Avoid Array.prototype.push/pop in WALKER_JS, validate returned snapshot graph bounds, acyclicity, and max depth before AX conversion, and replace recursive set_depth/render_tree with bounded iterative traversal. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * fix(webdriver): follow the ref map document identity after the main merge `main` changed `RefMap::observe_document` to take a document identity instead of a page session plus document id, and the merge was textually clean but left this crate uncompilable. Pass the snapshot's document root id, which is what the Firefox backend passes with its document shared id. * fix(webdriver): decide the eval retry from the script, not the driver's error text `eval` sends a bare expression as `return (expr);` so pages without `'unsafe-eval'` still work, then retries the script as a WebDriver function body when that wrapper does not parse. The retry was gated on the error text containing `SyntaxError`, which Chromium and Firefox add but WebKit and Ladybird do not. Ladybird reports `Unexpected keyword 'const'`, so `eval "const z = 7; return z"` failed instead of returning 7. Ask the page whether the script compiles as an expression, without running it, so every driver reaches the same decision. A successful evaluation still sends one request; the compile probe only runs after the wrapper fails. * fix(webdriver): give anchors without href their snapshot refs back Blink gives an `<a>` the link role when it has an href or a mouse button listener, and the walker only looked at href. An `<a onclick>` therefore fell through to generic, and because native tags skipped cursor detection it carried no hint either, so it was dropped from the snapshot and could not be targeted with a ref. Match Blink's rule, and skip cursor detection only for native tags that already resolved to a specific role, so `<a tabindex>` and `<a style="cursor:pointer">` keep the generic node, hint, and ref that Chrome shows for them. * fix(webdriver): index snapshot elements by id instead of scanning them Resolving a ref or a snapshot hint walked the element map for every target, so a page with 100,000 unnamed controls made one snapshot run about five billion lookups while holding the session mutex. Keep the element for each durable id in a vector, filled where the ids are assigned, and read it directly. Ids are also reset when the page moves to a new document or the retained set passes its cap, so a page that keeps churning elements cannot grow the map without bound. * fix(webdriver): scroll targets instantly so smooth-scroll pages can be clicked Click scrolled with `scrollIntoView` and then measured the rect in the same script. With `scroll-behavior: smooth` on the page that scroll animates, so the rect was still off-screen and the preflight rejected every click as outside the viewport. Pass `behavior: 'instant'`, as the CDP path does, and scroll the same way before hover and fill. * fix(webdriver): match Chrome for hidden text, svg titles, and unscoped th cells Names skipped `display: none` and `aria-hidden` but not `visibility: hidden`, so text inside a hidden span leaked in: `<button>Save<span style="visibility:hidden">X</span></button>` was named "SaveX" instead of "Save". An svg child contributed no text, so an icon-only button whose svg has a title was unnamed instead of taking the title, as Chrome does. An unscoped `<th>` was always a columnheader. Chrome makes it a rowheader when its row also holds data cells, and honours the rowgroup and colgroup scopes. * docs(skill-data): describe the provider option generically Drop the Ladybird-over-WebDriver example line, and say the audit needs a CDP browser instead of listing the providers it does not support. * fix(webdriver): never reuse a pruned element id Dropping retained handles restarted ids at 1 while the durable-ref table for an unchanged document survived, so a saved ref could be rebound to a different element, including one in another frame. Keep the ids counting up and only drop the handles, so a pruned id reads as stale instead of resolving to whatever took its number. * fix(webdriver): close the gaps the branch review found - Prune retained element ids with their durable refs, and prune only ids the current snapshot did not see, so page churn cannot grow either map and elements still on the page keep their ids. - Probe whether an eval script compiles as an expression before choosing a form, accepting only an explicit `true`, because the WebDriver algorithm lets a driver report an unparseable body as a plain null. - Return to the top-level frame before snapshotting and before entering a frame, so a frame switch that failed earlier cannot make later work target the wrong document. - Click `<option>` elements with Element Click, which selects them, instead of pointer actions at a box a collapsed select does not lay out. - Reject a snapshot when the page navigated during the walk, and report the URL read at the end so the tree and the URL describe the same document. - Count the visible descendants of a `visibility: hidden` wrapper in names, and find scoped selector roots by walking ancestors instead of comparing pairs. * fix(webdriver): walk each frame where the driver switched to it The reset that keeps a snapshot from starting inside a stale frame ran inside the per-frame walk, so entering a child frame was undone before the walker ran and the main document was read again instead of the frame's controls. Reset once at the start of the snapshot, and cover the frame order with a mock test. --------- Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> |
||
|
|
f25c7e6a70 |
ci: speed up Rust builds, caching, and native E2E tests (#2695)
* ci: speed up Rust builds, caching, and native E2E tests CI currently spends ~28 minutes per push to main because test binaries compile with release optimization and thin LTO, build.rs generates 16,639 lines of unused CDP types, 16 integration test files link as separate binaries, macOS targets share one rust-cache key, and native E2E tests run serially behind unit tests with hardcoded 30s wedge timeouts. Changes: - Remove unused cdp_generated.rs codegen from cli/build.rs, cli/src/native/cdp/types.rs, and unused build-dependencies from cli/Cargo.toml. - Add [profile.ci-test] (dev-derived with line-tables-only debuginfo and opt-level 3 for image/png) and use it with RUST_MIN_STACK=8388608 across Rust CI test jobs. - Merge the 16 cli/tests/*.rs integration binaries into cli/tests/cli_integration/main.rs so they link once. - Add test-only AGENT_BROWSER_TEST_CDP_TIMEOUT_MS and AGENT_BROWSER_TEST_PROBE_TIMEOUT_MS overrides with a unit test pinning the 30s and 3000ms production defaults. - Create ~/.agent-browser/.encryption-key atomically in auth.rs so parallel E2E processes cannot clobber the key on first run. - Split Rust Lint into its own parallel job, remove serial needs chains on native-e2e, windows-integration, and global-install, fix Swatinem/rust-cache target/shared keys, and run native E2E via cargo-nextest with 4 parallel processes. * ci: run e2e_recording tests exclusively in cargo-nextest Screencast recording tests spawn ffmpeg and assert captured motion frames during drags. Running them concurrently with other Chrome E2E tests on a 4-vCPU runner can starve frame capture. Reserve all test threads for e2e_recording tests while keeping the rest of the E2E suite 4-way parallel. * ci: run Firefox e2e tests serially in cargo-nextest Firefox e2e tests are marked to run serially and fail timing and cleanup assertions under 4-way concurrency on a 4-vCPU runner. Pass --test-threads 1 to the Firefox e2e step and reserve all test threads for e2e_firefox in nextest.toml. |
||
|
|
121b93bfa3 |
fix(cdp): keep peer-pinned tabs visible without taking control (#2815)
* fix(cdp): keep peer-pinned tabs visible without taking control Register targets pinned by another live session as observed pages so they show in `tab list` and can be closed by target id, while this session never attaches to them, activates them, or saves their origins. * fix(cdp): never promote a peer-pinned tab into the active slot Route active-page consumers through a single controlled-page check, prefer a controlled neighbor after a close or destroy, and reuse the retained control session when the pin holder releases a tab. * fix(cdp): keep observed rows inert across late attachments and fallbacks Retain a late CDP attachment on an already-observed row, select the first controlled page after observed-only rows, and measure the nearest controlled fallback on both sides of the closed slot. * fix(tab): refuse closing a tab another session pinned Enforce the live-pin check in tab close like switch and keep, and close the released tab through the browser endpoint in the recovery e2e. |
||
|
|
9a5f8e8a88 |
fix(firefox): isolate paste in BiDi sandbox, lock down owned DevTools, and fix Windows CDP probe test (#2751)
* fix(firefox): isolate paste in BiDi sandbox, lock down owned DevTools, and fix Windows CDP probe test
Resolve focused cross-origin frames and run literal text insertion in Firefox's BiDi sandbox without userActivation, re-enable DevTools prompts and disable remote debugging after owned launches verify their nonce, and drain HTTP requests before closing sockets in cdp_probe_server on Windows.
* test(firefox): use fixture.other for cross-origin paste iframe
fixture.url already uses localhost, so replacen("http://127.0.0.1:", "http://localhost:", 1) left the iframe same-origin. Use fixture.other so the iframe loads from 127.0.0.1 on a separate port.
Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com>
* test(firefox): wait for cross-origin iframe focus and paste completion
dispatch_input sends input_mouse and input_insert_text via send_no_wait, so fixed 150ms/200ms sleeps raced cross-process focus and script execution in the out-of-process iframe. Poll for #child-in focus before pasting and for #child-in value before asserting.
Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com>
* test(firefox): click cross-origin input inside its frame context
Firefox WebDriver BiDi input.performActions sent to the top-level tab focuses the parent iframe element without crossing into an out-of-process cross-origin child frame, leaving the child activeElement on body. Click #child-in inside #xframe before switching back to the main frame and dispatching dashboard input_insert_text.
---------
Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com>
|
||
|
|
7f422e7786 |
feat(refs): preserve snapshot refs across BFCache restores (#2772)
* feat(refs): preserve snapshot refs across BFCache restores and use event-driven CDP history navigation - Replace the fixed 500 ms sleep and page-script history calls in back/forward with Page.getNavigationHistory, Page.navigateToHistoryEntry, and CDP navigation events. - Key RefMap document identity by (frameId, loaderId) instead of ephemeral CDP session IDs so OOPIF refs rebind after BFCache restore, and keep a 6-entry per-tab LRU for archived documents. - Reactivate cached refs on Page.frameNavigated BackForwardCacheRestore with lazy DOM.resolveNode + isConnected checks (disabling role/name fallback so replaced nodes fail as stale) while keeping "no longer loaded" errors on non-BFCache commits. - Report refsValid in back/forward JSON responses and "(refs valid)" in CLI text output, and update MCP catalog, help text, skill data, and docs. * fix(diff): bind diff url navigations and captures to the original tab Verify the active target and session still match the starting tab after each navigation drain in handle_diff_url so a self-closing URL1 tab cannot redirect URL2 onto another tab. * fix(history): resolve main frameId via Page.getFrameTree instead of targetId Avoid falling back to active_target_id when no main frame has been recorded yet in handle_history. Query Page.getFrameTree and cache the real frameTree.frame.id (or leave it unset if unavailable) so Page.navigatedWithinDocument matches without stalling until timeout. |
||
|
|
f70fe8d918 |
fix(cdp): fail commands to crashed pages and to sessions under a detached one (#2775)
* fix(cdp): fail commands to crashed pages and to sessions under a detached one Refs #1660 Co-authored-by: coldsmirk <18739624+coldsmirk@users.noreply.github.com> * fix(cdp): fail destroyed-target subtrees and clear crash on main-frame navigation --------- Co-authored-by: coldsmirk <18739624+coldsmirk@users.noreply.github.com> |
||
|
|
3f43a2affd |
fix(recording): keep clicks on target while recording at an emulated device scale (#2761)
* fix(recording): keep clicks on target while recording at an emulated device scale Co-authored-by: Flipcyde <dillon.rodriguez@gmail.com> * fix(recording): scope screenshot gate to active screenshot-mode recordings * fix(recording): retain screenshot gate until in-flight capture settles --------- Co-authored-by: Flipcyde <dillon.rodriguez@gmail.com> |
||
|
|
52c1c08b77 |
fix(providers): honor system and custom CA trust for provider API and CDP connections (#2774)
* fix(providers): honor system and custom CA trust for provider API and CDP connections Resolve and propagate CLI trust options (--use-system-ca, --ca-cert, SSL_CERT_FILE) to the daemon and apply them to all provider API requests, provider session cleanup, CDP HTTP discovery, and wss:// CDP WebSocket connections. Allow --ca-cert with -p/--provider on every platform for CLI/daemon connections without affecting the remote browser's own trust store. Fixes #2752 * fix(providers): clear local provider state on failed cleanup and keep best-effort cleanup resilient Clear active_provider_session and active_provider_connection before running cleanup for non-browser-use providers so a transport or TLS error reports the failure without leaving the daemon half-closed. Keep browserbase, browserless, and agentcore cleanup best-effort when building the HTTP client fails, and reuse flags::tls_env_flags for daemon startup env parsing. |
||
|
|
147e15ae97 |
fix(recording): keep the take through encoder stalls and on ffmpeg < 5.1 (#2762)
* fix(recording): keep the take through encoder stalls and on ffmpeg < 5.1 Hold the latest frame across encoder stalls instead of aborting the take, report lateFrames in record stop, fall back to -vsync vfr on ffmpeg < 5.1, and surface ffmpeg stderr when the encoder exits early. Fixes #1973 Fixes #2011 Co-authored-by: John <2801548+JohnnyDangerously@users.noreply.github.com> Co-authored-by: Apurv Sheladiya <116494352+Apurvsheldiya25@users.noreply.github.com> * fix(recording): include ffmpeg exit status on empty stderr and reuse doctor version parser * test(docs): register the record stop lateFrames edit on /recording * fix(recording): preserve seed frame and timeline origin during ffmpeg startup --------- Co-authored-by: John <2801548+JohnnyDangerously@users.noreply.github.com> Co-authored-by: Apurv Sheladiya <116494352+Apurvsheldiya25@users.noreply.github.com> |
||
|
|
db055d7a3c |
fix(chrome): seed Local State so Windows skips the blank-password logon probe (#2776)
* fix(chrome): seed Local State so Windows skips blank-password logon probe Seed `password_manager.os_password_blank` and string-typed `os_password_last_changed` into empty Chrome profiles on Windows using `File::create_new` so existing `Local State` files are never overwritten and seeding failures abort launch before spawning Chrome. Fixes #2232 Co-authored-by: Sidreyas <sudharsan2594git1@gmail.com> Co-authored-by: J-H99 <60911709+J-H99@users.noreply.github.com> * fix(chrome): seed missing Local State in non-empty profiles and ignore AlreadyExists Seed `Local State` whenever it is absent rather than only in empty directories, and treat `ErrorKind::AlreadyExists` from `File::create_new` as success so concurrent launches on the same profile do not fail. --------- Co-authored-by: Sidreyas <sudharsan2594git1@gmail.com> Co-authored-by: J-H99 <60911709+J-H99@users.noreply.github.com> |
||
|
|
669ae63831 |
fix(chrome): support linux-arm64 Chrome for Testing and add AppArmor sandbox hint (#2773)
- Allow `agent-browser install` on Linux aarch64, map it to `linux-arm64`, and resolve `chrome-linux-arm64/chrome` in both the install cache and Playwright fallback. - Add a Linux AppArmor user namespace restriction hint before the `--no-sandbox` fallback when a sandboxed downloaded Chrome fails to launch (recreates #2756). - Update Chrome docs and WebGPU reference. Fixes #2753 Fixes #2755 Co-authored-by: tiennm99 <tiennm99@outlook.com> |
||
|
|
a67ba089fe |
fix(launch): report relaunchedBrowser when the settings pass closed the browser (#2759)
A `launch` whose settings change closed the running browser during the pre-launch settings pass reported `relaunchedBrowser: false`, because the flag did not reach `handle_launch_inner_prepared`. Carry it through `LaunchRequest::Planned`. |
||
|
|
a94b9f4a1e |
fix(iframe): fall back to top-level frame selector and report covering element outside frame (#2758)
When an iframe is already selected and `frame <selector>` finds no match inside the active frame, fall back to querying the top-level document so switching directly to a sibling iframe works without an explicit `mainframe` reset. Also include the covering node description (`is covered by <...>`) when `place_in_dispatch_viewport` refuses a click that lands outside the target's frame. |
||
|
|
6e857a8a4f |
fix(tracing): stop only the recorder a command started (#2763)
Track which recorder (Trace or Profiler) owns the active CDP tracing session so trace stop and profiler stop only stop the recorder their matching start command began. Decode base64-encoded IO.read chunks to bytes before UTF-8 conversion and always send IO.close before propagating stream read or decode errors. Fixes #1313 Co-authored-by: ZhYGuoL <zguoliau@andrew.cmu.edu> Co-authored-by: Afloat <ShuffleMonkey@163.com> |
||
|
|
f0a98351ec | Prepare v0.45.0 (#2748) | ||
|
|
e20a97bde0 |
fix(iframe): resolve frames by selector and ref, and scope selectors, find and wait to the selected frame (#2737)
* fix(frames): resolve nested and cross-origin iframes, same-site selectors, and frame-scoped find Resolve frame CSS selectors via DOM.describeNode in the active frame context, resolve iframe refs in their owning session, expand nested iframes up to a bounded depth in snapshots, evaluate same-process frame selectors through isolated worlds with browser-geometry click placement, and route semantic find locators through the active frame. Co-authored-by: O-B-ONE <319176320+OBOneProtocol@users.noreply.github.com> Co-authored-by: Saim Shafique <128062316+sx4im@users.noreply.github.com> Co-authored-by: luren <84951845+lurenjia534@users.noreply.github.com> * fix(wait): resolve frame selectors through isolated world Use find_frame_host_session and create_frame_isolated_world in wait_for_selector_in_frame so wait <selector> works inside same-site cross-origin and nested frames without contentDocument, and remove the unused frame_owner_object_id helper. * fix(frames): scope frame resolution to the active tab and preserve parent session in nested snapshots Validate every frame lookup and resolution path against the active tab's frame tree so retained background-tab iframe sessions are never selected or queried. Pass the parent frame's effective session when recursing into nested iframes during snapshot capture so in-process children inside an OOPIF retain their content and refs. * fix(snapshot): hoist top-level setup out of recursive iframe snapshots and update docs Run DOM.enable, Accessibility.enable, and selector backend-id scoping once at depth 0 instead of repeating on every nested iframe recursion, skip top-document cursor scans in child frames, and update iframe nesting docs to reflect the 4-level limit. * fix(frames): bind semantic locator values as literals, unify frame selector lookup, and refine wait polling Bind placeholder/alttext/title/testid values as JS literals instead of interpolating into single-quoted strings, unify marker locate/cleanup across semantic locators and presentational getbyrole (clearing stale markers and skipping cleanup on dialogOpened), check exceptionDetails in frame selector lookups via one helper in element.rs, resolve handle_getbyrole through find_frame_host_session, share selector_state_check_js between wait_for_selector and wait_for_selector_in_frame with selective transient-navigation retries, defer Page.getFrameTree in handle_frame until name/url fallback with sorted active sessions, and strengthen e2e assertions. * fix(forms): place form-control clicks in the host viewport via click_point Use click_point::place_in_dispatch_viewport (DOM.getContentQuads + hit-test) in CdpControl::click instead of frame-local coordinates from CLICK_POINT_JS so check/uncheck/radio by selector inside a same-site cross-origin iframe land on the iframe control rather than the parent page. * docs(snapshots): register 4-level iframe nesting edit in docs-edits fixture * fix(forms): refuse interactive overlays covering form controls while keeping viewport placement Restore strict receiver validation for form controls via place_form_control_in_dispatch_viewport: allow the control itself, non-interactive descendants, or an associated label without intervening interactive elements (links, buttons, other inputs), refusing anything else with intercepted_error. Leave click/dblclick/hover/drag placement policy unchanged. * test(e2e): cover nested interactive child in custom checkbox and frame-scoped eval --------- Co-authored-by: O-B-ONE <319176320+OBOneProtocol@users.noreply.github.com> Co-authored-by: Saim Shafique <128062316+sx4im@users.noreply.github.com> Co-authored-by: luren <84951845+lurenjia534@users.noreply.github.com> |
||
|
|
7b20c4939a |
fix(dashboard): forward editing shortcuts and bridge copy, cut and paste in the live view (#2745)
* fix(stream): forward editing key commands and bridge dashboard clipboard Forward an allowlisted set of CDP editing and caret-navigation commands on stream keyboard events, derive virtual key codes from KeyboardEvent.code with server-side fallback to interaction::named_key_info, and send shortcut combos as rawKeyDown without text. Bridge dashboard copy, cut, and paste using Input.insertText and page selection reads without granting global browser clipboard permissions. Fixes #1453 Fixes #1615 Co-authored-by: hyunjinee <leehj0110@kakao.com> Co-authored-by: Kevin Gatera <kevingatera@gmail.com> * fix(stream): preserve Option/AltGr text input and run cut atomically in input order Keep keyDown text for Option and AltGr character entry (such as Option+A -> å and AltGr+Q -> @) instead of suppressing text whenever Alt is held. Execute clipboard cut inline in the input reader using a single synchronous read-and-cut evaluation so later focus or selection changes cannot overtake the cut. Co-authored-by: Kevin Gatera <kevingatera@gmail.com> * fix(stream): do not mutate readonly, disabled, or non-editable elements on cut Guard the cut script so readonly or disabled inputs/textareas and non-contentEditable elements never run execCommand('cut') or the setRangeText fallback; they only return the selected text to the clipboard. Co-authored-by: Kevin Gatera <kevingatera@gmail.com> * fix(stream): strip Ctrl+Alt on AltGr text, guard empty clipboard writes, queue paste input, and use native cut deletion Strip Ctrl|Alt modifier bits on text-carrying AltGr keyDown events in both the dashboard and stream websocket so Chromium inserts AltGr characters. Ignore empty clipboard replies so Cmd/Ctrl+C with no selection preserves the local clipboard. Queue subsequent dashboard input behind async clipboard reads during paste so later keystrokes or clicks cannot overtake it. Replace JS execCommand/setRangeText cut deletion with an inline native CDP Backspace delete on editable selections so contenteditable cuts work without user activation and textarea/input cuts preserve browser undo history. Co-authored-by: Kevin Gatera <kevingatera@gmail.com> * fix(stream): scope dashboard paste queue to active target and handle rawKeyDown/clipboard in Firefox live view Reset the dashboard input queue and discard in-flight clipboard paste reads whenever the active session, stream port, active tab, or WebSocket instance changes so clipboard text is never sent to a different session or tab. Support rawKeyDown, input_insert_text, and cut actions in the Firefox BiDi stream input adapter, and dispatch native copy/cut keystrokes for Firefox sessions in the dashboard viewport. Co-authored-by: Kevin Gatera <kevingatera@gmail.com> * fix(stream): insert clipboard text literally via script.callFunction in Firefox live view Route Firefox input_insert_text through script.callFunction using document.execCommand('insertText') with an editable setRangeText fallback (skipping readonly, disabled, and non-editable elements) instead of WebDriver key actions, so PUA code points such as U+E007/U+E004 and control characters are inserted literally rather than interpreted as Enter/Tab. Co-authored-by: Kevin Gatera <kevingatera@gmail.com> --------- Co-authored-by: hyunjinee <leehj0110@kakao.com> Co-authored-by: Kevin Gatera <kevingatera@gmail.com> |
||
|
|
58d313edb6 |
fix(iframe): run eval in the selected frame and capture cross-origin iframe console (#2738)
* fix(iframe): run eval in selected frame and capture cross-origin iframe console - Resolve the active frame within the current tab's frame tree before evaluating, running in the frame's dedicated CDP session (OOPIF) or default execution context id (same-process) so CSP and same-site cross-origin frames work without `contentWindow.eval`. - Report the evaluated frame's own URL in `data.origin` so content boundaries reflect the iframe origin rather than the top-level page. - Clear `active_frame_id` whenever a popup, external tab close, top-level navigation, or browser close changes the active page. - Capture `Runtime.consoleAPICalled` and `Runtime.exceptionThrown` events from cross-origin iframe sessions belonging to the active tab. Co-authored-by: zhaohaode <13417014227@163.com> Co-authored-by: MrCoder <eagle.xiao@gmail.com> * fix(a11y): query active top frame first, propagate CDP errors, and fix nested OOPIF URL merge - Return `Result<Option<FrameHost>, String>` from `frame_host_info` so CDP timeouts and disconnects propagate instead of masking recovery errors. - Fast-path `frame_host_info` on `top_session_id` (1 RPC for same-process frames, 2 RPCs for direct OOPIFs) without fanning out across unrelated background sessions. - Treat a `FrameTarget` as authoritative only when `parent_session_id == session_id` so a parent OOPIF tree cannot overwrite a nested child OOPIF's live URL. * fix(iframe): harden frame context lookup, avoid Runtime replay duplicates, and refresh post-eval origin - Use `subscribe_methods(&["Runtime.executionContextCreated"])`, drop blind `Runtime.enable` retries, drain buffered contexts first, and use a 250ms grace window. - Share `eval_remote_object` and `parse_default_execution_context` so CDP transport errors are never wrapped in `Evaluation error: `. - Drain prior events and discard replayed `Runtime.consoleAPICalled`/`Runtime.exceptionThrown` events when cycling `Runtime` on a context miss. - Refresh the iframe URL after evaluation so in-frame `pushState` updates `data.origin`, and omit `origin` when empty so content boundaries fail closed to `unknown`. * fix(iframe): prune frame contexts, reset frame on window new, and buffer early OOPIF console events - Buffer `Runtime.consoleAPICalled`/`Runtime.exceptionThrown` events for iframe sessions attached in the same drain and replay them once `active_iframe_sessions` refreshes (fixes dropped load-time logs under `--allowed-domains`/proxy auth). - Clear `active_frame_id`, `active_iframe_sessions`, and WebMCP invocations in `handle_window_new` to match `handle_tab_new`. - Prune `frame_contexts` on `Runtime.executionContextDestroyed`, `Target.targetDestroyed`, `adopt_replacement_tab`, and `TryRecvError::Lagged`. - Replace fixed sleeps in iframe e2e tests with CDP drain polling and add background-tab OOPIF console isolation and event-lifecycle unit tests. * docs(iframe): update skill docs, CLI help, and MCP eval description - Document frame-scoped `eval` and cross-origin `console`/`errors` capture in `SKILL.md`, `references/commands.md`, `commands.mdx`, `debugging.mdx`, and `frame --help`. - Update `active_iframe_sessions` doc comments to cover console/exception capture alongside network tracking. - Reference `agent_browser_frame_switch` (`tabs` profile) and frame-scoped `origin` in the MCP `agent_browser_eval` tool description. * fix(iframe): dispatch unrelated CDP events while filtering replayed Runtime logs - Replace `discard_replayed_runtime_events` with `drain_cdp_events_filtered(Some(session_id))` + `apply_drained_events` so only `Runtime.consoleAPICalled` and `Runtime.exceptionThrown` for the cycled session are suppressed while target, network, page, execution context, and other-session console events are dispatched in order. - Add `test_drain_cdp_events_filtered_preserves_unrelated_events_while_suppressing_replay`. * fix(iframe): pass borrowed console args after main merge * test(iframe): use RequestTracker::entries after main merge --------- Co-authored-by: zhaohaode <13417014227@163.com> Co-authored-by: MrCoder <eagle.xiao@gmail.com> |
||
|
|
8a78afb377 |
fix(iframe): label iframes by name in snapshots and align iframe annotations (#2739)
* fix(iframe): label unnamed iframes in snapshots and align iframe annotations Snapshot output now falls back to an iframe's HTML title or name attribute for display when the accessibility tree has no name, keeping ref identity unchanged and omitting frame URLs. Annotated screenshots now resolve iframe child boxes via DOM.getBoxModel and OOPIF viewport offsets so labels align in top-level page coordinates across same-origin, cross-origin port, scrolled, nested, and transformed iframes. Fixes #2153 Fixes #2462 Co-authored-by: Ehsan-hash <Ehsan.slb@gmail.com> Co-authored-by: Paddy <89168564+patrickballard@users.noreply.github.com> * fix(screenshot): apply host content-quad affine transform for OOPIF annotations Projecting OOPIF element boxes with only a translation offset misplaced labels when the host iframe had CSS scale or rotation. Computing the affine map from the host iframe's content quad and the OOPIF layout viewport size aligns both position and dimensions across transformed OOPIF boundaries. Co-authored-by: Paddy <89168564+patrickballard@users.noreply.github.com> * fix(screenshot): compose iframe annotation boxes on captured image Iframe child annotations are now drawn directly onto the captured PNG/JPEG image instead of being injected into the parent document overlay, keeping each frame's layout geometry out of other documents while preserving top-level coordinates and DPR scaling. Co-authored-by: Paddy <89168564+patrickballard@users.noreply.github.com> * fix(screenshot): handle OOPIF scrollbars and scaled mobile visual viewports Use the OOPIF content viewport dimensions including visible scrollbars (window.innerWidth/innerHeight) when deriving the host content-quad affine transform so annotations and selector clips are not stretched when scrollbars are shown. Map composed iframe annotations to image pixels using the captured visual viewport or clip coordinate space (offset and pixel-to-CSS scale) so scaled mobile viewports align accurately. Co-authored-by: Paddy <89168564+patrickballard@users.noreply.github.com> * fix(screenshot): scale viewport-captured iframe annotations by dpr * visualViewport.scale Desktop viewport captures include visible scrollbars while visualViewport dimensions exclude them, so dividing captured image dimensions by visualViewport size stretched and shifted composed iframe boxes. Use dpr * visualViewport.scale directly for unclipped viewport captures while retaining clip-based scaling for full-page and selector captures. Co-authored-by: Paddy <89168564+patrickballard@users.noreply.github.com> --------- Co-authored-by: Ehsan-hash <Ehsan.slb@gmail.com> Co-authored-by: Paddy <89168564+patrickballard@users.noreply.github.com> |
||
|
|
0536ca2a1b |
fix(state): collect storage without stalling, leaking focus, or hitting the previous origin (#2746)
* fix(state): isolate temp storage target, keep it hidden, and collect attached origins Track temporary storage targets and sessions so the background network-control handler neither sets up the collector's own attachment (eliminating the 10s deadlock with --allowed-domains or proxy credentials) nor continues its paused requests to the network. Create the scratch target hidden and in the background with CDP fallbacks, pump private session Fetch events concurrently with navigation, merge origins from open page targets (including --cdp sessions), record restored origins, and propagate capture errors before overwriting an existing autosave. Co-authored-by: Stefan Smiljkovic <1984909+shtefcs@users.noreply.github.com> Co-authored-by: Sakib Rahman <13265680+thecodeartificerX@users.noreply.github.com> Co-authored-by: Saim Shafique <128062316+sx4im@users.noreply.github.com> Co-authored-by: Mitch Fultz <57411549+fitchmultz@users.noreply.github.com> Co-authored-by: Jaewang Lee <307875+leejaew@users.noreply.github.com> * fix(state): exclude tabs pinned by other sessions from state saves Filter Target.getTargets origins in save_state through TargetOriginScope and tab_binding::pinned_owner so tabs pinned by another session are never included, attached or pinned sessions only collect origins from their own tracked targets, and drain_events does not adopt a tab pinned by another session. * fix(tabs): skip attaching to tabs pinned by another session during event drain Check tab_binding::pinned_owner before calling Target.attachToTarget on discovered targets so title/URL updates on another session's pinned tab do not create untracked attachments, and detach auto-attached sessions for another session's pinned tab when no network controls are active. * fix(state): bypass service workers, propagate origin errors, gate load events, and keep session guard across close Enable Network and Network.setBypassServiceWorker on the temporary storage session so active service workers cannot intercept temp navigations or write to localStorage, return Err on per-origin navigation/timeout/eval failures instead of continuing, drain stale events and require Document fulfillment before accepting Page.loadEventFired, and keep the storage session guard and subscription active until after Target.closeTarget completes. Co-authored-by: Mitch Fultz <57411549+fitchmultz@users.noreply.github.com> --------- Co-authored-by: Stefan Smiljkovic <1984909+shtefcs@users.noreply.github.com> Co-authored-by: Sakib Rahman <13265680+thecodeartificerX@users.noreply.github.com> Co-authored-by: Saim Shafique <128062316+sx4im@users.noreply.github.com> Co-authored-by: Mitch Fultz <57411549+fitchmultz@users.noreply.github.com> Co-authored-by: Jaewang Lee <307875+leejaew@users.noreply.github.com> |
||
|
|
20d0eff8a5 |
fix(state): show state list dates and state show counts, and keep special keys in storage reads (#2747)
* fix(state): format state list dates, return state show counts, and preserve __proto__ in storage bulk reads Format numeric Unix-second modification times in state list output as UTC YYYY-MM-DD dates while keeping ISO string compatibility. Return structured cookie and origin counts from state_show and format state summaries before generic download/path branches in CLI output. Return key-value pairs from Web Storage bulk reads and build the JSON map in Rust so special keys such as __proto__ and constructor are preserved without mutating JS prototypes. Fixes #2455 Fixes #2284 Co-authored-by: pqminh27 <76590223+pqminh27@users.noreply.github.com> Co-authored-by: Luna <2442563541@qq.com> Co-authored-by: Aditya Datta <crazyme07071996@gmail.com> * fix(state): keep state show summary string and expose cookieCount and originCount Preserve the existing summary string in state_show JSON output for backward compatibility with existing consumers, expose structured counts via cookieCount and originCount, and render those counts in human-readable CLI output. Co-authored-by: Luna <2442563541@qq.com> --------- Co-authored-by: pqminh27 <76590223+pqminh27@users.noreply.github.com> Co-authored-by: Luna <2442563541@qq.com> Co-authored-by: Aditya Datta <crazyme07071996@gmail.com> |
||
|
|
7d6ff1bf33 |
fix(dashboard): map live view pointer to the real frame, forward held buttons, and resync self-closed tabs (#2744)
* fix(dashboard): map live view pointer coordinates, mouse buttons, touchpad context menu, and self-closed tabs - Forward real CDP `deviceWidth`, `deviceHeight`, `offsetTop`, and `pageScaleFactor` in screencast frame metadata and scale dashboard pointer input against the currently drawn frame. - Validate stream `input_mouse` messages (event type, button name, finite coordinates, bounded bitmasks) and forward `buttons` to CDP. - Send held-button state on dashboard `mouseMoved` events and synthesize a right-click when `contextmenu` fires without a preceding right mouse press. - Resync the stream tab list and active CDP session when a tracked page closes itself. Co-authored-by: Yusuf Güngör <yusufgngor@gmail.com> Co-authored-by: Kevin Gatera <kevingatera@gmail.com> Co-authored-by: Jeon Suyeol <devxoul@gmail.com> * fix(dashboard): drop unapplied offsetTop shift and guard right-click release before contextmenu --------- Co-authored-by: Yusuf Güngör <yusufgngor@gmail.com> Co-authored-by: Kevin Gatera <kevingatera@gmail.com> Co-authored-by: Jeon Suyeol <devxoul@gmail.com> |
||
|
|
5759f6bb2c |
fix(firefox): double-click, POST reload, cdp-url, and Windows test helpers (#2633)
* fix(firefox): fire dblclick when a gesture presses more than once `dblclick` sent each pointer step as its own `input.performActions` request, so a dialog that one press opens stops the steps after it. Firefox resets its click count at the start of every request, so both presses arrived with a click count of 1 and the page never received a `dblclick` event, on every platform. When a pointer gesture presses more than once, its presses now share one request and Firefox counts them, so the second press has a click count of 2 and the page gets `dblclick`. Pointer moves stay separate requests, and a single click is unchanged. If the first press opens a dialog, Firefox sends the remaining presses after the dialog closes. The e2e test now also checks that the page receives `dblclick`. * fix(firefox): resend a POST when reload runs on its result page Reloading a page that a form POST produced made Firefox ask whether to send the form again. WebDriver BiDi does not report that prompt, so `reload` waited for the load until the 25 second timeout and failed. The profile agent-browser creates for a launched Firefox now sets `dom.confirm_repost.testing.always_accept`, so `reload` resends the POST and loads the result, as it does on Chrome. An attached Firefox keeps its own setting. * fix(firefox): report get cdp-url as Chrome-only `get cdp-url` does not launch a browser, so on a running Firefox session it bypassed the Firefox backend and reached the Chrome handler, which answered "Browser not launched". It now returns the Chrome-only error that other CDP features return on Firefox. Every other command that does not launch a browser either runs without one or already handles Firefox. The docs list the command with the other Chrome-only features. * test(firefox): run the owned-process checks on Windows The Firefox e2e helpers found the owned Firefox with `pgrep`, which Windows does not have, and isolated the temp dir with `TMPDIR`, which Windows ignores. `e2e_firefox_smoke` failed on Windows every time, and other tests wrote their profiles into the real temp dir. The helpers now also set `TMP` and `TEMP`, and on Windows they read the process command lines through `Get-CimInstance`. * docs(firefox): note that dblclick finishes its second click after a dialog closes Firefox resets its click count between input.performActions requests, so dblclick sends both presses in one action chain and WebDriver BiDi cannot cancel queued ticks once a prompt opens. Update perform_pointer's doc comment and the Firefox and command docs to describe this behavior under --no-auto-dialog. |
||
|
|
06ea6d6a52 |
feat(firefox): click with another button or held modifier keys (#2595)
* feat(click): add --button and --modifiers to click and dblclick click and dblclick could only press the left button with no keys held. The parser took the first argument that was not --new-tab or --human as the selector and dropped every other flag, and the dispatch sent one press and one release with no modifiers. A click is now described by one ClickSpec (button, count, modifiers), decoded and validated in one place for both the CLI parser and the daemon. The dispatch walks an explicit Move, Press, Release sequence per click and carries the modifiers on every event, so a double click sends two full clicks and the page receives click, click, dblclick as with a real mouse. dblclick now shares the click handler, so it also follows the session input mode and accepts --human. Unknown flags are rejected instead of being ignored, and --new-tab cannot be combined with --button or --modifiers. Co-Authored-By: Kevin GATERA <22301610+kevingatera@users.noreply.github.com> * feat(mcp): expose click button and modifiers, and document them agent_browser_click and agent_browser_dblclick accept button and modifiers and pass them through the CLI parser. The mouse button schema now comes from the shared button table, so mouse down and up also list back and forward, which the CLI already accepted. Documents the new flags in the commands reference and the core skill reference. * fix(mcp): require at least one click modifier in the tool schema The modifiers array schema allowed an empty list that the argument reader rejects. Also corrects the docs sentence that said dblclick takes every click flag: it does not take --new-tab. * test(docs): record the new click examples in the docs baseline The /commands baseline sample is the whole command block, so the two inserted example lines need a from/to entry in docs-edits.json. * fix(click): name the backend limit when a non-Chrome session gets a button or keys The WebDriver guard rejected the new flags with a message that did not say what was unsupported or what to use instead. * refactor(mcp): read button and modifier names from the pointer tables The click tool schema spelled the modifier names out and used a fully qualified UFCS call for the buttons, so the schema could drift from the parser. Both enums now come from pointer.rs, and Modifiers derives its bits from one name list. * feat(firefox): click with another button or held modifier keys The Firefox click path read its own button string and ignored modifiers, so --button and --modifiers reached the daemon but never the page, and an unknown button silently became a left click. The click path now decodes the same ClickPlan as Chrome, holds the modifier keys for the whole gesture through BiDi key actions, and maps the button through the shared MouseButton table instead of a second name list. dblclick shares the handler, so it takes the same flags. Verified with a real Firefox 160 from FIREFOX_BIN: a right click fires contextmenu, a middle click fires auxclick with button 1, control and shift are held during the click, and an unknown button is rejected. * style: format the firefox click test * test(firefox): hold meta and shift in the click test The test held control and shift. macOS turns a control click into a context menu with no click event, so the test could not pass there. Meta and shift behave the same on every platform. * fix(firefox): release click modifiers on parent tab when iframe is removed * test(firefox): update modifier-release iframe mock for FrameTransform * fix(firefox): defer modifier release when a click opens a dialog Allow PendingRelease to represent button-only, modifier-only, or combined holds and release them together once the prompt closes. Avoid sending a modifier keyUp while a JavaScript dialog holds Firefox's input queue in click, dblclick, and input_mouse. * Align bidi/forms.rs ahead of laf/bidi-attach merge * Use MouseButton::Left in FirefoxControl::click --------- Co-authored-by: Kevin GATERA <22301610+kevingatera@users.noreply.github.com> |
||
|
|
d7546d49ea |
feat(firefox): attach to a running Firefox over WebDriver BiDi (#2227)
* feat(firefox): attach to a running Firefox over WebDriver BiDi Squashed during the stack rebase onto main. * fix(firefox): reject local file moves from attached browsers (#2384) Vercel Security Reviewer Publish-Id: 63af85a4-3cd8-4616-afd3-21483bd1ad1c Co-authored-by: vercel-security-reviewer-slack[bot] <321849240+vercel-security-reviewer-slack[bot]@users.noreply.github.com> * fix(firefox): stop blaming --engine firefox for a missing BiDi endpoint The probe error said --engine firefox expected an endpoint even when the user never passed --engine, such as after an attached Firefox exits. * fix(firefox): complete native HTML5 drag gestures * fix(firefox): read the active page through BiDi * fix(firefox): retain HAR request bodies and elapsed time * fix(firefox): complete HTML5 drags with DOM events * Align Firefox attach documentation with its route contract * fix(firefox): accept bare WebSocket endpoints and preserve CDP fallback * fix: initialize network controls before resuming new pages * fix: enable the current Chrome WebMCP feature * fix: align regression tests with integrated browser code * style: format integrated Firefox regressions * fix: correct docs fixtures and bound popup regression waits * fix(firefox): verify restore recovery and document capture limits * test(firefox): accept the command deadline for idle waits * test(firefox): use the current daemon stream constructor * fix(firefox): keep inferred attachment engines out of settings * style(firefox): format attachment routing regressions * Treat slow Firefox attach probes as healthy * Apply RDP timeout and liveness fixes to attach support * Fail closed after a Firefox DevTools timeout * Keep standard RDP replies after fail-closed timeouts * Update attached Firefox liveness expectations * refactor(firefox): the attached session records what it applied and undoes it on close * fix(firefox): decide in one table which settings an attached browser takes The planner dropped every launch-only setting for an attached browser, with a hand-written exemption for the engine, while the Firefox attach code applied some of those settings in place. The two lists disagreed, so `--user-agent` was reported and then ignored on an attached Firefox. `session_settings/attach.rs` now states, per setting, whether it needs a launch, a fresh attach, or can change in place on an attached Firefox. The planner and the attach path both read it. A user agent or download path set on an attached Firefox applies without reconnecting and is put back when the session closes. Docs and help text list what an attached Firefox accepts. * fix(firefox): keep a command's user agent when another setting changes Every settings pass on an attached Firefox compared the stored `--user-agent` with what the session last applied and reset the browser to the stored value. After `useragent X`, changing an unrelated setting such as `--default-timeout` therefore put the old user agent back. The in-place path now receives the settings that changed and applies only those, so a setting that did not change cannot undo a command. The attach e2e test sets a user agent by command, changes the default timeout and checks the user agent is still the command's; it fails without this change. * docs(firefox): drop the attach settings table The table claimed `--cdp-headers` is used for the attach handshake. The BiDi handshake does not send those headers. Several other rows were never checked against the code either, and the table's wording made the docs search test return the Firefox page for an unrelated query. The page goes back to the one sentence that is verified: the user agent and download path apply to an attached Firefox in place, and `close` resets both. * fix(firefox): leave an attached tab's size alone and undo overrides on close Attaching sent the default 1280x720 viewport to the user's selected tab, and close reset only the user agent and download folder. Firefox keeps emulation overrides after the session ends. Attach no longer applies a launch viewport. Close now clears every override the session holds (viewport, user agent, locale, timezone, geolocation, offline) in every open tab, from the one emulation record, so the separate user agent bookkeeping is gone. * fix(firefox): apply --user-agent on the first attach that detects Firefox A command that carried both a new `--cdp` target and `--user-agent`, on a session whose daemon was already running, dropped the user agent and reported it as ignored. The planner decides what an attached browser takes before the attach runs, and it treated a target it had not attached to yet like a browser known not to be Firefox. The planner now has three states for the engine behind an attach target: Firefox, another browser, or not detected yet. A setting only Firefox takes is carried into an attach whose engine is not detected yet. After the attach, the daemon keeps it when it found Firefox. Otherwise it puts the previous value back and reports the setting as ignored, as before. Only a `cdp` target can turn out to be Firefox, so plans for `--provider` and `--auto-connect` are unchanged, and a Chrome attach returns the same response as before. * fix(firefox): find the active tab when other tabs are unloaded or closed `snapshot` failed with `tabDestroyed` on an attached Firefox that had an unloaded tab, which session restore leaves until the tab is opened. To find the DevTools tab for the session's page, the lookup asked every tab for its target, and the first tab without one aborted it. DevTools tabs now come from one typed listing that marks unloaded tabs. The lookup skips them, since an unloaded tab has no page, and it skips a tab that closes while the lookup runs. It asks the selected tab first, which is the session's tab in the usual case, so a snapshot no longer runs a script in the other tabs of a browser the user is also using. Media emulation picked the first tab when none was selected, which could be an unloaded one. It reads the same listing and takes the first loaded tab. Reported by @matthewbjones on #2227. * fix(firefox): apply and undo attach overrides one tab at a time Firefox refuses a command that names one of its own pages, such as about:home, and it refuses the whole command when any listed tab is one. The in-place `--user-agent` change and the resets on `close` each listed every open tab in one command, so with such a tab open the change failed, and `close` left the user's tabs with the session's user agent, locale, timezone and geolocation, and left an offline tab offline. Each tab is now addressed on its own, through one helper. The session's own tab decides whether an in-place change failed. On close, the tabs that can be changed are put back. `close` also takes back the permission grants on a browser the session does not own, since Firefox keeps them in the profile after the session ends. Media emulation needs no reset: Firefox ends it when the DevTools connection closes, which happens when the session is dropped. A test now holds that connection to closing, and the doc comments say why `resets` omits it. * fix(firefox): apply in-place attach settings only after the policy gates Settings that ride on a command were applied before the action policy and confirmation checks, so that a changed policy governs the command. On an attached Firefox that pass also applied `--user-agent` and `--download-path` in place, so a command the policy denied, or one parked for confirmation, still changed the user's browser and could point its downloads at a directory the caller chose. A settings patch is now applied in named passes. Session-level settings still apply before the gates. Changes an attached browser takes in place wait until every gate has passed, and are reported as not applied when the command is denied or parked. An allowed command applies them in the same command, as before. * fix(firefox): refuse --pin-tab on a Firefox that is already attached `--pin-tab` cannot be enforced on an attached Firefox, and the attach refuses it. That check ran only while attaching, so a later command that added `--pin-tab` to a live attachment was accepted without any binding. When the session's tab closed, later commands moved to another open tab instead of failing with `tab_gone`. A command that asks for the pin on an attached Firefox is now refused before the pin is stored or the command runs, with the same error the attach gives. Every later command that still carries the flag is refused the same way. * refactor(firefox): drop duplicate attach tests, wrappers and docs Removes attach tests that repeat another test's assertions, one-line wrappers with a single caller, and the attach guide repeated on the Firefox engine page (it now links to the CDP mode page). No behaviour change. * test(firefox): drop the connect rejection test where attach supports connect The test asserts that connect with the Firefox engine is refused. That holds on the branch below. This branch adds attach, so the test had been removed here and came back through the merge. * Take the relaunch validation from laf/bidi-live-view-docs before merging it Brings in the base branch's launch validation hunks as they are so the merge that follows is conflict-free; the next commit reconciles them with this branch's attach-aware validate_firefox_launch. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * Bring in laf/bidi-live-view-docs's relaunch validation and snapshot hint fixes Content of merging laf/bidi-live-view-docs: the relaunch pre-check calls this branch's attach-aware validate_firefox_launch, which now takes the settings to check, and the Firefox hint pass is carried over. GitHub's merge endpoint reports a conflict, so it is pushed as a single commit; git merge -s ours origin/laf/bidi-live-view-docs records the ancestry without changing the tree. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * fix(firefox): undo emulation a failed attach already applied Attach applied the stored user agent to the user's tab inside open_session, so a later failure only sent session.end and the override stayed. Apply it after the session exists, within the attach deadline, so a failure goes through the same close() undo as the other attached settings. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * fix(firefox): record the pointer position from the browser, not from page scripts The pointer position is kept in top-level coordinates and later used by coordinate-free mouse commands. It was built from two values computed in the page's own realm: the element's point inside its frame, and a frame offset read through window.frameElement and window.parent, with a page-reported flag that skipped the browser-based mapping. A cross-origin iframe can redefine all of those, so hovering one of its refs could leave the pointer on a control in the parent, and the next mouse down and up would press it. The point inside the frame is now read in the isolated sandbox, and every frame hop is mapped from the browser's context tree and a verified frame handle read in the parent's sandbox. The page-realm mapper and the DOM-scanning mapper are gone, and the click path shares the frame lookup. The viewport edge used to plan the pointer path is read in the sandbox too. Adds a unit test where the page answers every call in its own realm with coordinates aimed at a parent control; the recorded position must still come from the sandbox and the frame handle. * fix(console): bound the console and page error history by memory, not only by count The tracker kept the latest 1,000 console messages and 1,000 page errors whatever their size, so a page that logged multi-megabyte messages could grow the daemon by gigabytes. Both engines feed it, and Firefox now subscribes to page logs at launch. The tracker now cuts each message or error to 64 KiB of text, marked with the number of bytes cut, replaces console arguments over 64 KiB with a note, and drops the oldest entries once the console messages, or the page errors, hold about 8 MiB. One bounded store handles both lists and the lists are read-only outside it. Callers pass arguments by reference, so an oversized value is never copied first. With a page logging 3 MiB messages, the daemon held 447 MiB on Firefox and 792 MiB on Chrome before, and 73 MiB and 193 MiB after. The console command returned 198 MB and 314 MB before, and about 4 MB and 6.5 MB after. Adds unit tests for the cut, the note, the byte bound with oldest-first eviction, and page errors. The limits are documented in the console and errors help, the debugging page and the command reference. * fix(firefox): re-attach dead sessions on in-place changes and override every tab on attach In-place settings (--user-agent, --download-path) ran before the relaunch check, so a command after an attached Firefox exited tried to write to the closed BiDi socket instead of re-attaching. Defer in-place settings to the launch pass when a relaunch is needed or the browser has exited, and roll them back if re-attach fails. Attached sessions also pre-populated emulation.user_agent before apply_attached_settings ran, causing the every-tab pass to skip and leaving --user-agent applied only to the starting tab. Leave emulation.user_agent unset until apply_attached_settings applies it to every open tab, and restore partially updated tabs if the active tab refuses the override. * fix(settings): only track ignored keys for rollback on relaunch * fix(firefox): plan attach destination before settings, normalize launch-only flags, and validate before closing - Merge launch/connect envelopes with invocation settings before planning so destination and Reuse/Replace transitions decide every option consistently - Probe ambiguous attach targets read-only and validate Firefox attach restrictions before closing the running browser or applying restore changes - Normalize explicit and inherited launch-only flags for external attach with ignored notices while preserving owned Firefox rejections - Plan user-agent and download options against the new Firefox destination when switching from an existing CDP attach * fix(firefox): preserve BiDi endpoint diagnostic when preflight probing fails * fix(firefox): thread prepared attach target through auto_launch_with_settings * test(firefox): update attached_target_for unit test for engine parameter * style: format attached_target_for test * fix(security): reject domain-restricted or CA-restricted attach before probing endpoints * test(security): use kebab-case allowed-domains wire key in preflight containment test * fix(firefox): reject syntactic Firefox attach pin-tab before allowed-domains preflight * fix(security): displace conflicting connection targets in launch envelopes Ensure Patch::with_envelope drops other mutually exclusive connection keys (and orphaned CDP headers) when the launch envelope names a target, so positional connect cannot be overwritten by an explicit settings provider. Also check effective launch settings for provider plugin capabilities in execute_command_inner as defense in depth. * fix(policy): gate provider plugin only when a command launches Check effective settings for provider plugin capabilities only when action is launch or needs_launch is true, so page commands on an already-connected provider session do not re-trigger browser.provider confirmation or denial. * fix(daemon): box settings and launch futures in execute_command Keep execute_command's async state machine small enough for debug test threads after combining the restore unit and attach planning passes. * Align pin_tab test setup ahead of laf/bidi-live-view-docs merge * Resolve pin_tab test merge in actions.rs --------- Co-authored-by: vercel-security-reviewer-slack[bot] <321849240+vercel-security-reviewer-slack[bot]@users.noreply.github.com> Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> |
||
|
|
e49844de63 |
feat(firefox): dashboard live view, bidi module and docs (#2208)
* feat(firefox): dashboard live view, bidi module and docs Squashed during the stack rebase onto main. * docs(firefox): drop set device from the supported list set device errors on Firefox, and the README and core skill already say it is unsupported. * test(stream): use an array for the cached tabs fixture clippy --all-targets flags the vec! as useless_vec; the test only slices it. * fix(firefox): switch to tabs the page opens target=_blank links and window.open left agent-browser on the old tab while Chrome follows the popup. Contexts BiDi reports with an originalOpener now become the active tab, and refs reset whenever drained events change it. * fix(firefox): complete native HTML5 drag gestures * fix(firefox): read the active page through BiDi * fix(firefox): retain HAR request bodies and elapsed time * fix(firefox): complete HTML5 drags with DOM events * Preserve proxy settings rollback after Firefox launch failures * Format Firefox proxy rollback regression * Preserve Firefox and streaming documentation expectations * fix(firefox): preserve dashboard input modifiers * fix(firefox): restore popup openers and clear stale frames * fix: align regression tests with integrated browser code * style: format integrated Firefox regressions * fix: correct docs fixtures and bound popup regression waits * fix: apply the engine docs fixture edit once * fix(firefox): verify restore recovery and document capture limits * fix(firefox): preserve CLI titles while bounding tab lookups * style: format bounded tab lookup * test(firefox): accept the command deadline for idle waits * test(firefox): match the clarified attach error before attach support * ci: run pull request checks for stacked branches * test(firefox): use the current daemon stream constructor * test(firefox): cover selectors shared by light and shadow roots * fix(firefox): resolve shadow refs through exact DOM ancestry * Fix the BiDi client path in the pointer rejection test * Remove duplicate Firefox dialog regression * Skip unreadable Firefox frames during state save * Format the unreadable-frame regression * Remove the unused RDP dispatcher dependency * Restore the owning tab when an iframe popup closes * Format the request scope regression * Fix renamed module references in request scope tests * Keep stale-ref checks tied to the snapshot document * Format snapshot document tracking * Adapt pointer checks and snapshot tracking to BiDi APIs * Return the snapshot result after recording its document * Apply RDP reply matching in the renamed module * Fail closed after a Firefox DevTools timeout * Format fail-closed RDP timeout assertions * Keep standard RDP replies after fail-closed timeouts * Remove duplicate DevTools initialization after merge * test(bidi): restore unit tests dropped when the Firefox modules moved 38 tests were lost in the move from firefox/ to bidi/. Restore them, porting the touch tap and stale-ref recovery tests to the new Origin and document-identity APIs. * docs: drop the stale browser engine edit from the commands fixture The page already lists firefox, so the edit no longer applies and the docs contract test fails on the missing anchor. * docs: keep one engine-list edit for the commands page The fixture listed the same replacement twice, so the second pass failed. Keep a single entry and leave the baseline untouched, so the route contract sees the Firefox engine list. * docs: record the Firefox engine in the configuration fixture The env table row changed with the engine list, so the route contract needs the matching edit. * docs: cover the plain-text configuration sample in the fixture The rendered sample and the table markup carry the engine list in different forms, so both need the edit. * fix(firefox): give the dashboard live view one owner With streaming enabled, every Firefox command asked the browser for the tab tree and each tab's title, whether or not a dashboard was connected, and the frame poller awaited each screenshot inline with a 30 s timeout, so one unresponsive tab stalled commands and froze prompt tracking. The poller is now the only code that talks to Firefox for the dashboard and the only writer of frames, viewport status, the tab list and the paused state. It is started once per session, works only while a client is connected, runs captures and tab reads as child tasks with 2 s timeouts, and learns about tab changes through one watch channel. The command path sends no BiDi request for the stream. Dashboards now get a tab list within one poll interval of a command instead of immediately. * fix(firefox): start a new dashboard poller for each Firefox session The poller was created once and reused for whatever session came next. It listens to one session's events and stops when that session's socket closes, so after Firefox exited and the session was relaunched, dashboards got no frames. A poller now knows which session it serves, and a session it does not serve gets its own. * fix(firefox): round live-view wheel input and reject connect Firefox takes only integers for a wheel scroll, so a trackpad's fractional deltas were rejected and live-view scrolling did nothing. The wheel builder now rounds the position and deltas for every caller. `connect` with `--engine firefox` attached to Chrome over CDP because the engine was set by the settings patch and dropped by the launch patch. The launch patch now carries it, so `connect` is rejected like `--cdp`. The docs no longer say it drives Chrome. * fix(stream): serve /api/tabs only to same-origin and local requests A session's HTTP server returned its cached tab titles and URLs from `/api/tabs` with a wildcard CORS header and no check of the request, so any page that could reach the loopback port could read them. Firefox sessions now fill that cache too. `/api/tabs` is served only when the request's `Origin` names the same loopback authority as `Host`, or when there is no `Origin` and `Host` is a loopback authority, which also stops a DNS-rebinding page. Other requests get 403. The response no longer carries the wildcard header; a same-origin request gets its own origin reflected. The dashboard reads tabs through its server-side proxy, which sends a loopback `Host` and no `Origin`, so it is unaffected. * test(firefox): point the stalled-tab test at the bidi module The merge from laf/bidi-network-emulation brought in a test that still named the firefox module, which this branch renames to bidi. * fix(firefox): cap live view frames and validate options before a relaunch closes Firefox AGENT_BROWSER_STREAM_MAX_WIDTH and AGENT_BROWSER_STREAM_MAX_HEIGHT did nothing on Firefox, which captures frames at the viewport size. Frames larger than the cap are now scaled down in proportion before they are published. A relaunch closed the running Firefox and only then checked the new settings, so an option Firefox rejects cost the open pages. The settings are now checked first, and a rejected option leaves the browser open. * refactor(firefox): drop duplicate live view tests, helpers and docs Removes a copied upload helper, two forwarding accessors, tests that repeat another test's assertions, and docs passages that repeat the Firefox engine page. No behaviour change. * test(firefox): give the idle live view test a session that already collects bodies A dashboard turns request tracking on, so the session adds its body collector on the first command. The test asserts an idle live view asks Firefox for nothing, so its session now starts with the collector in place. * test(firefox): restore the connect test and two docs passages The cleanup removed the only test that drives the explicit launch command with a CDP target into the Firefox check, the Obscura sentence saying later commands keep the engine, and the guidance on when to choose Firefox. None of the three is stated or tested anywhere else. * docs(firefox): note auth challenges, closed shadow roots and transformed iframes Firefox now cancels an auth challenge it has no credentials for, so the guide says what the page shows and how to authenticate. It also names two limits: controls in closed shadow roots cannot be acted on, and pointer commands can miss inside an iframe with a CSS transform. * docs(firefox): state that the Windows DevTools port is open to local accounts On Windows the daemon can only give Firefox's DevTools server a loopback TCP port, and Firefox has no way to restrict it to one account or authenticate its clients. The Firefox page now says so and tells readers to use the engine on Windows only where they trust every local account. * Take the relaunch validation from laf/bidi-network-emulation before merging it Brings in the base branch's launch validation hunks as they are so the merge that follows is conflict-free; the next commit reconciles them with this branch's validate_firefox_launch. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * Bring in laf/bidi-network-emulation's relaunch validation and snapshot hint fixes Content of merging laf/bidi-network-emulation, with the relaunch pre-check reconciled with this branch's validate_firefox_launch and the Firefox hint pass carried to bidi/snapshot.rs. Pushed as a single commit because the signed-commit rule and GitHub's merge endpoint (no rename detection for firefox/ to bidi/) leave no way to push the two-parent merge from here. Running git merge -s ours origin/laf/bidi-network-emulation records the ancestry without changing the tree. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * fix(firefox): record the pointer position from the browser, not from page scripts The pointer position is kept in top-level coordinates and later used by coordinate-free mouse commands. It was built from two values computed in the page's own realm: the element's point inside its frame, and a frame offset read through window.frameElement and window.parent, with a page-reported flag that skipped the browser-based mapping. A cross-origin iframe can redefine all of those, so hovering one of its refs could leave the pointer on a control in the parent, and the next mouse down and up would press it. The point inside the frame is now read in the isolated sandbox, and every frame hop is mapped from the browser's context tree and a verified frame handle read in the parent's sandbox. The page-realm mapper and the DOM-scanning mapper are gone, and the click path shares the frame lookup. The viewport edge used to plan the pointer path is read in the sandbox too. Adds a unit test where the page answers every call in its own realm with coordinates aimed at a parent control; the recorded position must still come from the sandbox and the frame handle. * fix(console): bound the console and page error history by memory, not only by count The tracker kept the latest 1,000 console messages and 1,000 page errors whatever their size, so a page that logged multi-megabyte messages could grow the daemon by gigabytes. Both engines feed it, and Firefox now subscribes to page logs at launch. The tracker now cuts each message or error to 64 KiB of text, marked with the number of bytes cut, replaces console arguments over 64 KiB with a note, and drops the oldest entries once the console messages, or the page errors, hold about 8 MiB. One bounded store handles both lists and the lists are read-only outside it. Callers pass arguments by reference, so an oversized value is never copied first. With a page logging 3 MiB messages, the daemon held 447 MiB on Firefox and 792 MiB on Chrome before, and 73 MiB and 193 MiB after. The console command returned 198 MB and 314 MB before, and about 4 MB and 6.5 MB after. Adds unit tests for the cut, the note, the byte bound with oldest-first eviction, and page errors. The limits are documented in the console and errors help, the debugging page and the command reference. * fix(firefox): serve fresh /api/tabs for Firefox sessions without a WebSocket client - Add a single-flight on-demand tab refresh channel from GET /api/tabs to the active Firefox poller when no WebSocket dashboard client is connected - Clear cached tabs when attaching a new Firefox BiDi client so stale Chrome tabs are not served - Keep idle Firefox sessions free of background polling when neither a WebSocket client nor /api/tabs requests tabs * test(firefox): accept default-denied geolocation before granting in loaded iframe E2E * docs(firefox): note that closed shadow root refs are actionable * Align actions.rs, bidi/client.rs and bidi/forms.rs ahead of laf/bidi-network-emulation merge * Temporarily align renamed firefox/ paths ahead of laf/bidi-network-emulation merge * Resolve merge, sync dashboard live view on pin changes, and document Firefox form commands Resolve the merge of laf/bidi-network-emulation across actions.rs and cli/src/native/bidi/. Reconcile the dashboard Firefox live target at command and tick boundaries so disabling --pin-tab after a closed pinned tab re-points dashboard input and live frames to the surviving tab. Document shared Firefox form prechecks, warnings, select --by, and check behavior in firefox.mdx, commands.mdx, skill-data/core/references/commands.md, CLI help, and MCP tool descriptions. --------- Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> |
||
|
|
487ce86ed4 |
feat(firefox): network control and emulation on Firefox (#2207)
* feat(firefox): network control and emulation on Firefox Squashed during the stack rebase onto main. * fix(firefox): retain HAR request bodies and elapsed time * fix(firefox): complete native HTML5 drag gestures * fix(firefox): read the active page through BiDi * fix(firefox): complete HTML5 drags with DOM events * Keep Firefox proxy credentials scoped to their settings * fix(firefox): track repeated downloads on Firefox 150 Give legacy download events a fresh identity after completion because Firefox 150 reuses navigation IDs. Preserve modern download IDs and extend the real-browser regression to repeat the download. * fix(firefox): track request bodies and link downloads * fix: align regression tests with integrated browser code * style: format integrated Firefox regressions * fix: correct docs fixtures and bound popup regression waits * fix(firefox): isolate storage export from user routes * fix(firefox): verify restore recovery and document capture limits * fix(firefox): wait for network idle after navigation * test(firefox): accept the command deadline for idle waits * fix(firefox): preserve origin auth and overlapping downloads * test(firefox): check origin auth without blocking navigation * fix(firefox): initialize the current HAR entry fields * style(firefox): format the overlapping download assertion * fix(firefox): scope networkidle waits to the active tab * Reuse the shared BiDi client in the fake Firefox session * Keep Firefox media emulation on the active tab * Test Firefox media emulation does not select background tabs * Remove the unused RDP argument from background emulation * Remove the unused RDP dispatcher dependency * Scope Firefox request recording to the active tab * Cover active child frames in request scope test * Prevent stale proxy credentials from reaching a new daemon * Test proxy credential isolation for daemon launches * Format the Firefox request scope regression * Expose Firefox context parentage to network tests * Allow Firefox accessibility snapshots more time in CI * fix(firefox): connect to DevTools once on launch The launch path opened a second RDP connection and enabled accessibility again, left over from a merge. Drop the duplicate block. * Revert the longer Firefox accessibility timeout The 90 second RDP timeout only hid the hang caused by the duplicate DevTools connection, which is fixed. Go back to 30 seconds so a real hang still fails fast. * refactor(firefox): one intake for recorded events, one allowlist entry point, one emulation applier * docs(firefox): authenticated proxies work, so stop listing them as rejected Update --help and the command references to describe proxy credentials as supported and keep the rejected list accurate. * fix(firefox): recover when the event queue drops events A subscriber's queue holds 65,536 events and anything past that was dropped without a trace. The session drains its queue only when a command runs, so on a busy page a dropped `network.responseCompleted` left its request counted as unfinished for the life of the tab and later `networkidle` waits timed out. The client now records that it dropped events. The session checks that before each command and, after a drop, reads the context tree again and forgets the unfinished requests, since their completions may be among what was lost. This is the same recovery that already ran when no context was active, now one function. * fix(firefox): leave an empty request body out of the HAR A request without a body was recorded with postData and an empty text, while Chrome writes no postData block. The empty check now runs once, before either recorder stores the body. * fix(firefox): keep permission grants across origins and blank pages `permissions` granted only the origin of the page that was open, so it failed on about:blank right after launch and on file: and data: pages, and a navigation to another origin lost the grant. Chrome grants for the whole browser context and needs no page. WebDriver BiDi grants a permission to one origin at a time, so the session now records the granted names and gives them to each origin as a tab loads it. The dispatcher grants an origin when it sees the tab's document request, before an intercepted request is released, so the page holds the permission by the time it can ask. Each redirect hop and each history traversal sends its own document request and is covered the same way. A file: page is granted through the one origin Firefox uses for all of them. A name is checked with Firefox before it is recorded, so an unsupported one still fails the command when no page is open yet. Permissions move out of the emulation module into their own. The e2e test grants on about:blank and then checks two origins. * fix(firefox): stage downloads outside the requested directory `download` pointed Firefox at the directory of the requested path, and Firefox saved the file there under the name the page chose before the command renamed it. A download that failed or timed out left that file behind, so a page could put a file such as `conftest.py` in a project directory. Each `download` now stages into its own private temporary directory and moves only the file it claimed to the requested path. The staging directory is removed on every exit path, along with anything else the page saved there. * fix(firefox): hold document requests until their origin holds the grants A granted permission reaches a new origin when the dispatcher sees the tab's document request. Without request interception that request was not held, so the grant only raced the page, and a script on a newly loaded origin could ask before the grant landed. Granting a permission now installs the session's request intercept, so each document request stays paused until its origin holds the grants. * fix(proxy): replace stored proxy credentials on every launch The daemon keeps proxy credentials to answer the proxy's auth challenges. A local Chrome launch stored them only when the launch named some, and otherwise left the previous ones in place. Firefox launches store them too, so a session that moved from an authenticated Firefox proxy to Chrome with a different proxy and no credentials would answer the new proxy's challenge with the old proxy's credentials. Every launch now goes through one function that replaces the stored credentials with those of the browser being launched, and clears them when it names none or when the daemon does not launch the browser itself. * fix(firefox): give page-opened tabs the session's emulation, credentials and grants Emulation was sent to one browsing context at a time and replayed after a new one existed, so a tab the page opened made its first request with the real user agent. Overrides are now set on the tab's cookie jar, which covers every tab in it from creation. The color scheme was a DevTools setting of the selected tab only, so such a tab loaded with the system scheme. It is now a browser preference set through DevTools. An origin that answered 401 to a request that already carried an Authorization header fell back to Firefox's auth prompt, which nobody answers, and the navigation waited for its timeout. That challenge is now cancelled so the 401 reaches the page. Permission grants covered only top-level documents. A frame of another origin holds its own grants, so frame documents are now covered too. * test(firefox): give the network test session the ref document map * fix(firefox): refuse a blocked URL before tab new creates the tab tab new with a URL the allowlist refuses failed only after the new tab was created and made active, so the commands that followed ran on an empty tab. The allowlist is now checked before the tab exists, next to the label check. The check inside load stays, since every URL load goes through it. * test(firefox): stop asserting a popup leaves the active tab alone The popup emulation test ended by checking the active tab had not moved. That is not what the test is about, and the live view branch makes the active tab follow a popup the way Chrome does, where the check fails. * test(firefox): drop network and emulation tests that repeat other tests Removes tests that compare a builder's output with the same literal or repeat a case another test already asserts, and moves their distinct assertions into the test that stays. The download staging and route header tests stay, since nothing else covers them. * fix(firefox): collect request and response bodies only while they are read Every session added a BiDi data collector at launch and never removed it, so Firefox kept up to 10 MB per body for the whole session even with HAR recording and request tracking off. The network drain, which is the only reader of those bodies and runs around every command, now adds the collector when HAR recording or request tracking turns on and removes it when both are off. * refactor(firefox): remove duplicated network and emulation helpers Drops an allowlist method identical to check_url, a route decision variant handled exactly like another, single-use accessors and wrappers, and repeated request lookups. No behaviour change. * test(firefox): clear proxy credentials in the shared engine test environment The Firefox test environment now takes its variable list from the one the Obscura tests use, which lacked the two proxy credential variables the proxy tests set. * fix(firefox): collect bodies while responsebody waits responsebody reads the body of the next matching response, so it needs the data collector even when HAR recording and request tracking are off. It now installs the collector before it waits, and the drain after the command removes it again. * fix(firefox): cancel an origin auth challenge instead of opening Firefox's dialog An origin 401 answered `default` unless the request already carried an Authorization header, which handed the challenge to Firefox's own auth dialog. Nothing in the daemon can type into that dialog, so the navigation blocked until the CLI's read deadline. The challenge is always cancelled now, so a page whose credentials are missing or wrong answers at once with its 401 body. Proxy 407 challenges still use the configured credentials up to the retry limit. * fix(firefox): cancel auth challenges from the start of the session Auth challenges were only intercepted once a route, header or filter had installed the request intercept. A plain open of a page that answers 401 still reached Firefox's own auth dialog and blocked until the CLI gave up. The session now intercepts the auth phase as soon as it starts, and the request intercept covers only requests. * test(firefox): answer with the fake session's silent reply The load-timeout test came from the branch below, where the fake answered with an Option. This branch answers with FakeReply, so the test needs the silent variant to leave a command unanswered. * fix(firefox): cap the bytes each event queue holds Every BiDi subscriber queued up to 65,536 events of any size, and the daemon reads its own queue only between commands. A page that logged large strings while a command ran could grow the daemon by gigabytes. Each queue now also has a byte budget: 64 MiB for events and a separate 8 MiB for page logs, so a console flood cannot push out the events that keep tabs, requests and dialogs current. An event that does not fit is dropped. A dropped log leaves no state to rebuild, so it no longer triggers the lost-event recovery. Checked against Firefox with a page that logs 400 strings of 1 MiB during one eval: the daemon peaked at 1,093 MB before and 52 MB after. * fix(firefox): take a frame download only from the clicked frame `download` on an element inside an iframe also accepted a download that began in the embedding page. A hostile embedder could start a faster download of its own and have that file saved at the path the user asked for. The command now accepts only a download that begins in the clicked element's own browsing context. The new e2e test starts a slow download in a cross-origin frame while the embedding page finishes its own first, and fails on the old code. * Take the relaunch validation from laf/bidi-snapshot-refs-input before merging it Brings in the base branch's launch validation hunks as they are so the merge that follows is conflict-free; the next commit adapts them to this branch's launch flags. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * fix(firefox): adapt the relaunch validation to this branch's launch flags The allowlist is supported here and checked by ensure_allowed_domains_supported_for_launch, so validate_firefox_launch drops the allowed_domains flag the base branch passes. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * test(firefox): pin that a Firefox launch drops the previous browser's proxy credentials The Firefox network dispatcher answers proxy challenges from the daemon's credential slot, so launch_firefox has to rebind that slot to its own proxy before the dispatcher exists. The rebinding is a single call, and a merge resolution on this branch dropped it once, which let a Chrome session's proxy credentials reach a different proxy after a switch to Firefox. Add a unit test that starts from stored credentials, launches Firefox through another proxy, and checks the slot is cleared, then replaced by the new launch's own credentials. It runs without a browser, unlike the ignored Firefox e2e. * fix(console): bound the console and page error history by memory, not only by count The tracker kept the latest 1,000 console messages and 1,000 page errors whatever their size, so a page that logged multi-megabyte messages could grow the daemon by gigabytes. Both engines feed it, and Firefox now subscribes to page logs at launch. The tracker now cuts each message or error to 64 KiB of text, marked with the number of bytes cut, replaces console arguments over 64 KiB with a note, and drops the oldest entries once the console messages, or the page errors, hold about 8 MiB. One bounded store handles both lists and the lists are read-only outside it. Callers pass arguments by reference, so an oversized value is never copied first. With a page logging 3 MiB messages, the daemon held 447 MiB on Firefox and 792 MiB on Chrome before, and 73 MiB and 193 MiB after. The console command returned 198 MB and 314 MB before, and about 4 MB and 6.5 MB after. Adds unit tests for the cut, the note, the byte bound with oldest-first eviction, and page errors. The limits are documented in the console and errors help, the debugging page and the command reference. * fix(network): bound tracked requests and HAR request bodies by count and memory Tracked requests previously appended every active-page request and POST body to an unbounded Vec, and HAR recording did not apply body budgets to request bodies or cap entry count and headers. Because the default stream server enables request tracking, visited pages could exhaust daemon memory. Encapsulate tracked requests in RequestTracker (capped at 1000 entries and 8 MiB aggregate, clipping URLs, headers, and POST bodies before copying and evicting oldest entries on both insert and update), apply the shared HAR_MAX_BODY_BYTES / HAR_MAX_TOTAL_BODY_BYTES and HAR_MAX_ENTRIES caps across both request and response bodies on Chrome and Firefox, and scope Firefox's BiDi data collector through an explicit DataCollectorState state machine. * fix(firefox): collect response bodies under RequestsOnly for request_detail * fix(firefox): grant iframe permissions, replay session setup on relaunch, keep window viewports local, and resolve proxy credentials - Walk the full browsing context tree when granting permissions so already-loaded cross-origin iframes receive grants - Record runtime emulation and global headers in session_setup and replay them on owned Firefox relaunches - Track per-context window viewport overrides separately from the session baseline and stop seeding Firefox relaunch from observed stream dimensions - Resolve proxy server and separate AGENT_BROWSER_PROXY_USERNAME/PASSWORD once in flags for both daemon spawning and settings patches * test(firefox): adapt focus prompt test to FakeReply * fix(firefox): keep network dispatcher control events lossless Add a lossless filtered subscription mode on BidiClient and use it for the network dispatcher's control channel. An overflow of bounded control events previously evicted the subscriber and caused the dispatcher to exit on None, leaving later intercepted requests blocked. * Align contexts.rs and storage.rs ahead of laf/bidi-snapshot-refs-input merge * Resolve merge conflicts in contexts.rs and storage.rs --------- Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> |
||
|
|
45067d9957 |
feat(firefox): snapshots, refs and element commands on Firefox (#2206)
* feat(firefox): snapshots, refs and element commands on Firefox Squashed during the stack rebase onto main. * fix(firefox): complete native HTML5 drag gestures * fix(firefox): read the active page through BiDi * fix(firefox): complete HTML5 drags with DOM events * Preserve Firefox element test fixtures during integration * fix(firefox): recover frame targets after event lag * test(firefox): keep network tests with the network implementation * fix: align regression tests with integrated browser code * style: format integrated Firefox regressions * fix: correct docs fixtures and bound popup regression waits * fix(firefox): verify restore recovery and document capture limits * fix(firefox): keep page commands on the top-level context * fix(firefox): bound nested launch futures on debug stacks * test(firefox): return a complete script evaluation result * fix(firefox): honor mouse motion options and wheel position * Format Firefox pointer regression assertions * Capture Firefox elements outside the viewport * Format the Firefox screenshot regression * Use real pointer events for Firefox check and uncheck * Remove the unused synthetic checkbox click import * Expose Firefox click preparation to form commands * Revert "Remove unused DevTools setup from owned Firefox launch" This reverts commit |
||
|
|
70416cb088 |
feat(firefox): launch Firefox over WebDriver BiDi (#2205)
* feat(firefox): add WebDriver BiDi and DevTools protocol clients Small clients for the two protocols the Firefox engine uses: BiDi over WebSocket and Firefox's DevTools protocol (length-prefixed JSON over a unix socket or loopback TCP). Covered by mock-server tests. * fix(firefox): time out DevTools requests and keep replies aligned A DevTools request now fails after 30s instead of waiting forever, and a failed write drops its waiter so later replies reach the right request. * feat(firefox): find, validate and launch an owned Firefox Locates Firefox (env override, PATH, standard installs; rejects snap), rejects options that cannot apply to Firefox, and launches it with a fresh temp profile, BiDi on a random port and the DevTools server on a private socket. The process tree and profile are removed on drop. * feat(firefox): launch Firefox sessions and route commands to them --engine firefox now launches an owned Firefox from both the explicit and implicit launch paths, reuses a live session, relaunches a dead one, and tears it down through the same close path. Commands are routed to a Firefox module before the WebDriver and dialog gates; Chrome-only commands fail with a clear error, and confirm/deny and the pending-dialog guard work as on Chrome. navigate, url, title, eval, tab list and close work; doctor reports the Firefox binary. * fix(firefox): keep the DevTools socket path short The DevTools socket now lives in a short private dir under /tmp, so a long TMPDIR no longer breaks launch on the macOS socket path limit. * feat(firefox): page, tab, storage and capture commands back, forward, reload, content, wait (ms, load state, function, url), tabs with Chrome-style t<N> ids, cookies, local/session storage, state save/load with --session-name restore, screenshots (viewport and full page) and PDF now work on Firefox with the same output as Chrome. * test(firefox): add Firefox e2e harness and CI job Real-browser e2e tests gated on FIREFOX_BIN, mirroring the Obscura harness. CI installs Firefox from Mozilla and runs the smoke test; later scenarios are enabled as their features land. * fix(firefox): engine switching, recovery, autosave and handshake bounds Close Firefox before switching engines, relaunch Firefox (not Chrome) after a crash, autosave and drain Firefox sessions on the background tick and before a relaunch, reject launch options Firefox would ignore, keep DevTools replies aligned after a timeout, keep wait polling through transient script errors, and bound the BiDi and DevTools handshakes. * fix(firefox): keep the BiDi connection on large full-page screenshots The BiDi socket used tungstenite's default 64 MB message limit, so a long page's full-page screenshot closed the connection and every later command waited 30 seconds before failing. The limit is now off, like the CDP client, and a command on a closed socket fails immediately. Tested with a Firefox e2e that captures a >48 MB full-page screenshot: fails with "BiDi connection closed" before, passes after. * fix(firefox): auto-accept alert and beforeunload like Chrome Chrome accepts alert and beforeunload dialogs unless --no-auto-dialog is set; Firefox left them pending and blocked the next command. The BiDi session now asks Firefox to accept those two prompt types itself, and prompts Firefox already handled are not reported as pending. confirm and prompt still wait for the dialog command. Tested with a Firefox e2e: an alert and a beforeunload no longer block. * fix(firefox): default cookie paths like Chrome cookies set without a path used the page's full path, so a cookie set on /one was gone on /two. Chrome's CDP setter builds a host-only URL, so the default path is /. Firefox now defaults to / too; explicit paths are unchanged. Tested with a Firefox e2e: fails before, passes after. * fix(state): write state files owner-only State exports and autosaves hold cookies and tokens but were written with default permissions, so under a 022 umask other local users could read them. Chrome and Firefox now write state files through one helper that creates or tightens them to 0600 before writing, and the managed sessions directories are 0700. User-chosen export folders are untouched. Tested with a unit test that rewrites an existing 0644 file and creates a new one. * fix(firefox): restore saved storage in an isolated realm The state restore wrote saved localStorage and sessionStorage by evaluating setItem calls in the page, with no origin check, so a page hooking Storage or a redirect to another origin could read the saved tokens. Restore now runs one script in a BiDi sandbox that checks the origin before reading the payload. * fix(firefox): skip storage origins that redirect and keep restoring Firefox state restore now skips an origin whose page landed somewhere else, like Chrome, and returns the skipped origins so state load and launch --state report them. Adds a Firefox e2e test for page-script isolation and redirects. * fix(firefox): box the Firefox dispatch future so execute_command stays small * fix(daemon): run confirm outside the dispatch match so it never nests execute_command's dispatch match has a very large debug poll frame. confirm re-entered execute_command from inside that match, so a confirmed command kept two dispatch frames on the stack and overflowed the 2 MiB test thread stack. The match now lives in dispatch(), and confirm calls handle_confirm before it. * fix(firefox): validate restores and scope cookie reads like Chrome Firefox restore checks now run against the page, and autosave goes through the shared private writer with candidate validation and promotion, so a failed restore no longer overwrites good saved state. cookies get returns only cookies that apply to the requested URLs, or the active page and its frames, checking domain, path and Secure. * test(daemon): clear AGENT_BROWSER_CDP in the unknown-command test The test read the process environment without holding the env lock, so it failed whenever it ran alongside the test that sets AGENT_BROWSER_CDP to an invalid target. * fix(firefox): launch, idle and autosave lifecycle fixes - launch --state no longer merges into a live Firefox; it relaunches like Chrome. - A headed Firefox is exempt from the default idle shutdown, and browserLaunched reports a live Firefox. - A closed BiDi connection counts as a dead session, so the next command relaunches. - Autosave reads iframe origins and keeps saved origins it could not read, so a partial save no longer drops logged-in storage. Explicit state save still overwrites. - The stderr drain decodes lossily instead of stopping at the first non-UTF-8 line. - Firefox reuses Chrome's URL glob matcher instead of a copy. - Test fixes: cookie default-path comment, restore-validation e2e checks saveStatus and cleans up. * chore: refresh MCP tool catalog snapshot * fix(firefox): preserve saved storage when reads are blocked Return null when either storage read fails so autosave keeps the previous origin. Cover blocked reads and deliberate storage clearing. Use the platform Firefox filename in the resolver test and keep launch tests within the commands this branch supports. * fix(firefox): read the active page through BiDi * test: preserve Windows runtime variables in MCP CLI check Keep the environment variables needed for Windows sockets when clearing the test environment. Include the full MCP result if the expected parser error is absent. * fix(firefox): preserve saved state and handle dialogs * fix: align browser startup and docs checks with current behavior * fix: preserve paused target state during network setup * fix: align regression tests with integrated browser code * fix: correct docs fixtures and bound popup regression waits * fix(firefox): handle launch defaults and bound tab operations * fix(firefox): verify restore recovery and document capture limits * fix(firefox): run all Firefox e2es and reject unsupported headers * fix(firefox): reset inherited engine when switching connections * fix(firefox): apply live dialog settings and count open tabs * Run native browser end-to-end tests on pull requests * Run only Firefox browser tests on pull requests * Remove timed-out Firefox DevTools requests from the actor queue * Test RDP recovery after a request timeout * Remove unused DevTools setup from owned Firefox launch * Match RDP replies by command type after timeouts * Fail closed after a Firefox DevTools timeout * Keep standard RDP replies after fail-closed timeouts * Format fail-closed RDP timeout assertions * fix(firefox): drop tabs closed outside the daemon Subscribe to browsingContext.contextDestroyed and remove destroyed top-level contexts from the tab list and labels. If the active tab was destroyed, fall back to a surviving tab and reset refs and frame state, so later commands work and the label can be reused. * fix(firefox): tab new races prompts and launch stops opening the debugger socket tab new <url> now returns with dialogOpened set when the page opens a prompt during load, instead of waiting out the 30s BiDi timeout. Firefox no longer starts the DevTools server or enables chrome devtools here, since nothing in this change connects to it. * refactor(firefox): one owner each for navigation, tab lifecycle, prompts and launch validation * fix(firefox): answer the prompt in the tab that opened it dialog now targets the context recorded with the pending prompt instead of the active tab, so a prompt in a tab you switched away from can still be accepted or dismissed. * test(firefox): pin the prompt target in the dialog test The test asserted only that handleUserPrompt was sent, so it passed while the command went to the active tab. It now checks the context in the request. * fix(firefox): give window new its own cookie jar window new now opens the window in a fresh BiDi user context, so it starts without the other window's cookies and storage, like Chrome's browser context. Closing the window removes the user context. * fix(firefox): keep cookies and new tabs inside the window's user context Cookie reads, writes and clears use the active tab's storage partition, and tab new opens in that user context, so an isolated window stays isolated. * fix(firefox): keep new tabs and restored cookies in the window's jar A tab opened from an isolated window was created in that window's user context but never recorded as belonging to it. active_partition looked the new tab's context up in window_contexts, missed, and fell back to the default jar, so cookie reads and writes on that tab went to the wrong jar and the next tab opened outside the window. tab_new now records the user context it created along with the context, which keeps active_partition and the following tab_new inside the window. Several tabs now share one user context, and tab_close still drops the context only when the last tab of the window closes, counting by user context value. A state load replayed saved cookies without a partition, so loading while an isolated window was active wrote them into the default jar. The restore path now sends the active partition, the same way cookies_set does. The other cookie calls in this module already carried it. The window cookie e2e test now sets a cookie in a tab opened from the window, checks a third tab opened from that one stays in the same jar, and checks the default jar stays clean once the window closes. A new e2e test covers restoring cookies while an isolated window is active. * refactor(firefox): track browsing contexts in one registry Tab ids, labels, the active tab and each tab's cookie jar lived in five maps on the session that every handler updated by hand. A popup opened from an isolated window was never added to the jar map, so cookie commands and state save used the default jar while it was active. `Contexts` now records every context Firefox reports, frames included, with the user context Firefox reports for it. Tab ownership, the active context and the storage partition are answered there and nowhere else. User contexts created by `window new` are removed once their last tab is gone, whoever closed it. Also in this change: - `window new` honours `viewport`, as it does on Chrome. - The DevTools client and its socket setup move to the snapshots change, the first one that uses them, so the module-wide `allow(dead_code)` can go. - Drop a launch test that repeated the fake-binary test and the e2e smoke test. Tested with `cargo test firefox` and the Firefox e2e suite; the window test now opens a popup from an isolated window and reads its cookies. * fix(firefox): adopt the next tab when no open tab is active After the last known tab closed, the session kept an empty active context, so commands failed until a tab switch even though a new tab had opened. The registry now makes the first tab it records active when none is. * fix(firefox): recover the active tab when its creation event was lost When no context is active, read the context tree instead of waiting for an event that may have been dropped. Also restore the launch test's check that Firefox is not started with a DevTools server. * fix(firefox): save state from the active window's cookie jar State save from a window opened by `window new` read open tabs from every jar and re-read visited origins in a tab created in the default jar, so it dropped the window's storage and picked up the default window's. It now reads only tabs in the active tab's jar and creates the storage tab in that jar, both asked of the context registry. The window e2e test saves state from an isolated window after navigating away and checks the saved storage is that window's. * fix(firefox): read saved storage in a sandbox and check its origin State save read each origin's storage with a script in the page's own JavaScript realm, so the page could change what was read, for example by patching `Storage.prototype.getItem`, and the values it chose were saved and written back into that origin on restore. The origin on the result was also taken from the script and never compared with the browser's. Storage is now read in the same BiDi sandbox the restore already uses, where page patches do not apply. Each read is given the origin the browser reports for the context, returns nothing if the page has moved to another origin, and is dropped on the Rust side unless its origin matches. The open-tab path and the background-tab path share that one read. * fix(firefox): reject proxy schemes Firefox cannot honour An https:// proxy fell through to the plain HTTP proxy setting, so Firefox talked to the proxy without TLS while the user had asked for an encrypted connection to it. The WebDriver proxy capability has no way to ask for TLS to the proxy. The proxy scheme is now matched explicitly. http://, socks4://, and socks5:// proxies work as before, and any other scheme is rejected by launch validation before Firefox starts. * test: stop two races that fail the Rust job The credentials and HAR tests read paths under HOME more than once without the lock that other tests hold while they change HOME, so a change in between sent the second read to a different directory. Both now hold that lock for the whole test. The skills tests copy the binary and run the copy. A child forked by one test inherited the descriptor another test was still copying through, and running that copy failed with 'Text file busy'. The tests in that file now run one at a time. * fix(firefox): default a cookie's path from its URL A cookie set without a path was stored at "/", so one set on /foo/bar was sent site-wide. Chrome derives the RFC 6265 default path from the cookie url or the page URL (/foo). Firefox now does the same and keeps "/" only when there is no URL to derive from. The e2e test asserted the old path and now checks the cookie is scoped to the page directory. * test(firefox): drop launch tests that repeat other tests Removes unit tests that restate the implementation or assert a fake's canned reply, merges tests that prove the same behaviour, folds the read e2e test into the smoke test to save a browser launch, and trims two doc passages that described internals. * fix(firefox): report values JSON cannot carry the way Chrome does eval returned null for undefined and the strings "NaN", "Infinity" and "10" for NaN, Infinity and bigint, so callers saw engine-dependent values. The BiDi value conversion now yields null for anything JSON cannot represent, and eval adds the same unserializable token Chrome returns (undefined, NaN, Infinity, -Infinity, -0, 10n). Both engines build the reply with one function. * refactor(firefox): reuse shared helpers for waits and timeouts Firefox carried its own copies of code the Chrome path already has: the wait-for-selector expression and the command timeout lookup. It also had three copies of the same poll loop. Each now has one implementation. No behaviour change. * test(firefox): restore the smoke checks for init scripts and first-save storage The cleanup removed them as duplicates, but nothing else sends initScripts through the launch command, and nothing else asserts that the first save captures a closed origin's storage. * fix(firefox): always name the tab's cookie jar when reading or writing cookies cookies, cookies clear and state save/load sent no partition for a tab in Firefox's default user context, so BiDi ran the command over every jar and a window opened with `window new` leaked into them. The partition is now always the tab's user context, default included, matching Chrome. * fix(firefox): report a load timeout instead of a raw socket error A page whose subresource never finishes kept the BiDi load waiting for 30 seconds, as long as the CLI waits for the daemon, so the CLI gave up first with a socket error. A load now uses the session's default timeout, as Chrome does, and fails with the same load timeout message. This covers open, tab new, reload, back and forward. * fix(firefox): reject an unsupported action before launching Firefox The check for actions Firefox cannot run sat in the Firefox dispatch, which runs after the browser is launched. An unsupported action therefore started Firefox and then failed, or failed with a launch error when Firefox was missing. The same check now runs before the launch, so the action fails at once with the not-supported message and no browser starts. * fix(firefox): reject an unsupported action before switching restore sessions The check ran after the restore session switch, which saves and closes the running browser. An unsupported action with a new session name closed Firefox and then failed without starting a replacement. The check now runs first. * test(firefox): use an action no layer of the stack supports The pre-launch test used snapshot, which Firefox gains later in the stack, so the test would then try to launch a browser. vitals stays unsupported. * fix(firefox): let the session timeout decide when a load gives up `ff.bidi.send` carries a fixed 30s deadline, so a session timeout above 30s failed the load at 30s with the BiDi error instead of the load timeout. The load now sends without a client-side deadline and its own budget is the only one in play. A fake session that never answers a method covers the case. * A launch setting Firefox rejects (--profile, --user-agent, --cdp) closed the running Firefox in the settings relaunch before launch_firefox validated it, losing the session. Validate the planned settings before the relaunch instead, reusing the launch validation. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * fix(firefox): follow a popup the active tab opens A tab opened by window.open or target=_blank only became active once the previous active tab was gone, so url, navigate and eval kept acting on the opener. Record each tab's opener, make a popup of the active tab active like Chrome does, and hand back to the opener when it closes. Matches the later bidi branches. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * fix(firefox): handle history boundaries, history landing, event loss, and storage origin normalization - Treat BiDi no-such-history-entry as a no-op returning the current URL - Wait for history traversal to land on the destination document under one timeout and prompt race - Filter critical BiDi event subscriptions in the socket reader and reconcile context state on overflow - Normalize saved storage origins during restore and autosave merge while keeping original skipped labels * Apply main's changes to actions.rs and the restore docs ahead of the main merge Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * Resolve the main merge in actions.rs and the restore docs Keep the Firefox unsupported-action check ahead of main's restore unit, count Firefox and the other WebDriver sessions as active browsers for relaunch and autosave, skip Firefox autosave while the restore identity is unresolved, and keep the Firefox notes in the restore docs. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * test(firefox): pass the restore key through the settings patch main now carries the restore key and checks only in the settings patch, so the Firefox restore e2e sends them there instead of the old top-level fields. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * fix(firefox): enforce --pin-tab in the context registry Propagate --pin-tab to Firefox on launch and runtime settings updates so page-opened popups never replace the active context while pinned. Closing the bound tab moves the registry into a tab_gone state instead of falling back to an opener or neighboring tab, refusing page commands with Chrome's tab_gone error and structured recovery data until an explicit tab switch, tab new, window new, or --no-pin-tab. * fix(firefox): refuse storage reads and autosave when a pinned tab is gone Require a live storage tab instead of falling back to the default user context when a pinned tab closes, so periodic autosave and close cannot overwrite an isolated tab's saved state with the default window's cookies or storage. Keep restore validation pending while pinned-gone. --------- Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> |
||
|
|
da1268d6a2 | Fix flow replay waiting for requests Chrome reports late (#2711) | ||
|
|
dd1247c7fa |
fix(flow): normalize host rules, enforce write consent, bound deadlines, and fix result shaping (#2735)
- Normalize case and trailing DNS root dots in `HostPolicy::of` and `HostPolicy::allows_host` so equivalent hostnames match saved restrictions. - Restrict the GraphQL read-only exception in `is_write` to `POST` requests so non-POST methods still require write declarations and consent. - Bound HTTP preflight cookie and route lookups in `http::send` by the run deadline so stalled lookups cannot outlast the run. - Abort in-page fetches via `AbortController` and `setTimeout` when the remaining run budget expires and skip the credential fallback after abort. - Skip `unknown_fields` validation on empty result lists and project/clone only rows retained by `--limit` in `apply_shape`. Co-authored-by: Afloat <ShuffleMonkey@163.com> |
||
|
|
2204ad8688 |
fix(keyboard): send key codes and apply held and chord modifiers (#2734)
* fix(keyboard): propagate held modifiers, key codes, and chord modifier events keydown/keyup now resolve physical codes, virtual key codes, locations, and text via named_key_info, and track held CDP modifier bits across subsequent press, keydown/keyup, mouse, and flow-recorder commands. press applies US-layout Shift mapping, suppresses text for Alt/Control/Meta, and dispatches keyDown/keyUp for chord modifiers not already held. Co-authored-by: Roberto Campos <64264987+cavalcanticampos@users.noreply.github.com> Co-authored-by: Ossi <29481017+osrjv@users.noreply.github.com> Co-authored-by: Hannes <135652575+hanneslipusch@users.noreply.github.com> Co-authored-by: Junpei Zhang <199601925+pei711@users.noreply.github.com> * fix(flow): resolve key code aliases when redacting recorded secrets Use the same key chord and key-code resolution in FlowRecorder::record_key as keyboard dispatch so physical aliases (KeyA-KeyZ, Digit0-Digit9, Space, ShiftLeft/ShiftRight) are tracked in secret buffers and redacted in saved flows. Unrecognized keys in secret fields are redacted by default. --------- Co-authored-by: Roberto Campos <64264987+cavalcanticampos@users.noreply.github.com> Co-authored-by: Ossi <29481017+osrjv@users.noreply.github.com> Co-authored-by: Hannes <135652575+hanneslipusch@users.noreply.github.com> Co-authored-by: Junpei Zhang <199601925+pei711@users.noreply.github.com> |
||
|
|
0a923358ea |
Prepare v0.44.0 (#2722)
* Prepare v0.44.0 * Add #2667 and #2720 to the v0.44.0 changelog --------- Co-authored-by: Railly Hugo <railly.hugoquispe@vercel.com> |
||
|
|
bf03eb1383 |
fix(webmcp): show each tool's origin in announcements (#2720)
* fix(webmcp): show each tool's origin in announcements and gate direct invocation to the page's own origin Text announcements now name the top-level page origin, start every record with the browser-reported origin of the tool, and mark tools from other origins as cross-origin. Direct invoke examples cover only tools from the page's own origin; cross-origin tools require confirming the origin against the user's task first. * test(docs): record the webmcp origin edits in the route fixtures |
||
|
|
1ee56cd2b7 |
refactor(settings): carry the restore key, save policy and checks only through the settings patch (#2667)
* refactor(settings): carry the restore key, save policy and checks only through the settings patch The restore envelope fields duplicated the restore settings rows, and the daemon validated them in three places. The restore key is now a launch setting: a key change closes the running browser at the launch, saves it under the key it ran with, and only then starts the new key's restore cycle. The save policy and checks that arrive with a new key wait for the same point, so the old browser is not validated against the new key's checks before its save. A failed launch puts the key back. close and commands that never launch leave the key alone. auth login --no-navigate still rejects a key change. A restoreSave that is not a string is an error instead of auto. The CLI validates the restore key and save policy from the patch before it starts a daemon. * fix(settings): validate the restore save policy without a restore key * docs(sessions): restore key change relaunches; close and failed launch use the current key * fix(settings): apply the restore key, save policy and checks as one unit after the policy gates The unit applies once, past the policy gates and any confirmation, for every command including close and commands that do not launch. A denied or parked command changes none of it, so no restore check is installed for autosave to run. A failed launch puts all of it back, and a daemon seeded with a key starts as pending instead of not_configured. * fix(settings): report a relaunch only when the command launches A close that changes the restore key closes the old browser and launches nothing, so lifecycle.relaunchedBrowser is set where the launch happens. * fix(settings): drop the restore save policy and checks with the restore key A command that never launches a browser dropped the restore key but still sent the save policy and checks, so they applied to the running key. The restore unit now leaves a non-launching patch as a whole. * fix(settings): keep restore policy on the running key for non-launch commands A non-launching patch now keeps the restore save policy and checks only when it names no restore key or the running one. A different key drops them with it. The CLI cannot see the running key, so it sends none of the unit for `get cdp-url`. * docs(settings): non-launching commands apply the restore unit A command that never launches a browser applies live settings and the restore key, save policy and checks together, not launch settings. Tests cover the key switch and the same-key policy change through execute_command. * fix(settings): report a closed browser for a restore key change that never launches A new restore key on `close` or another command that never launches saves and closes the browser without relaunching it. Its stderr line said "relaunched browser" while the response reported `relaunchedBrowser: false`; it now says "closed browser". * fix(settings): send --restore-save without a restore key The CLI sent the save policy only with a restore key, so `close --restore-save never` still saved. An explicit policy now rides the settings patch on its own and applies to the running key. The close e2e builds its commands through the CLI parser. * docs(settings): match restore unit docs to get cdp-url and close `get cdp-url` sends live settings without the restore unit, a save policy without a key applies to the running key, and a key change on a command that never launches closes the browser without relaunching it. * fix(settings): label launch-setting notices from the full browser lifecycle A launch-setting line said "closed browser" whenever `relaunchedBrowser` was false, so a fresh launch with `--allowed-domains` claimed a close. A failed command carried no lifecycle flags, so a `read` that failed after a new restore key closed the browser said "relaunched browser". The line now says "relaunched browser", "launched browser" or "closed browser" from `relaunchedBrowser` and `launched`. A failed response with a settings report now carries both flags, and a response without them says "applied". The lifecycle note no longer repeats "launched browser" when a setting line names it. * fix(settings): close the browser attached under a rolled-back restore key without saving |
||
|
|
dc987e0831 |
feat(webdriver): add Ladybird provider (#2721)
Add -p ladybird, which spawns Ladybird's WebDriver server and drives it through the existing WebDriver backend. Safari and Ladybird now share one LocalDriver launcher. The WebDriver client read responses until EOF, but Ladybird keeps the new-session connection open, so launch hung. The client now uses reqwest, which honors Content-Length. Headless Ladybird sessions follow the default idle timeout; headed ones stay exempt like other headed browsers. Tested end to end against Ladybird 2026.47.7 on Linux, headless and headed. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> |
||
|
|
3a83e3cfb2 |
fix(interaction): refuse fill, type, check, uncheck and select on preconditions (#2687)
* fix(interaction): refuse fill, type, check, uncheck and select on preconditions fill, type, check, uncheck and select reported success without checking the target. The target's own properties now decide, before anything changes: - Refuse with stable codes: not_editable, read_only, disabled, not_checkable, option_not_found, ambiguous, malformed_value. - fill sets date, time, color and range inputs directly and rejects values the input would sanitize away. - check and uncheck return when the state already matches, refuse non-toggle elements, a checked radio and disabled controls, and retry with a DOM click for native inputs only. - select takes a unique exact label, then a unique exact value, otherwise ambiguous; options sharing a value are one choice; several values on a non-multiple select are refused first; multiselect shares the checks. - Whether the page ended up as requested is a warning shown in text and JSON output, not an error. - type with only newline, carriage return and tab keeps the key dispatch. Text insertion and clearing are unchanged. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): narrow refusals to never-text elements, tolerate failed reads, select --by - fill and type refuse only elements that can never take text (select, button, checkbox, radio, file, submit and reset inputs, and color, range and date-type inputs for type); where text lands for everything else is unchanged. A label stands for its control. - A failed read after the action (context destroyed, page navigated) is a warning, not an error, and a probe that cannot inspect the element lets the action proceed. - select: a string that matches exactly one option by value or exact label selects it; matching options with different values, across kinds or by shared label, is ambiguous. --by value|label (and a by field in MCP) restricts matching so every option is reachable. Several values on a single select are not_multiple. - Option and treeitem state comes from aria-selected, role tokens are parsed, line endings are normalized before comparing, and the form warning is carried in its own data key. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): snap range values to the step, point type at fill - fill on a range input inside its bounds sets the value the browser snaps to and warns with the requested and held values; unparsable and out-of-range values stay malformed_value. - The refusal hint for type on color, range and date-type inputs says to use fill to set the value of the input. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): select takes dash-leading values, buttons behave as before - select treats only --by <v>, --by=<v> and a leading -- as special; values such as "-- Select --" or "-none-" are data, as in the type parser. A repeated --by is rejected. - fill and type no longer refuse button, submit, reset and button inputs: whether text reaches a field through them depends on focus. - A read that fails because the page navigated reports "page navigated after the action; result not verified". - The ambiguous error advises the by field over MCP and the --by flag in the listbox path; the select synopsis in the docs lists --by. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): type no longer refuses readonly inputs type does not clear the field, so a readonly input is left to the page as before (a trigger may forward focus to another field); fill still refuses it because it would empty the value. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): form warnings never echo field values; option labels are the browser's labels - A fill whose value the page rewrote reports the change by length (length 10 -> 14) or as a different value of the same length; the snapped-range warning, the malformed_value error and the could-not-verify warning no longer repeat a value or a raw error. - An option's label is option.label, the text the browser shows. select matches it by default and with --by label, and no longer matches the hidden text of an option that has a label override, which removes false ambiguity. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): type --clear is refused on readonly fields Any step that destroys a field's value is refused on a readonly field, not only fill: type --clear empties the value before the browser drops the text. A plain type does not clear, so it keeps its behavior. The type help, docs, MCP description and skill text say so. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): fill and type act on one resolved control, refuse non-text targets and report altered text Labels and date parts resolve to their control once, and focus, clear, insert and read-back all use it. Options and hidden, image, button, submit and reset inputs are refused with the other targets that never take text, from one table. type compares the read-back with the prior value plus the typed text and warns on a maxlength cut or a mask rewrite. Errors and warnings name the target from the caller's selector and a fixed tag and input-type vocabulary; ids, tag names and option labels from the page are never included. * docs: describe refused targets and ambiguous select results * fix(interaction): scrub page strings from select errors, refuse buttons and controlless labels, warn only when typed text is missing * fix(interaction): page text never reaches form errors, refuse targets that take no focus, report maxlength cuts and replace editable content The precheck, select and value-input failures return a kind or a number and the message is built in Rust, so nothing a page returns is repeated in an error. fill and type refuse a target that neither takes focus nor forwards it to another field, walking open and closed shadow roots. type warns when the old value plus the typed text exceeds maxlength and the field is full, even when the old value already contains the typed text. fill replaces the content of an editable region instead of appending. * fix(interaction): refuse by focusability, not by focus movement; keys-only text skips the focus guard A focusable target whose focus handler forwards to the already-focused field is a valid typing path. The guard now refuses only a target that cannot take focus and where focus did not land. Key-only text goes to the focused control as before. * fix(daemon): box fill/type futures and isolate the har_stop test env The fill and type futures grew the execute_command frame past a debug test thread's stack. The har_stop test built its state without the env lock, so an action policy path set by another test leaked into it. * fix(interaction): guard on an observed focus signal instead of tabIndex A hidden, display:none or inert input has tabIndex 0 but cannot take focus. The guard now allows a target that received focus or a focus event during focus() and refuses otherwise. * fix(interaction): count only trusted focus events in the focus guard A page could override focus() to dispatch a synthetic focus event and pass the guard, sending text to the field that already had focus. * fix(interaction): clear editable regions in their own document, return select options as error data, measure maxlength after focus selection - fill and type --clear select and delete an editable region through its ownerDocument, so a region inside a same-origin iframe is replaced instead of prepended to. - select no-match errors keep fixed text with the option count; the options go to data.options as [{value, label}], printed inside content boundaries by the CLI. - the maxlength check subtracts the text selected after focus, so a field that selects on focus does not report a cut that did not happen. * fix(form): treat input and textarea as text controls inside a contenteditable ancestor isContentEditable is inherited by form controls, so fill deleted a textarea and the read-back used innerText. One helper classifies by tag first; only a non-control element with isContentEditable is an editor. * fix(mcp): pass select's by mode after the selector The select parser reads its first argument as the selector, so --by placed before it became the selector. MCP now builds select -- <selector> [--by <mode>] -- <values>. * fix(select): refuse an empty value list and keep option data out of the MCP advice rewrite An empty list matched nothing but cleared the selection. The by-field rewrite now touches only the error message, so option labels in the response data stay as the page wrote them. * fix(interaction): refuse clearing a field that turns readonly on focus The readonly check ran before focus, so a field whose focus handler sets readOnly passed it, and the clear step then emptied the value. fill and type --clear now check again at the clear step and refuse with read_only, keeping the value. * fix: accept every css color chrome accepts when filling a color input * fix: update the mcp tool catalog for color fill * fix(interaction): check stored color, controls in editors, and normalized range values A color input that stores a color other than the one requested, such as black for red on a browser that accepts only #rrggbb, now fails with malformed_value and keeps its previous value. A select, option, or button inside an editable region is refused like it is anywhere else instead of being replaced by the text, unless it is itself an editing host. Range and other value inputs are compared with the value the browser stored, so 50.0 stored as 50 no longer warns. --------- Co-authored-by: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-authored-by: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-authored-by: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> |
||
|
|
d2dfc782cc | fix(ci): enable WebMCP on Chrome 157+, unblock paused iframes under --allowed-domains, and fix the Windows and global install jobs (#2700) | ||
|
|
1fde6b90e8 |
feat(webmcp): announce page tools so agents use them (#2606)
* feat(webmcp): announce page tools with full descriptions and a direct-use prompt
The announcement now says the page provides N tools, lists each tool on one line inside the nonce-bounded block, and tells the agent to use a relevant tool before driving the DOM. Small catalogs keep full descriptions so the call can often skip the schema lookup. When the bounded catalog omits tools, the lead line reports how many are listed. The invoke line carries the frame id when every listed tool shares one.
* fix(webmcp): escape control characters in the announcement and tighten its wording
Page-provided names and descriptions are collapsed to one line, with control and invisible formatting characters shown as escapes. The lead is conditional on a tool fitting the task, the frame id is filled only for a fully listed single-frame catalog, and the listed counts read correctly down to a catalog too large to list. The context eval detects the new announcement text. Docs describe chat and the dashboard fetching a schema only when the description does not show the arguments.
* fix(webmcp): escape every invisible format character in the announcement
Page text is escaped by class instead of a hand-picked list: control characters, the Default_Ignorable_Code_Point ranges and the remaining format characters, including the tag block and variation selectors. A literal backslash before u{ is escaped so real text cannot imitate an escape, and the full-description budget counts the rendered size so escape expansion cannot exceed it.
* fix(webmcp): bound the rendered announcement for large catalogs
The bounded context path charged JSON bytes but not the escaped text the
announcement renders, so sixteen tools with soft-hyphen descriptions
produced a 3.9 KB context and an 11 KB announcement. Accrue
webmcp_record_len against MAX_CONTEXT_BYTES there as well, and mark the
catalog truncated once a record no longer fits.
* fix(webmcp): count only visible records when --max-output cuts the announcement
The lead claimed every tool was listed and the invoke line kept a concrete
frame id after truncation had hidden records. Select the records that fit the
limit before building either, fall back to <frame-id>, and point at the full
catalog when records are hidden.
* fix(webmcp): report the page total consistently when the catalog is shortened
The truncation note used the daemon's record count as the total, so a page with 40 tools and 13 held records read "showing 1 of 13 tools". It now uses the page total, matching the lead.
|
||
|
|
bb034f384c |
fix(cli): reject unmet preconditions in upload, har stop, diff snapshot and diff url (#2689)
* fix(cli): reject unmet preconditions in upload, har stop, diff snapshot and diff url upload resolves relative paths in the CLI against its own cwd, fails with file_not_found for a missing file (warns for provider browsers) and with not_file_input for other targets. network har stop fails with no_har_recording when no recording is active, e.g. after a browser restart. diff snapshot without --baseline compares against the last snapshot of the page session, or fails with no_baseline. diff url returns the snapshot diff the renderer reads, honours --screenshot, --full, --selector, --compact and --depth. Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: Mohammad-Maraqa <154911866+Mohammad-Maraqa@users.noreply.github.com> Co-Authored-By: cavalcanticampos <64264987+cavalcanticampos@users.noreply.github.com> Co-Authored-By: hyunjinee <63354527+hyunjinee@users.noreply.github.com> * docs: describe upload paths, har stop and diff snapshot preconditions * docs: record upload and diff snapshot prose edits in the docs baseline * fix(cli): keep the diff snapshot baseline's options, pass directories to upload, warn for remote browsers A bare diff snapshot captures with the options and frame of the last snapshot; an option that differs fails with baseline_mismatch. diff snapshot accepts -i and -u. upload accepts directories (webkitdirectory), expands ~, and only warns when the browser is on another machine (provider or non-loopback --cdp). diff snapshot --baseline resolves against the CLI cwd and fails with file_not_found when the file is missing. diff url --full without --screenshot is rejected. Messages and docs name the daemon restart as what discards a HAR recording, and MCP tool descriptions are regenerated. * fix(upload): record the attached target for every session connection A session whose settings carry --cdp, auto-connect or a provider attached without recording the target, so upload treated a remote browser as local and rejected paths missing on this host. The target is now derived from the connection after every settings-driven launch. Also: diff snapshot baseline_mismatch names both the requested and the last snapshot values, the MCP diff_snapshot tool accepts urls, the directory upload test waits for the input to be populated, and docs say the implicit baseline is per tab. * fix(cli): keep the diff snapshot baseline per tab and box the launch future The implicit baseline of diff snapshot is kept per tab and dropped when the tab closes, so a snapshot on one tab no longer discards another's. The launch wrapper boxes the inner launch future so it stays out of the caller's future size. * fix(security): keep page text out of upload errors and inside content boundaries not_file_input names the node only through a fixed tag list and input type list. Snapshot diff output, including diff url, goes through the same boundary and truncation path as other page content. * test(cli): compare resolved paths without assuming forward slashes std::path::absolute emits backslashes on Windows, so expected paths are built with Path::join and the HAR test checks the file name. --------- Co-authored-by: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-authored-by: Mohammad-Maraqa <154911866+Mohammad-Maraqa@users.noreply.github.com> Co-authored-by: cavalcanticampos <64264987+cavalcanticampos@users.noreply.github.com> Co-authored-by: hyunjinee <63354527+hyunjinee@users.noreply.github.com> |
||
|
|
5aad200e67 |
test(native): serialize encryption-key and HOME mutation behind one env lock (#2697)
The auth tests took AUTH_TEST_MUTEX while the credentials and parity tests took ENV_MUTEX for the same AGENT_BROWSER_ENCRYPTION_KEY, so they could overwrite each other. All of them now use EnvGuard with a temp HOME, and the HAR default-location test holds the same lock. |
||
|
|
45d8c11ddc |
fix(mcp): keep tool argument values from being read as CLI flags (#2681)
* fix(cli): accept -- before operands of select, press, keyboard and similar commands These parsers read operands directly, so a leading end-of-options marker was taken as the first operand. * fix(mcp): pass every typed positional after an end-of-options marker select, upload, press, keydown, keyup, keyboard, set device, tab and the single-value tools built argv without the marker, so values such as --session or --help were parsed as CLI flags. Co-Authored-By: holny <12433219+holny@users.noreply.github.com> * fix(mcp): reject caller values that would be read as global flags A single guard in the shared argv path rejects any typed value that would land before the literal boundary and parse as a global flag (--session, --help, -h, --restore=, --webgpu, --proxy), whether or not the flag is on the allow-list. Schema enums are checked before argv is built, and skills/plugin operands accept the end-of-options marker. A lone -- stays an operand. Co-Authored-By: holny <12433219+holny@users.noreply.github.com> * fix(mcp): reject derived global-flag tokens and enum-array values Global-looking tokens built from caller data (k=v pairs, joined lists, option values) are rejected in both the command and global argument paths. Flow param names may not start with '-'. Enum validation covers array items. skills get/path accept the -- boundary. The class test now covers enum fields, object keys, every global flag from the flag tables, and fails if a tool is skipped. Help text and docs list the commands that take -- and the MCP rejection of flag-shaped values. Co-Authored-By: holny <12433219+holny@users.noreply.github.com> * fix(mcp): scope the global-token guard to value slots and split the class test A caller string equal to a server-emitted global flag is rejected only when it lands in a flag value slot, so data after the literal boundary such as fill text "--session" passes. The class test asserts on parsed flags and covers each flag class plus a table test over every global flag. Co-Authored-By: holny <12433219+holny@users.noreply.github.com> * test(native): give the tab-binding tests their own session Tests that do not take the env lock write default.target into whichever socket dir is current, which can overwrite a binding another test saved. The pin-tab and rollback tests now use their own session name. * fix(mcp): validate click modifiers with the CLI parser and cover every parsed flag - click and dblclick modifiers are checked with Modifiers::parse_list, so aliases such as ctrl, cmd and ctrl+shift stay accepted - tab new accepts the -- marker and MCP passes the url after it - skills get parses its operands in one function and treats names after -- as names - restore keys that start with '-' are rejected - the class test compares every parsed global flag with a neutral reference call, covers the shared arguments, and has a table test per documented command Co-Authored-By: holny <12433219+holny@users.noreply.github.com> * fix(mcp): accept restore keys that start with a hyphen A restore key travels as one --restore=<key> token, so a leading hyphen cannot be read as another flag. The parser now strips exactly one --restore= prefix, so a key such as --restore=evil keeps its text. * fix(mcp): read flag-shaped fields of auth, webmcp and plugin tools as data auth save, auth login, webmcp invoke, webmcp result and plugin run take free-form names and values. The MCP builder now puts -- right after the subcommand, so a name such as --session reaches the command instead of being refused or read as a global flag. Tests run the recorded argv through parse_flags and parse_command and check that Flags stay unchanged. * fix(mcp): keep per-command extraArgs working on auth, webmcp and plugin tools Global extraArgs stay before the -- marker; the remaining options go after the operands, where these parsers read them. The docs name the fields that pass flag-shaped values. * fix(mcp): keep help and version in extraArgs before the operand marker The CLI reads --help and --version only before --, so moving them after the operands ran the command instead of printing help. --------- Co-authored-by: holny <12433219+holny@users.noreply.github.com> |
||
|
|
a7e41ff16a |
test: fix Windows CI failures in session settings and pin-tab tests (#2692)
* test(session-settings): use platform-absolute policy paths in env seed tests The env seed makes the policy path absolute against the working directory. A bare /x.json is not absolute on Windows, so it gained the drive prefix and the expectations failed. * test(native): isolate the close-without-browser test from the shared socket dir The test ran close against the default session in whichever socket dir was live. Close releases a pin in that session's binding, so it could unpin the binding another test had just written, failing pin_tab_false_disables_a_pin_read_from_disk_on_attach intermittently. |
||
|
|
07883ddbc0 |
fix(daemon): carry action warnings out of band instead of in response data (#2693)
* fix(daemon): carry action warnings out of band instead of in response data Page-derived JSON returned as command data could include a postActionWarning key and be promoted to a daemon warning. Handlers now set a Rust-only pending warning on DaemonState, drained once when the response is assembled and reset at the start of each command. * fix(daemon): queue session setup warnings on the same out-of-band channel sessionSetupWarning was still hoisted from response data. Producers now queue it on DaemonState, so no data key is promoted. Tests drive execute_command with forged warning keys and check a leftover warning does not reach the next command. * test(daemon): isolate the action warning tests from the shared socket dir They run execute_command, which writes the default session's tab binding; a private socket dir keeps them from racing other tests. |
||
|
|
343602553a |
fix(snapshot): ref native controls with non-interactive roles, pierce shadow roots, scope -s to all matches (#2688)
* fix(snapshot): ref native controls with non-interactive roles, pierce shadow roots, scope -s to all matches The cursor scan skipped every native tag, so <summary> and buttons with role=menu got no ref, and it never entered open shadow roots. It now skips a native tag only when its AX role is interactive, walks open shadow roots, resolves matches without mutating the DOM, and snapshot -s covers every match. Co-Authored-By: swjtuhuangjunfu <7245859+swjtuhuangjunfu@users.noreply.github.com> Co-Authored-By: danted4 <67830495+danted4@users.noreply.github.com> Co-Authored-By: Zhao0335 <218378524+Zhao0335@users.noreply.github.com> Co-Authored-By: linzch3 <20380442+linzch3@users.noreply.github.com> Co-Authored-By: luxleader <205600116+luxleader@users.noreply.github.com> * fix(snapshot): tighten cursor scan and -s scoping The cursor scan compares inherited cursor:pointer against the flat-tree parent, so shadow children and slotted nodes no longer get extra refs. It scans from document.body, skips a details container and a link without href that wraps a control, and ColorWell is an interactive role. snapshot -s drops matches nested in another match and releases its element handles. Help, MCP description, skill text and the docs edit fixture describe the every-match scope. * fix(snapshot): list -s matches in page order and keep links around hidden controls snapshot -s sorts its roots by the page order of the selector matches instead of AX-tree index order. A link without href is skipped only when it wraps a control that is visible and not aria-hidden. * fix(snapshot): treat display:contents controls as visible when their contents render A link without href wrapping a display:contents control was not covered by that control because its own bounding rect is empty. Visibility of such an element now comes from the rect of its contents. --------- Co-authored-by: swjtuhuangjunfu <7245859+swjtuhuangjunfu@users.noreply.github.com> Co-authored-by: danted4 <67830495+danted4@users.noreply.github.com> Co-authored-by: Zhao0335 <218378524+Zhao0335@users.noreply.github.com> Co-authored-by: linzch3 <20380442+linzch3@users.noreply.github.com> Co-authored-by: luxleader <205600116+luxleader@users.noreply.github.com> |