mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
cdp: fix some id inconsitency accross runtime messages
This commit is contained in:
@@ -121,6 +121,7 @@ pub fn dispatch(
|
|||||||
pub const State = struct {
|
pub const State = struct {
|
||||||
executionContextId: u32 = 0,
|
executionContextId: u32 = 0,
|
||||||
contextID: ?[]const u8 = null,
|
contextID: ?[]const u8 = null,
|
||||||
|
sessionID: ?[]const u8 = null,
|
||||||
frameID: []const u8 = FrameID,
|
frameID: []const u8 = FrameID,
|
||||||
url: []const u8 = URLBase,
|
url: []const u8 = URLBase,
|
||||||
securityOrigin: []const u8 = URLBase,
|
securityOrigin: []const u8 = URLBase,
|
||||||
|
|||||||
@@ -129,13 +129,11 @@ fn sendInspector(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.sendInspector(msg.json);
|
|
||||||
|
|
||||||
if (method == .enable) {
|
if (method == .enable) {
|
||||||
try executionContextCreated(
|
try executionContextCreated(
|
||||||
alloc,
|
alloc,
|
||||||
ctx,
|
ctx,
|
||||||
0,
|
1,
|
||||||
"://",
|
"://",
|
||||||
"",
|
"",
|
||||||
// TODO: hard coded ID
|
// TODO: hard coded ID
|
||||||
@@ -147,10 +145,12 @@ fn sendInspector(
|
|||||||
.frameId = cdp.FrameID,
|
.frameId = cdp.FrameID,
|
||||||
},
|
},
|
||||||
// TODO: hard coded ID
|
// TODO: hard coded ID
|
||||||
target.BrowserContextID,
|
msg.sessionId orelse target.BrowserContextID,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.sendInspector(msg.json);
|
||||||
|
|
||||||
if (msg.id == null) return "";
|
if (msg.id == null) return "";
|
||||||
|
|
||||||
return result(alloc, msg.id.?, null, null, msg.sessionId);
|
return result(alloc, msg.id.?, null, null, msg.sessionId);
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ fn setAutoAttach(
|
|||||||
.sessionId = cdp.BrowserSessionID,
|
.sessionId = cdp.BrowserSessionID,
|
||||||
.targetInfo = .{
|
.targetInfo = .{
|
||||||
.targetId = PageTargetID,
|
.targetId = PageTargetID,
|
||||||
.title = "New Incognito tab",
|
.title = "about:blank",
|
||||||
.url = cdp.URLBase,
|
.url = cdp.URLBase,
|
||||||
.browserContextId = BrowserContextID,
|
.browserContextId = BrowserContextID,
|
||||||
},
|
},
|
||||||
@@ -171,8 +171,8 @@ fn attachToTarget(
|
|||||||
const attached = AttachToTarget{
|
const attached = AttachToTarget{
|
||||||
.sessionId = cdp.BrowserSessionID,
|
.sessionId = cdp.BrowserSessionID,
|
||||||
.targetInfo = .{
|
.targetInfo = .{
|
||||||
.targetId = PageTargetID,
|
.targetId = input.params.targetId,
|
||||||
.title = "New Incognito tab",
|
.title = "about:blank",
|
||||||
.url = cdp.URLBase,
|
.url = cdp.URLBase,
|
||||||
.browserContextId = BrowserContextID,
|
.browserContextId = BrowserContextID,
|
||||||
},
|
},
|
||||||
@@ -185,7 +185,7 @@ fn attachToTarget(
|
|||||||
sessionId: []const u8,
|
sessionId: []const u8,
|
||||||
};
|
};
|
||||||
const output = SessionId{
|
const output = SessionId{
|
||||||
.sessionId = input.sessionId orelse BrowserContextID,
|
.sessionId = input.sessionId orelse cdp.BrowserSessionID,
|
||||||
};
|
};
|
||||||
return result(alloc, input.id, SessionId, output, null);
|
return result(alloc, input.id, SessionId, output, null);
|
||||||
}
|
}
|
||||||
@@ -342,6 +342,7 @@ fn createTarget(
|
|||||||
ctx.state.securityOrigin = "://";
|
ctx.state.securityOrigin = "://";
|
||||||
ctx.state.secureContextType = "InsecureScheme";
|
ctx.state.secureContextType = "InsecureScheme";
|
||||||
ctx.state.loaderID = LoaderID;
|
ctx.state.loaderID = LoaderID;
|
||||||
|
ctx.state.sessionID = msg.sessionId;
|
||||||
|
|
||||||
// send targetCreated event
|
// send targetCreated event
|
||||||
const created = TargetCreated{
|
const created = TargetCreated{
|
||||||
@@ -361,9 +362,10 @@ fn createTarget(
|
|||||||
.sessionId = cdp.ContextSessionID,
|
.sessionId = cdp.ContextSessionID,
|
||||||
.targetInfo = .{
|
.targetInfo = .{
|
||||||
.targetId = ctx.state.frameID,
|
.targetId = ctx.state.frameID,
|
||||||
.title = "",
|
.title = "about:blank",
|
||||||
.url = ctx.state.url,
|
.url = ctx.state.url,
|
||||||
.browserContextId = input.params.browserContextId orelse ContextID,
|
.browserContextId = input.params.browserContextId orelse ContextID,
|
||||||
|
.attached = true,
|
||||||
},
|
},
|
||||||
.waitingForDebugger = true,
|
.waitingForDebugger = true,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ pub const Ctx = struct {
|
|||||||
const s = try std.fmt.allocPrint(
|
const s = try std.fmt.allocPrint(
|
||||||
allocator,
|
allocator,
|
||||||
tpl,
|
tpl,
|
||||||
.{ msg_open, cdp.ContextSessionID },
|
.{ msg_open, ctx.state.sessionID orelse cdp.ContextSessionID },
|
||||||
);
|
);
|
||||||
|
|
||||||
try ctx.send(s);
|
try ctx.send(s);
|
||||||
|
|||||||
Reference in New Issue
Block a user