Implementation:Microsoft Playwright WebKit BrowserType
Appearance
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 aWKBrowserinstance from a connection transportamendEnvironment-- sets WebKit-specific environment variables (e.g.,CURL_COOKIE_JAR_PATHfor persistent cookies on Windows)doRewriteStartupLog-- detects X server errors and provides helpful messagesattemptToGracefullyCloseBrowser-- sendsPlaywright.closevia the transportdefaultArgs-- 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
WKBrowserinstance connected to the WebKit process- Command-line arguments array for launching WebKit
Related Pages
- Microsoft_Playwright_Server_Playwright -- Root object holding WebKit browser type
- Microsoft_Playwright_WkConnection -- WebKit protocol connection
- Microsoft_Playwright_WkInput -- WebKit input handling
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment