Skip to content

Commit 2db43ee

Browse files
committed
cdp: add a Page.getFrameTree unit test
1 parent f0332db commit 2db43ee

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/cdp/page.zig

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,37 @@ fn navigate(cmd: anytype) !void {
262262
.frameId = bc.frame_id,
263263
}, .{ .session_id = session_id });
264264
}
265+
266+
const testing = @import("testing.zig");
267+
test "cdp.page: getFrameTree" {
268+
var ctx = testing.context();
269+
defer ctx.deinit();
270+
271+
{
272+
try testing.expectError(error.BrowserContextNotLoaded, ctx.processMessage(.{ .id = 10, .method = "Page.getFrameTree", .params = .{ .targetId = "X" } }));
273+
try ctx.expectSentError(-31998, "BrowserContextNotLoaded", .{ .id = 10 });
274+
}
275+
276+
const bc = try ctx.loadBrowserContext(.{ .id = "BID-9" });
277+
{
278+
try ctx.processMessage(.{ .id = 11, .method = "Page.getFrameTree" });
279+
try ctx.expectSentResult(.{
280+
.frameTree = .{
281+
.frame = .{
282+
.id = bc.frame_id,
283+
.loaderId = bc.loader_id,
284+
.url = bc.url,
285+
.domainAndRegistry = "",
286+
.securityOrigin = bc.security_origin,
287+
.mimeType = "text/html",
288+
.adFrameStatus = .{
289+
.adFrameType = "none",
290+
},
291+
.secureContextType = bc.secure_context_type,
292+
.crossOriginIsolatedContextType = "NotIsolated",
293+
.gatedAPIFeatures = [_][]const u8{},
294+
},
295+
},
296+
}, .{ .id = 11 });
297+
}
298+
}

0 commit comments

Comments
 (0)