mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
Internal navigation should change the CDP loader-id
This is one of the ways that puppeteer knows that navigation happened and is needed to support `waitForNavigation` which compares the existing loader-id with the new one, so it has to change. Also, fix a crash that could happen if CDP disconnects while connections are being aborted.
This commit is contained in:
@@ -1369,9 +1369,7 @@ test "Browser.HTML.HtmlInputElement.propeties.form" {
|
|||||||
|
|
||||||
try runner.testCases(&.{
|
try runner.testCases(&.{
|
||||||
.{ "let elem_input = document.querySelector('input')", null },
|
.{ "let elem_input = document.querySelector('input')", null },
|
||||||
}, .{});
|
.{ "elem_input.form", "[object HTMLFormElement]" }, // Initial value
|
||||||
try runner.testCases(&.{.{ "elem_input.form", "[object HTMLFormElement]" }}, .{}); // Initial value
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "elem_input.form = 'foo'", null },
|
.{ "elem_input.form = 'foo'", null },
|
||||||
.{ "elem_input.form", "[object HTMLFormElement]" }, // Invalid
|
.{ "elem_input.form", "[object HTMLFormElement]" }, // Invalid
|
||||||
}, .{});
|
}, .{});
|
||||||
|
|||||||
@@ -85,13 +85,15 @@ fn putAssumeCapacity(headers: *std.ArrayListUnmanaged(std.http.Header), extra: s
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn httpRequestFail(arena: Allocator, bc: anytype, request: *const Notification.RequestFail) !void {
|
pub fn httpRequestFail(arena: Allocator, bc: anytype, request: *const Notification.RequestFail) !void {
|
||||||
|
// It's possible that the request failed because we aborted when the client
|
||||||
|
// sent Target.closeTarget. In that case, bc.session_id will be cleared
|
||||||
|
// already, and we can skip sending these messages to the client.
|
||||||
|
const session_id = bc.session_id orelse return;
|
||||||
|
|
||||||
// Isn't possible to do a network request within a Browser (which our
|
// Isn't possible to do a network request within a Browser (which our
|
||||||
// notification is tied to), without a page.
|
// notification is tied to), without a page.
|
||||||
std.debug.assert(bc.session.page != null);
|
std.debug.assert(bc.session.page != null);
|
||||||
|
|
||||||
// all unreachable because we _have_ to have a page.
|
|
||||||
const session_id = bc.session_id orelse unreachable;
|
|
||||||
|
|
||||||
// We're missing a bunch of fields, but, for now, this seems like enough
|
// We're missing a bunch of fields, but, for now, this seems like enough
|
||||||
try bc.cdp.sendEvent("Network.loadingFailed", .{
|
try bc.cdp.sendEvent("Network.loadingFailed", .{
|
||||||
.requestId = try std.fmt.allocPrint(arena, "REQ-{d}", .{request.id}),
|
.requestId = try std.fmt.allocPrint(arena, "REQ-{d}", .{request.id}),
|
||||||
|
|||||||
@@ -163,6 +163,11 @@ pub fn pageNavigate(arena: Allocator, bc: anytype, event: *const Notification.Pa
|
|||||||
std.debug.assert(bc.session.page != null);
|
std.debug.assert(bc.session.page != null);
|
||||||
|
|
||||||
var cdp = bc.cdp;
|
var cdp = bc.cdp;
|
||||||
|
|
||||||
|
if (event.opts.reason != .address_bar) {
|
||||||
|
bc.loader_id = bc.cdp.loader_id_gen.next();
|
||||||
|
}
|
||||||
|
|
||||||
const loader_id = bc.loader_id;
|
const loader_id = bc.loader_id;
|
||||||
const target_id = bc.target_id orelse unreachable;
|
const target_id = bc.target_id orelse unreachable;
|
||||||
const session_id = bc.session_id orelse unreachable;
|
const session_id = bc.session_id orelse unreachable;
|
||||||
|
|||||||
Reference in New Issue
Block a user