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 FfExecutionContext

From Leeroopedia

Template:Implementation Page

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 session
  • executionContextId: string -- identifier for the execution context within Firefox

Outputs

  • Returns evaluated JSON values or JSHandle references 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

Page Connections

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