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 WebKit BrowserType

From Leeroopedia

Template:Implementation Page

Overview

WebKit BrowserType is the browser type implementation for WebKit, handling browser launch configuration, transport connection, environment setup, and graceful shutdown specific to the WebKit browser engine.

Description

The WebKit class extends BrowserType and provides WebKit-specific overrides:

  • connectToTransport -- creates a WKBrowser instance from a connection transport
  • amendEnvironment -- sets WebKit-specific environment variables (e.g., CURL_COOKIE_JAR_PATH for persistent cookies on Windows)
  • doRewriteStartupLog -- detects X server errors and provides helpful messages
  • attemptToGracefullyCloseBrowser -- sends Playwright.close via the transport
  • defaultArgs -- builds command-line arguments for WebKit process launch including headless mode and user data directory

Usage

Instantiated once by the Playwright root object. Users interact with it via playwright.webkit.

Code Reference

Source Location

packages/playwright-core/src/server/webkit/webkit.ts (103 lines)

Class Signature

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

Import

import { WebKit } from './server/webkit/webkit';

I/O Contract

Inputs

  • parent: SdkObject -- parent SDK object (Playwright instance)
  • Launch options: headless mode, user data directory, executable path, arguments

Outputs

  • WKBrowser instance connected to the WebKit process
  • Command-line arguments array for launching WebKit

Related Pages

Page Connections

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