Open Bug 2095024 Opened 2 days ago Updated 1 day ago

[firefox-mcp] new_page fails after select_privileged_context

Categories

(Developer Infrastructure :: Firefox MCP, defect, P3)

defect

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file)

In the Mozilla-internal package, with MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1:

  1. navigate_page to any page
  2. list_privileged_contexts, then select_privileged_context with the chrome://browser/content/browser.xhtml context
  3. select_page with pageIdx: 0 (works)
  4. new_page with any URL

Result: new_page fails with BiDi error: "unknown error": TypeError: can't access property "browsingContext", webProgress is null. The new tab stays on about:blank, and the next evaluate_script runs in chrome://browser/content/browser.xhtml instead of a page.

Cause: select_privileged_context calls driver.setContext('chrome'), and nothing switches back to content:
https://github.com/mozilla/firefox-mcp/blob/main/src/tools/privileged-context.ts#L154-L165

new_page still uses WebDriver Classic to open the tab: switchTo().newWindow('tab'), then getWindowHandle() (src/firefox/pages.ts). In chrome scope, getWindowHandle() returns the chrome window, so the server selects it and navigates it with BiDi.

Confirmed locally: with the setContext('chrome') call removed, the same steps work. new_page opens and selects the new tab, and select_page and close_page still work.

The call is a leftover from before the WebDriver BiDi migration, when privileged scripts ran through Classic executeScript. No tool needs the Classic chrome context anymore: evaluate_privileged_script sends BiDi script.callFunction with an explicit target, and the prefs tools evaluate in the chrome context with BiDi.

Suggested fix:

  • Remove the setContext('chrome') call, and probably the Classic switchTo().window() call in the same handler. Keep setCurrentContextId().
  • Add an MCP harness test: select_privileged_context, then new_page, then evaluate_script returns the page URL.
Summary: [firefox-mcp] ]new_page fails after select_privileged_context → [firefox-mcp] new_page fails after select_privileged_context
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: