Skip to content

Lightpanda: the headless browser designed for AI and automation

expose LP.version including Lightpanda's version

Pierre Tachoire447a34036651
diff --git a/src/cdp/domains/lp.zig b/src/cdp/domains/lp.zig
index be69776be..0a8b1371e 100644
--- a/src/cdp/domains/lp.zig
+++ b/src/cdp/domains/lp.zig
@@ -45,6 +45,7 @@ pub fn processMessage(cmd: *CDP.Command) !void {
waitForSelector,
handleJavaScriptDialog,
configureLoading,
+ version,
}, cmd.input.action) orelse return error.UnknownMethod;
switch (action) {
@@ -61,9 +62,16 @@ pub fn processMessage(cmd: *CDP.Command) !void {
.waitForSelector => return waitForSelector(cmd),
.handleJavaScriptDialog => return handleJavaScriptDialog(cmd),
.configureLoading => return configureLoading(cmd),
+ .version => return version(cmd),
}
}
+fn version(cmd: *CDP.Command) !void {
+ return cmd.sendResult(.{
+ .version = lp.build_config.version,
+ }, .{});
+}
+
fn configureLoading(cmd: *CDP.Command) !void {
// Each field is optional so callers can flip one without resetting
// the other to its default. Backwards-compatible: existing callers
@@ -386,6 +394,19 @@ fn handleJavaScriptDialog(cmd: anytype) !void {
}
const testing = @import("../testing.zig");
+test "cdp.lp: version" {
+ var ctx = try testing.context();
+ defer ctx.deinit();
+
+ try ctx.processMessage(.{
+ .id = 1,
+ .method = "LP.version",
+ });
+
+ const result = (try ctx.getSentMessage(0)).?.object.get("result").?.object;
+ try testing.expectEqualSlices(u8, lp.build_config.version, result.get("version").?.string);
+}
+
test "cdp.lp: getMarkdown" {
var ctx = try testing.context();
defer ctx.deinit();