cdp: ctx state has init and deinit now

This commit is contained in:
Pierre Tachoire
2025-02-06 17:17:44 +01:00
parent 8b22313ca1
commit 39b3786776
3 changed files with 37 additions and 1 deletions

View File

@@ -69,13 +69,17 @@ pub const Ctx = struct {
last_active: ?std.time.Instant = null,
// CDP
state: cdp.State = .{},
state: cdp.State = undefined,
// JS fields
browser: *Browser, // TODO: is pointer mandatory here?
sessionNew: bool,
// try_catch: jsruntime.TryCatch, // TODO
pub fn deinit(self: *Ctx) void {
self.state.deinit();
}
// callbacks
// ---------
@@ -458,7 +462,10 @@ pub fn handle(
.accept_completion = &accept_completion,
.conn_completion = &conn_completion,
.timeout_completion = &timeout_completion,
.state = cdp.State.init(browser.session.alloc),
};
defer ctx.deinit();
try browser.session.initInspector(
&ctx,
Ctx.onInspectorResp,