Implementation:Microsoft Playwright FfExecutionContext
Overview
FFExecutionContext implements the JavaScript execution context delegate for Firefox, enabling expression evaluation and function calls within Firefox browser pages through the Juggler protocol.
Description
The FFExecutionContext class implements js.ExecutionContextDelegate, providing the bridge between Playwright's abstract execution context API and Firefox's Runtime domain. It supports evaluating expressions for JSON values or object handles, calling functions with arguments, and managing remote object references. Error handling translates Firefox-specific exceptions into Playwright errors.
Usage
Created internally by the Firefox page implementation when new execution contexts are established in frames or workers.
Code Reference
Source Location
packages/playwright-core/src/server/firefox/ffExecutionContext.ts (145 lines)
Class Signature
export class FFExecutionContext implements js.ExecutionContextDelegate {
constructor(session: FFSession, executionContextId: string)
async rawEvaluateJSON(expression: string): Promise<any>
async rawEvaluateHandle(context: js.ExecutionContext, expression: string): Promise<js.JSHandle>
async evaluateWithArguments(expression: string, returnByValue: boolean, utilityScript: js.JSHandle, values: any[], handles: js.JSHandle[]): Promise<any>
}
Import
import { FFExecutionContext } from './server/firefox/ffExecutionContext';
I/O Contract
Inputs
session: FFSession-- the Firefox protocol sessionexecutionContextId: string-- identifier for the execution context within Firefox
Outputs
- Returns evaluated JSON values or
JSHandlereferences to remote objects - Throws JavaScript evaluation errors with rewritten messages
Usage Examples
Evaluating an Expression
const context = new FFExecutionContext(session, contextId);
const result = await context.rawEvaluateJSON('document.title');
Related Pages
- Microsoft_Playwright_FfConnection -- Firefox connection and session management
- Microsoft_Playwright_WkExecutionContext -- WebKit equivalent implementation