Make CDP frame-aware

This commit is contained in:
Karl Seguin
2026-02-18 12:17:22 +08:00
parent 815319140f
commit bb01a5cb31
2 changed files with 10 additions and 8 deletions

View File

@@ -1210,7 +1210,7 @@ pub fn iframeAddedCallback(self: *Page, iframe: *Element.Html.IFrame) !void {
page_frame.iframe = iframe;
iframe._content_window = page_frame.window;
page_frame.navigate(src, .{}) catch |err| {
page_frame.navigate(src, .{.reason = .initialFrameNavigation}) catch |err| {
log.warn(.page, "iframe navigate failure", .{ .url = src, .err = err });
self._pending_loads -= 1;
iframe._content_window = null;
@@ -3119,6 +3119,7 @@ pub const NavigateReason = enum {
script,
history,
navigation,
initialFrameNavigation,
};
pub const NavigateOpts = struct {

View File

@@ -252,13 +252,14 @@ pub fn pageNavigate(bc: anytype, event: *const Notification.PageNavigate) !void
.address_bar => null,
};
if (reason_) |reason| {
try cdp.sendEvent("Page.frameScheduledNavigation", .{
.frameId = frame_id,
.delay = 0,
.reason = reason,
.url = event.url,
}, .{ .session_id = session_id });
if (reason != .initialFrameNavigation) {
try cdp.sendEvent("Page.frameScheduledNavigation", .{
.frameId = frame_id,
.delay = 0,
.reason = reason,
.url = event.url,
}, .{ .session_id = session_id });
}
try cdp.sendEvent("Page.frameRequestedNavigation", .{
.frameId = frame_id,
.reason = reason,