mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 07:31:47 +00:00
Handle CDP messages with different order
The 'method' still needs to be the first or the second key (in this case after the 'id'). Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
@@ -4,7 +4,7 @@ const server = @import("../server.zig");
|
||||
const Ctx = server.Cmd;
|
||||
const cdp = @import("cdp.zig");
|
||||
const result = cdp.result;
|
||||
const getParams = cdp.getParams;
|
||||
const getMsg = cdp.getMsg;
|
||||
const stringify = cdp.stringify;
|
||||
|
||||
const EmulationMethods = enum {
|
||||
@@ -15,7 +15,7 @@ const EmulationMethods = enum {
|
||||
|
||||
pub fn emulation(
|
||||
alloc: std.mem.Allocator,
|
||||
id: u64,
|
||||
id: ?u16,
|
||||
action: []const u8,
|
||||
scanner: *std.json.Scanner,
|
||||
ctx: *Ctx,
|
||||
@@ -36,26 +36,26 @@ const MediaFeature = struct {
|
||||
|
||||
fn setEmulatedMedia(
|
||||
alloc: std.mem.Allocator,
|
||||
id: u64,
|
||||
id: ?u16,
|
||||
scanner: *std.json.Scanner,
|
||||
_: *Ctx,
|
||||
) ![]const u8 {
|
||||
|
||||
// input
|
||||
const Params = struct {
|
||||
media: ?[]const u8 = null,
|
||||
features: ?[]MediaFeature = null,
|
||||
};
|
||||
_ = try getParams(alloc, Params, scanner);
|
||||
const sessionID = try cdp.getSessionID(scanner);
|
||||
const msg = try getMsg(alloc, Params, scanner);
|
||||
|
||||
// output
|
||||
// TODO: dummy
|
||||
return result(alloc, id, null, null, sessionID);
|
||||
return result(alloc, id orelse msg.id.?, null, null, msg.sessionID);
|
||||
}
|
||||
|
||||
fn setFocusEmulationEnabled(
|
||||
alloc: std.mem.Allocator,
|
||||
id: u64,
|
||||
id: ?u16,
|
||||
scanner: *std.json.Scanner,
|
||||
_: *Ctx,
|
||||
) ![]const u8 {
|
||||
@@ -64,24 +64,23 @@ fn setFocusEmulationEnabled(
|
||||
const Params = struct {
|
||||
enabled: bool,
|
||||
};
|
||||
_ = try getParams(alloc, Params, scanner);
|
||||
const sessionID = try cdp.getSessionID(scanner);
|
||||
const msg = try getMsg(alloc, Params, scanner);
|
||||
|
||||
// output
|
||||
// TODO: dummy
|
||||
return result(alloc, id, null, null, sessionID);
|
||||
return result(alloc, id orelse msg.id.?, null, null, msg.sessionID);
|
||||
}
|
||||
|
||||
fn setDeviceMetricsOverride(
|
||||
alloc: std.mem.Allocator,
|
||||
id: u64,
|
||||
id: ?u16,
|
||||
scanner: *std.json.Scanner,
|
||||
_: *Ctx,
|
||||
) ![]const u8 {
|
||||
|
||||
// input
|
||||
const content = try cdp.getContent(alloc, void, scanner);
|
||||
const msg = try cdp.getMsg(alloc, void, scanner);
|
||||
|
||||
// output
|
||||
return result(alloc, id, null, null, content.sessionID);
|
||||
return result(alloc, id orelse msg.id.?, null, null, msg.sessionID);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user