mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
emit context created on createTarget event for chromedp
This commit is contained in:
@@ -173,6 +173,10 @@ pub const Session = struct {
|
|||||||
const page = &self.page.?;
|
const page = &self.page.?;
|
||||||
try Page.init(page, page_arena.allocator(), self);
|
try Page.init(page, page_arena.allocator(), self);
|
||||||
|
|
||||||
|
self.notify(&.{ .context_created = .{
|
||||||
|
.origin = try page.origin(),
|
||||||
|
} });
|
||||||
|
|
||||||
// start JS env
|
// start JS env
|
||||||
log.debug("start new js scope", .{});
|
log.debug("start new js scope", .{});
|
||||||
|
|
||||||
|
|||||||
@@ -404,8 +404,8 @@ pub fn BrowserContext(comptime CDP_T: type) type {
|
|||||||
const self: *Self = @alignCast(@ptrCast(ctx));
|
const self: *Self = @alignCast(@ptrCast(ctx));
|
||||||
|
|
||||||
switch (notification.*) {
|
switch (notification.*) {
|
||||||
.context_created => |cc| {
|
.context_created => |cc| if (self.target_id) |target_id| {
|
||||||
const aux_data = try std.fmt.allocPrint(self.arena, "{{\"isDefault\":true,\"type\":\"default\",\"frameId\":\"{s}\"}}", .{self.target_id.?});
|
const aux_data = try std.fmt.allocPrint(self.arena, "{{\"isDefault\":true,\"type\":\"default\",\"frameId\":\"{s}\"}}", .{target_id});
|
||||||
self.inspector.contextCreated(
|
self.inspector.contextCreated(
|
||||||
self.session.page.?.scope,
|
self.session.page.?.scope,
|
||||||
"",
|
"",
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ fn createTarget(cmd: anytype) !void {
|
|||||||
const target_id = cmd.cdp.target_id_gen.next();
|
const target_id = cmd.cdp.target_id_gen.next();
|
||||||
|
|
||||||
try bc.createIsolatedWorld();
|
try bc.createIsolatedWorld();
|
||||||
|
bc.target_id = target_id;
|
||||||
|
|
||||||
_ = try bc.session.createPage();
|
_ = try bc.session.createPage();
|
||||||
|
|
||||||
@@ -149,8 +150,6 @@ fn createTarget(cmd: anytype) !void {
|
|||||||
try doAttachtoTarget(cmd, target_id);
|
try doAttachtoTarget(cmd, target_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bc.target_id = target_id;
|
|
||||||
|
|
||||||
try cmd.sendResult(.{
|
try cmd.sendResult(.{
|
||||||
.targetId = target_id,
|
.targetId = target_id,
|
||||||
}, .{});
|
}, .{});
|
||||||
|
|||||||
Reference in New Issue
Block a user