Removes CDPT (generic CDP)

CDPT used to be a generic so that we could inject Browser, Session, Page and
Client. At some point, it [thankfully] became a generic only to inject Client.

This commit removes the generic and bakes the *Server.Client instance in CDP.
It uses a socketpair for testing.

BrowserContext is still generic, but that's generic for a very different reason
and, while I'd like to remove that generic too, it belongs in a different PR.
This commit is contained in:
Karl Seguin
2026-03-25 17:43:30 +08:00
parent d517488158
commit 0dd0495ab8
14 changed files with 456 additions and 396 deletions

View File

@@ -27,7 +27,7 @@ const ArenaAllocator = std.heap.ArenaAllocator;
const log = @import("log.zig");
const App = @import("App.zig");
const Config = @import("Config.zig");
const CDP = @import("cdp/cdp.zig").CDP;
const CDP = @import("cdp/CDP.zig");
const Net = @import("network/websocket.zig");
const HttpClient = @import("browser/HttpClient.zig");
@@ -212,7 +212,7 @@ pub const Client = struct {
http: *HttpClient,
ws: Net.WsConnection,
fn init(
pub fn init(
socket: posix.socket_t,
allocator: Allocator,
app: *App,
@@ -250,7 +250,7 @@ pub const Client = struct {
self.ws.shutdown();
}
fn deinit(self: *Client) void {
pub fn deinit(self: *Client) void {
switch (self.mode) {
.cdp => |*cdp| cdp.deinit(),
.http => {},
@@ -461,7 +461,7 @@ pub const Client = struct {
fn upgradeConnection(self: *Client, request: []u8) !void {
try self.ws.upgrade(request);
self.mode = .{ .cdp = try CDP.init(self.app, self.http, self) };
self.mode = .{ .cdp = try CDP.init(self) };
}
fn writeHTTPErrorResponse(self: *Client, comptime status: u16, comptime body: []const u8) void {