mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-05 14:57:11 +00:00
cdp: return a valide response for Page.getFrameTree on STARTUP
Stagehand expects a valid response for this specific command. Add also `Target.activateTarget`
This commit is contained in:
@@ -36,6 +36,7 @@ pub fn processMessage(cmd: anytype) !void {
|
||||
sendMessageToTarget,
|
||||
setAutoAttach,
|
||||
setDiscoverTargets,
|
||||
activateTarget,
|
||||
}, cmd.input.action) orelse return error.UnknownMethod;
|
||||
|
||||
switch (action) {
|
||||
@@ -51,14 +52,16 @@ pub fn processMessage(cmd: anytype) !void {
|
||||
.sendMessageToTarget => return sendMessageToTarget(cmd),
|
||||
.setAutoAttach => return setAutoAttach(cmd),
|
||||
.setDiscoverTargets => return setDiscoverTargets(cmd),
|
||||
.activateTarget => return cmd.sendResult(null, .{}),
|
||||
}
|
||||
}
|
||||
|
||||
fn getTargets(cmd: anytype) !void {
|
||||
// Some clients like Stagehand expects to have an existing context.
|
||||
const bc = cmd.browser_context orelse cmd.createBrowserContext() catch |err| switch (err) {
|
||||
error.AlreadyExists => unreachable,
|
||||
else => return err,
|
||||
// If no context available, return an empty array.
|
||||
const bc = cmd.browser_context orelse {
|
||||
return cmd.sendResult(.{
|
||||
.targetInfos = [_]TargetInfo{},
|
||||
}, .{ .include_session_id = false });
|
||||
};
|
||||
|
||||
const target_id = bc.target_id orelse {
|
||||
|
||||
Reference in New Issue
Block a user