Merge pull request #441 from karlseguin/cdp_tests
Some checks are pending
e2e-test / zig build release (push) Waiting to run
e2e-test / puppeteer (push) Blocked by required conditions
wpt / web platform tests (push) Waiting to run
wpt / perf-fmt (push) Blocked by required conditions
zig-test / zig build dev (push) Waiting to run
zig-test / zig test (push) Waiting to run
zig-test / perf-fmt (push) Blocked by required conditions

Turn CDP into a generic so that mocks can be injected for testing
This commit is contained in:
Pierre Tachoire
2025-02-21 17:49:47 +01:00
committed by GitHub
5 changed files with 480 additions and 269 deletions

View File

@@ -638,7 +638,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;
},
@@ -1792,7 +1792,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;