# Which Chrome DevTools Protocol Domains Does Lightpanda Support? Complete Implementation Guide

> Discover the 17 Chrome DevTools Protocol domains Lightpanda supports including DOM, Page, Network, Runtime, and Fetch. Explore the implementation guide for full details.

- Repository: [Lightpanda/browser](https://github.com/lightpanda-io/browser)
- Tags: how-to-guide
- Published: 2026-03-14

---

**Lightpanda implements 17 Chrome DevTools Protocol domains including DOM, Page, Network, Runtime, and Fetch, with domain handlers located in `src/cdp/domains/` and a central dispatcher in `src/cdp/cdp.zig`.**

The **lightpanda-io/browser** repository provides a full-stack **Chrome DevTools Protocol (CDP)** engine written in Zig. Unlike headless Chrome implementations that merely wrap existing browser binaries, Lightpanda maintains native Zig implementations of individual CDP domains, enabling direct programmatic control over browser automation, DOM inspection, and network interception.

## Complete List of Supported CDP Domains

Lightpanda organizes each protocol domain as a standalone Zig module under **`src/cdp/domains/`**. The following table lists every supported **Chrome DevTools Protocol domain**, its purpose, and the corresponding implementation file:

| Domain | Purpose | Implementation File |
|--------|---------|---------------------|
| **LP** | Lightpanda-specific extensions (e.g., `lp.getMarkdown`) | `src/cdp/domains/lp.zig` |
| **DOM** | Document structure inspection and node manipulation | `src/cdp/domains/dom.zig` |
| **Log** | Browser console logging infrastructure | `src/cdp/domains/log.zig` |
| **CSS** | Computed and authored style retrieval | `src/cdp/domains/css.zig` |
| **Page** | Lifecycle management, navigation, and screenshots | `src/cdp/domains/page.zig` |
| **Fetch** | HTTP request interception and modification | `src/cdp/domains/fetch.zig` |
| **Input** | Mouse, keyboard, and touch device emulation | `src/cdp/domains/input.zig` |
| **Target** | Tab, window, and service worker management | `src/cdp/domains/target.zig` |
| **Browser** | Global browser control and context creation | `src/cdp/domains/browser.zig` |
| **Runtime** | JavaScript execution and context management | `src/cdp/domains/runtime.zig` |
| **Network** | HTTP traffic monitoring and cookie handling | `src/cdp/domains/network.zig` |
| **Storage** | localStorage, sessionStorage, and cookie persistence | `src/cdp/domains/storage.zig` |
| **Security** | Certificate handling and security state overrides | `src/cdp/domains/security.zig` |
| **Emulation** | Device metrics, geolocation, and user agent spoofing | `src/cdp/domains/emulation.zig` |
| **Inspector** | Debugger attachment and inspection utilities | `src/cdp/domains/inspector.zig` |
| **Performance** | Runtime profiling and timeline metrics | `src/cdp/domains/performance.zig` |
| **Accessibility** | Accessibility tree computation and auditing | `src/cdp/domains/accessibility.zig` |

These domains cover the essential surface area required for automated testing, web scraping, and debugging workflows compatible with standard Chrome DevTools clients.

## How Lightpanda Routes CDP Commands

Incoming CDP method calls route through the **`dispatchCommand`** function (lines 220–270) in **`src/cdp/cdp.zig`**. This dispatcher inspects the method name prefix—the domain identifier—to determine which module's `processMessage` routine receives the command.

For example, a command string `"Page.navigate"` triggers the **Page** domain handler in `src/cdp/domains/page.zig`, while `"Runtime.evaluate"` routes to the **Runtime** domain. This architecture allows domain-specific logic to remain encapsulated while maintaining a uniform JSON-RPC interface across all 17 supported domains.

## Practical CDP Usage Examples

The following Zig snippets demonstrate how to interact with Lightpanda's **Chrome DevTools Protocol domains** programmatically. These examples assume a `CDP` client instance obtained through Lightpanda's test context or a live WebSocket connection.

### Create a Browser Context and Navigate (Browser + Page Domains)

```zig
const std = @import("std");
const CDP = @import("cdp/cdp.zig");

var client = try CDP.TestContext.init();
defer client.deinit();
var cdp = client.cdp();

// Create isolated browser context
const ctx = try cdp.sendJSON(.{
    .method = "Browser.createBrowserContext",
    .params = .{},
});
std.debug.print("Context ID: {s}\n", .{ctx});

// Open new tab via Target domain
const target = try cdp.sendJSON(.{
    .method = "Target.createTarget",
    .params = .{ .url = "about:blank" },
});

// Navigate to URL via Page domain
try cdp.sendJSON(.{
    .method = "Page.navigate",
    .params = .{ .url = "https://example.com" },
});

```

### Capture a Screenshot (Page Domain)

```zig
const screenshot = try cdp.sendJSON(.{
    .method = "Page.captureScreenshot",
    .params = .{ .format = "png", .quality = 90 },
});
std.debug.print("Base64 screenshot length: {d}\n", .{screenshot.data.len});

```

### Intercept Network Requests (Fetch Domain)

```zig
// Enable request interception for all document requests
try cdp.sendJSON(.{
    .method = "Fetch.enable",
    .params = .{ .patterns = &[_]anytype{
        .{ .urlPattern = "*", .resourceType = "Document", .requestStage = "Request" },
    }},
});

// Handler for paused requests
pub fn onRequestPaused(ctx: *CDP.Context, params: anytype) void {
    const headers = [_]anytype{
        .{ .name = "X-Intercepted-By", .value = "Lightpanda" },
    };
    ctx.cdp.sendJSON(.{
        .method = "Fetch.continueRequest",
        .params = .{
            .requestId = params.requestId,
            .headers = &headers,
        },
    }) catch {};
}

```

### Evaluate JavaScript (Runtime Domain)

```zig
const result = try cdp.sendJSON(.{
    .method = "Runtime.evaluate",
    .params = .{ 
        .expression = "document.querySelector('h1').textContent",
        .returnByValue = true,
    },
});
std.debug.print("Heading text: {s}\n", .{result.result.value});

```

## Key Implementation Files

Beyond the domain handlers, several core files comprise Lightpanda's CDP architecture:

- **`src/cdp/cdp.zig`** — Central dispatcher and JSON-RPC message I/O.
- **`src/cdp/testing.zig`** — Test harness providing `TestContext` for unit tests.
- **`src/cdp/Node.zig`** and **`src/cdp/AXNode.zig`** — DOM and accessibility node models underlying the DOM and Accessibility domains.
- **`src/browser/Browser.zig`** and **`src/browser/Page.zig`** — High-level abstractions exposing CDP methods to the broader browser engine.

## Summary

- Lightpanda supports **17 Chrome DevTools Protocol domains** including standard Chrome domains (Page, Network, Runtime) and a custom **LP** domain.
- Domain implementations reside in **`src/cdp/domains/*.zig`**, with each file handling one protocol domain.
- The **`dispatchCommand`** function in `src/cdp/cdp.zig` (lines 220–270) routes incoming CDP method calls to the appropriate domain handler.
- Lightpanda is compatible with standard CDP clients, allowing you to use existing Chrome DevTools tooling or programmatic libraries.

## Frequently Asked Questions

### How many Chrome DevTools Protocol domains does Lightpanda implement?

Lightpanda implements **17 CDP domains**: Browser, Target, Page, DOM, CSS, Runtime, Network, Storage, Fetch, Input, Security, Emulation, Inspector, Log, Performance, Accessibility, and a Lightpanda-specific LP domain for custom functionality.

### Where does Lightpanda route incoming CDP commands?

Command routing occurs in the **`dispatchCommand`** function within **`src/cdp/cdp.zig`** (approximately lines 220–270). This function parses the method name prefix to determine which domain handler's `processMessage` function receives the call.

### Can I use standard Chrome DevTools clients with Lightpanda?

Yes. Because Lightpanda implements standard **Chrome DevTools Protocol domains** using the same method signatures and JSON-RPC format as Chrome, existing CDP clients (Puppeteer, Playwright, or Chrome DevTools itself) can connect to Lightpanda's CDP endpoint.

### How do I add a new CDP domain to Lightpanda?

Create a new Zig file under **`src/cdp/domains/`** implementing the domain's `processMessage` routine, then register the domain in the **`dispatchCommand`** switch statement within `src/cdp/cdp.zig` to handle the new domain prefix.