Open Bug 2081129 Opened 1 month ago Updated 1 day ago

[firefox-devtools-mcp] Call global commands with the proper user context in container restricted sessions

Categories

(Developer Infrastructure :: Firefox MCP, enhancement, P2)

enhancement
Points:
3

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Depends on 2 open bugs)

Details

(Whiteboard: [webdriver:m22])

Attachments

(1 external file)

When the WebDriver BiDi server is started at runtime, Firefox restricts the session to a dedicated container (remote-control-container) if remote.experimental.dynamicstart.container-isolation-enabled is true (bug 2072964, bug 2081128). A restricted session only sees the tabs of the container, only supports a small set of commands, and requires explicit targets for some of them. See "Sessions restricted to a single user context" in remote/doc/webdriver-bidi/Extensions.md.

The MCP needs these changes to work with such a session, typically with --connect-existing:

  • Read the moz:userContext capability from the new session. If it is present, the session is restricted, and the value is the user context of the container.
  • session.subscribe: pass userContexts: [userContext] in a restricted session. Subscriptions without targets are rejected.
  • session.unsubscribe: unsubscribe by subscription id. Unsubscribing by event names only removes global subscriptions.
  • browser.setDownloadBehavior: pass userContexts: [userContext] in a restricted session.
  • network.addDataCollector: pass userContexts: [userContext] in a restricted session, so that request and response bodies can still be captured (needs the matching Firefox change).
  • Hide the tools which need commands that a restricted session rejects: debugging, profiler, prefs, privileged contexts, web extensions, print and the network cache tool. Send a tool list change notification once the restriction is known, and return a clear error if a hidden tool is called anyway.
  • Map the unsupported operation error to a clear message, for example "Not available when connected to an existing Firefox".

In unrestricted sessions, keep the current behavior (global subscriptions and settings, all tools).

The page tools still use WebDriver classic, which is not restricted, so they keep seeing all tabs until they are migrated to BiDi (see the dependencies of bug 2037070).

Points: --- → 5
Priority: -- → P2
Whiteboard: [webdriver:m22]
Blocks: 2082353

Scope reduced a bit, this bug focuses on commands which can be restricted at framework level, and the special cases which need individual fixes moves to Bug 2082353.

Points: 5 → 3
Component: WebDriver BiDi → Firefox MCP
Product: Remote Protocol → Developer Infrastructure
Summary: [firefox-devtools-mcp] Restrict events and global commands to a single container → [firefox-devtools-mcp] Call global commands with the proper user context in container restricted sessions

Waiting on Bug 2080973 and Bug 2080977: once they land, this bug will also pass the restricted user context to browsingContext.create, so new tabs open in the session's container.

Depends on: 2080973, 2080977
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: