Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Playwright BidiFirefox

From Leeroopedia
Knowledge Sources
Domains BiDi, Firefox
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete tool for launching and connecting to Firefox browsers using the WebDriver BiDi protocol provided by the Playwright library.

Description

The `BidiFirefox` class extends `BrowserType` to implement Firefox-specific browser launching via the native BiDi protocol (Firefox supports BiDi natively, unlike Chromium). It configures Firefox preferences via `createProfile`, handles Firefox-specific environment requirements (absolute home directory, `SNAP_NAME`, `MOZ_DISABLE_GMP_SANDBOX`), creates temporary profile directories, and manages the BiDi connection lifecycle. The class rewrites common startup errors (root session issues, missing DISPLAY) into user-friendly messages.

Usage

Use BidiFirefox when launching Firefox through Playwright. This is the primary BrowserType implementation for Firefox in Playwright, using Firefox's native WebDriver BiDi support.

Code Reference

Source Location

Signature

export class BidiFirefox extends BrowserType {
  constructor(parent: SdkObject);
  override executablePath(): string;
  override async connectToTransport(transport: ConnectionTransport, options: BrowserOptions): Promise<BidiBrowser>;
  override doRewriteStartupLog(logs: string): string;
  override amendEnvironment(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
  override defaultArgs(options: types.LaunchOptions, isPersistent: boolean, userDataDir: string): string[];
}

Import

import { BidiFirefox } from '../server/bidi/bidiFirefox';

I/O Contract

Inputs

Name Type Required Description
parent SdkObject Yes Parent SDK object for instrumentation
transport ConnectionTransport Yes Raw transport to the Firefox process
options BrowserOptions Yes Browser launch configuration
env NodeJS.ProcessEnv Yes Environment variables to amend for Firefox

Outputs

Name Type Description
browser BidiBrowser Connected BidiBrowser instance for Firefox
args string[] Firefox command-line arguments for launching
env NodeJS.ProcessEnv Amended environment variables

Usage Examples

import { BidiFirefox } from '../server/bidi/bidiFirefox';

const bidiFirefox = new BidiFirefox(playwrightSdkObject);
const args = bidiFirefox.defaultArgs(launchOptions, false, '/tmp/firefox-profile');
const browser = await bidiFirefox.connectToTransport(transport, browserOptions);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment