mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
No need to navigate to about:blank
This commit is contained in:
@@ -125,9 +125,6 @@ fn createTarget(cmd: anytype) !void {
|
|||||||
bc.target_id = target_id;
|
bc.target_id = target_id;
|
||||||
|
|
||||||
var page = try bc.session.createPage();
|
var page = try bc.session.createPage();
|
||||||
// Navigate to about:blank such that the window.document are created and set
|
|
||||||
const url = @import("../../url.zig").URL.about_blank;
|
|
||||||
try page.navigate(url, .{});
|
|
||||||
{
|
{
|
||||||
const aux_data = try std.fmt.allocPrint(cmd.arena, "{{\"isDefault\":true,\"type\":\"default\",\"frameId\":\"{s}\"}}", .{target_id});
|
const aux_data = try std.fmt.allocPrint(cmd.arena, "{{\"isDefault\":true,\"type\":\"default\",\"frameId\":\"{s}\"}}", .{target_id});
|
||||||
bc.inspector.contextCreated(
|
bc.inspector.contextCreated(
|
||||||
@@ -504,10 +501,6 @@ test "cdp.target: createTarget" {
|
|||||||
// should create a browser context
|
// should create a browser context
|
||||||
const bc = ctx.cdp().browser_context.?;
|
const bc = ctx.cdp().browser_context.?;
|
||||||
try ctx.expectSentEvent("Target.targetCreated", .{ .targetInfo = .{ .url = "about:blank", .title = "about:blank", .attached = false, .type = "page", .canAccessOpener = false, .browserContextId = bc.id, .targetId = bc.target_id.? } }, .{});
|
try ctx.expectSentEvent("Target.targetCreated", .{ .targetInfo = .{ .url = "about:blank", .title = "about:blank", .attached = false, .type = "page", .canAccessOpener = false, .browserContextId = bc.id, .targetId = bc.target_id.? } }, .{});
|
||||||
|
|
||||||
// Even about:blank should set the window.document
|
|
||||||
const page = ctx.cdp().browser_context.?.session.page.?;
|
|
||||||
try testing.expect(page.window.document != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ const TestContext = struct {
|
|||||||
if (bc.session_id == null) bc.session_id = "SID-X";
|
if (bc.session_id == null) bc.session_id = "SID-X";
|
||||||
parser.deinit();
|
parser.deinit();
|
||||||
const page = try bc.session.createPage();
|
const page = try bc.session.createPage();
|
||||||
page.doc = (try Document.init(html)).doc;
|
page.window.document = (try Document.init(html)).doc;
|
||||||
}
|
}
|
||||||
return bc;
|
return bc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ pub const Random = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub const Document = struct {
|
pub const Document = struct {
|
||||||
doc: *parser.Document,
|
doc: *parser.DocumentHTML,
|
||||||
arena: std.heap.ArenaAllocator,
|
arena: std.heap.ArenaAllocator,
|
||||||
|
|
||||||
pub fn init(html: []const u8) !Document {
|
pub fn init(html: []const u8) !Document {
|
||||||
@@ -219,7 +219,7 @@ pub const Document = struct {
|
|||||||
|
|
||||||
return .{
|
return .{
|
||||||
.arena = std.heap.ArenaAllocator.init(allocator),
|
.arena = std.heap.ArenaAllocator.init(allocator),
|
||||||
.doc = parser.documentHTMLToDocument(html_doc),
|
.doc = html_doc,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ pub const Document = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn asNode(self: *const Document) *parser.Node {
|
pub fn asNode(self: *const Document) *parser.Node {
|
||||||
return parser.documentToNode(self.doc);
|
return parser.documentHTMLToNode(self.doc);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user