Skip to content

feat(firefox): launch Firefox over WebDriver BiDi - #2205

Open
lahfir wants to merge 57 commits into
mainfrom
laf/bidi-engine-launch
Open

lahfir wants to merge 57 commits into
mainfrom
laf/bidi-engine-launch

Conversation

@lahfir

@lahfir lahfir commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor
  1. agent-browser could only drive Chromium-based browsers, so Firefox users had no engine.
  2. This adds --engine firefox, which launches an owned Firefox over WebDriver BiDi and runs page, tab, storage and capture commands on it.
  3. First of four stacked PRs; continued in feat(firefox): snapshots, refs and element commands on Firefox #2206.

@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agent-browser Ready Ready Preview, v0 Nov 9, 2026 10:41pm UTC
agent-browser-env-demo Ready Ready Preview, v0 Nov 9, 2026 10:41pm UTC

@vercel-internal-security-reviewer

Copy link
Copy Markdown

Security review details

Comment thread cli/src/native/firefox/storage.rs Resolved
Comment thread cli/src/native/firefox/storage.rs Resolved
Comment thread cli/src/native/actions.rs Resolved

@Railly Railly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. autosave writes the state file in place, so a crash mid-write might wipe the previous state; save_auto_state_transactional could help
  2. a few firefox e2e tests here (dialog, route, allowlist) need features from #2206/#2207 and fail on this branch; ci only runs the smoke test so it doesn't show

Comment thread cli/src/native/firefox/session.rs Resolved
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.
Comment thread cli/src/native/firefox/tabs.rs Resolved
Comment thread cli/src/native/firefox/storage.rs Resolved
Comment thread cli/src/native/firefox/process.rs Resolved
…gger 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.
Comment thread cli/src/native/firefox/actions.rs Resolved
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.
Comment thread cli/src/native/firefox/actions.rs Resolved
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.
Comment thread cli/src/native/firefox/tabs.rs Resolved
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.
Comment thread cli/src/native/firefox/storage.rs Resolved
Comment thread cli/src/native/firefox/storage.rs Resolved
Comment thread cli/src/native/firefox/tabs.rs Resolved
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.
Comment thread cli/src/native/firefox/tabs.rs Resolved
Comment thread cli/src/native/firefox/storage.rs Resolved
# Conflicts:
#	docs/content/docs/network.mdx
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.
Comment thread cli/src/native/firefox/storage.rs Resolved
Comment thread cli/src/native/firefox/session.rs Resolved
let params = &e["params"];
match e["method"].as_str() {
Some("browsingContext.contextCreated") => {
if params["parent"].is_null() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contextCreated branch assigns a tab id to a popup but never records its inherited userContext, so once the popup is the active tab, cookie reads, writes and state save use the default jar instead of its window's. Reproduced.

This branch was successfully deployed

2 active deployments
Preview – agent-browser — 7c363b01 Deployed Nov 9, 2026 by vercel[bot]
Preview – agent-browser-env-demo — 7c363b01 Deployed Nov 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants