Skip to content

Commit 9bd5ff6

Browse files
authored
Merge pull request #779 from lightpanda-io/waitForNavigation
Internal navigation should change the CDP loader-id
2 parents eadf351 + 872a9d3 commit 9bd5ff6

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/browser/html/elements.zig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,9 +1369,7 @@ test "Browser.HTML.HtmlInputElement.propeties.form" {
13691369

13701370
try runner.testCases(&.{
13711371
.{ "let elem_input = document.querySelector('input')", null },
1372-
}, .{});
1373-
try runner.testCases(&.{.{ "elem_input.form", "[object HTMLFormElement]" }}, .{}); // Initial value
1374-
try runner.testCases(&.{
1372+
.{ "elem_input.form", "[object HTMLFormElement]" }, // Initial value
13751373
.{ "elem_input.form = 'foo'", null },
13761374
.{ "elem_input.form", "[object HTMLFormElement]" }, // Invalid
13771375
}, .{});

src/cdp/domains/network.zig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ fn putAssumeCapacity(headers: *std.ArrayListUnmanaged(std.http.Header), extra: s
8585
}
8686

8787
pub fn httpRequestFail(arena: Allocator, bc: anytype, request: *const Notification.RequestFail) !void {
88+
// It's possible that the request failed because we aborted when the client
89+
// sent Target.closeTarget. In that case, bc.session_id will be cleared
90+
// already, and we can skip sending these messages to the client.
91+
const session_id = bc.session_id orelse return;
92+
8893
// Isn't possible to do a network request within a Browser (which our
8994
// notification is tied to), without a page.
9095
std.debug.assert(bc.session.page != null);
9196

92-
// all unreachable because we _have_ to have a page.
93-
const session_id = bc.session_id orelse unreachable;
94-
9597
// We're missing a bunch of fields, but, for now, this seems like enough
9698
try bc.cdp.sendEvent("Network.loadingFailed", .{
9799
.requestId = try std.fmt.allocPrint(arena, "REQ-{d}", .{request.id}),

src/cdp/domains/page.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ pub fn pageNavigate(arena: Allocator, bc: anytype, event: *const Notification.Pa
163163
std.debug.assert(bc.session.page != null);
164164

165165
var cdp = bc.cdp;
166+
167+
if (event.opts.reason != .address_bar) {
168+
bc.loader_id = bc.cdp.loader_id_gen.next();
169+
}
170+
166171
const loader_id = bc.loader_id;
167172
const target_id = bc.target_id orelse unreachable;
168173
const session_id = bc.session_id orelse unreachable;

0 commit comments

Comments
 (0)