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 CrDevTools

From Leeroopedia
Revision as of 11:36, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Microsoft_Playwright_CrDevTools.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Chromium, DevTools
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete tool for intercepting and persisting Chrome DevTools preferences via runtime bindings provided by the Playwright library.

Description

The `CRDevTools` class intercepts preferences-related DevTools embedder methods through a Chrome Runtime binding (`__pw_devtools__`) and stores preferences as a JSON file at a specified path in the browser installation directory. It supports `getPreferences`, `setPreference`, `removePreference`, and `clearPreferences` methods. The class lazily loads preferences from disk on first access and batches write operations through a promise chain (`_savePromise`) to avoid concurrent file writes. It also installs a JavaScript snippet into the DevTools page that overrides the `InspectorFrontendHost` methods to route through the binding.

Usage

Use CrDevTools when Playwright opens DevTools alongside an automated browser and needs to persist user preferences (like dark mode, panel layouts) across sessions.

Code Reference

Source Location

Signature

export class CRDevTools {
  constructor(preferencesPath: string);
  install(session: CRSession): void;
}

Import

import { CRDevTools } from '../server/chromium/crDevTools';

I/O Contract

Inputs

Name Type Required Description
preferencesPath string Yes File system path where DevTools preferences are stored as JSON
session CRSession Yes CDP session for the DevTools target

Outputs

Name Type Description
(side effect) void Installs runtime binding and overrides DevTools preference methods

Usage Examples

import { CRDevTools } from '../server/chromium/crDevTools';

const devtools = new CRDevTools('/path/to/browser/devtools-preferences.json');
devtools.install(devToolsSession);
// DevTools preferences will now be persisted to the specified file

Related Pages

Page Connections

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