mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-28 15:40:04 +00:00
Removes CDPT (generic CDP)
CDPT used to be a generic so that we could inject Browser, Session, Page and Client. At some point, it [thankfully] became a generic only to inject Client. This commit removes the generic and bakes the *Server.Client instance in CDP. It uses a socketpair for testing. BrowserContext is still generic, but that's generic for a very different reason and, while I'd like to remove that generic too, it belongs in a different PR.
This commit is contained in:
@@ -512,7 +512,7 @@ const TargetInfo = struct {
|
||||
|
||||
const testing = @import("../testing.zig");
|
||||
test "cdp.target: getBrowserContexts" {
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
|
||||
// {
|
||||
@@ -536,7 +536,7 @@ test "cdp.target: getBrowserContexts" {
|
||||
}
|
||||
|
||||
test "cdp.target: createBrowserContext" {
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
|
||||
{
|
||||
@@ -554,7 +554,7 @@ test "cdp.target: createBrowserContext" {
|
||||
}
|
||||
|
||||
test "cdp.target: disposeBrowserContext" {
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
|
||||
{
|
||||
@@ -585,7 +585,7 @@ test "cdp.target: disposeBrowserContext" {
|
||||
|
||||
test "cdp.target: createTarget" {
|
||||
{
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
try ctx.processMessage(.{ .id = 10, .method = "Target.createTarget", .params = .{ .url = "about:blank" } });
|
||||
|
||||
@@ -595,7 +595,7 @@ test "cdp.target: createTarget" {
|
||||
}
|
||||
|
||||
{
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
// active auto attach to get the Target.attachedToTarget event.
|
||||
try ctx.processMessage(.{ .id = 9, .method = "Target.setAutoAttach", .params = .{ .autoAttach = true, .waitForDebuggerOnStart = false } });
|
||||
@@ -607,7 +607,7 @@ test "cdp.target: createTarget" {
|
||||
try ctx.expectSentEvent("Target.attachedToTarget", .{ .sessionId = bc.session_id.?, .targetInfo = .{ .url = "about:blank", .title = "", .attached = true, .type = "page", .canAccessOpener = false, .browserContextId = bc.id, .targetId = bc.target_id.? } }, .{});
|
||||
}
|
||||
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
const bc = try ctx.loadBrowserContext(.{ .id = "BID-9" });
|
||||
{
|
||||
@@ -624,7 +624,7 @@ test "cdp.target: createTarget" {
|
||||
}
|
||||
|
||||
test "cdp.target: closeTarget" {
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
|
||||
{
|
||||
@@ -655,7 +655,7 @@ test "cdp.target: closeTarget" {
|
||||
}
|
||||
|
||||
test "cdp.target: attachToTarget" {
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
|
||||
{
|
||||
@@ -686,7 +686,7 @@ test "cdp.target: attachToTarget" {
|
||||
}
|
||||
|
||||
test "cdp.target: getTargetInfo" {
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
|
||||
{
|
||||
@@ -737,7 +737,7 @@ test "cdp.target: getTargetInfo" {
|
||||
}
|
||||
|
||||
test "cdp.target: issue#474: attach to just created target" {
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
const bc = try ctx.loadBrowserContext(.{ .id = "BID-9" });
|
||||
{
|
||||
@@ -752,7 +752,7 @@ test "cdp.target: issue#474: attach to just created target" {
|
||||
}
|
||||
|
||||
test "cdp.target: detachFromTarget" {
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
const bc = try ctx.loadBrowserContext(.{ .id = "BID-9" });
|
||||
{
|
||||
@@ -775,19 +775,19 @@ test "cdp.target: detachFromTarget" {
|
||||
}
|
||||
|
||||
test "cdp.target: detachFromTarget without session" {
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
_ = try ctx.loadBrowserContext(.{ .id = "BID-9" });
|
||||
{
|
||||
// detach when no session is attached should not send event
|
||||
try ctx.processMessage(.{ .id = 10, .method = "Target.detachFromTarget" });
|
||||
try ctx.expectSentResult(null, .{ .id = 10 });
|
||||
try ctx.expectSentCount(0);
|
||||
try ctx.expectSentCount(1);
|
||||
}
|
||||
}
|
||||
|
||||
test "cdp.target: setAutoAttach false sends detachedFromTarget" {
|
||||
var ctx = testing.context();
|
||||
var ctx = try testing.context();
|
||||
defer ctx.deinit();
|
||||
const bc = try ctx.loadBrowserContext(.{ .id = "BID-9" });
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user