Turn CDP into a generic so that mocks can be injected for testing

ADD CDP testing helpers (mock Browser, Session, Page and Client). These are
placeholders until tests are added which use them.

Added a couple CDP tests.
This commit is contained in:
Karl Seguin
2025-02-21 13:17:35 +08:00
parent 09505dba09
commit 99fb82e244
5 changed files with 480 additions and 269 deletions

View File

@@ -592,7 +592,7 @@ fn ClientT(comptime S: type, comptime C: type) type {
self.server.queueClose(self.socket);
return false;
},
.text, .binary => if (self.cdp.?.processMessage(msg.data) == false) {
.text, .binary => if (self.cdp.?.handleMessage(msg.data) == false) {
self.close(null);
return false;
},
@@ -1747,7 +1747,7 @@ const MockCDP = struct {
self.messages.deinit(allocator);
}
fn processMessage(self: *MockCDP, message: []const u8) bool {
fn handleMessage(self: *MockCDP, message: []const u8) bool {
const owned = self.allocator.dupe(u8, message) catch unreachable;
self.messages.append(self.allocator, owned) catch unreachable;
return true;