/** * WebDriver BiDi types for Firefox */ export type BrowsingContextId = string; /** * BiDi browsing context (tab/window) */ export interface BrowsingContext { context: BrowsingContextId; url: string; title?: string; children?: BrowsingContext[]; parent?: BrowsingContextId; } /** * BiDi console log entry */ export interface ConsoleMessage { level: 'debug' | 'info' | 'warn' | 'error'; text: string; timestamp: number; source?: string; args?: unknown[]; /** * The browsing context that logged the message. Present since the capture * layer started recording it; leaving it off the type is what kept the tools * from filtering on something they were already being handed. */ context?: string; } /** * Combined network request+response record */ export interface NetworkRecord { id: string; url: string; method: string; timestamp: number; resourceType?: string; isXHR?: boolean; status?: number; statusText?: string; requestHeaders?: Record; responseHeaders?: Record; timings?: { requestTime?: number; responseTime?: number; duration?: number; }; } /** * Firefox launch options */ export interface FirefoxLaunchOptions { firefoxPath?: string | undefined; headless: boolean; profilePath?: string | undefined; viewport?: { width: number; height: number } | undefined; args?: string[] | undefined; startUrl?: string | undefined; acceptInsecureCerts?: boolean | undefined; connectExisting?: boolean | undefined; marionettePort?: number | undefined; env?: Record | undefined; logFile?: string | undefined; /** Firefox preferences to set at startup via moz:firefoxOptions */ prefs?: Record | undefined; } /** * BiDi command structure */ export interface BiDiCommand { id: number; method: string; params: Record; } /** * BiDi response structure */ export interface BiDiResponse { id?: number; result?: Record; error?: { error: string; message: string; stacktrace?: string; }; method?: string; params?: Record; } /** * BiDi error */ export class BiDiError extends Error { constructor( message: string, public code: string, public details?: unknown ) { super(message); this.name = 'BiDiError'; } }