Merge pull request #3646 from lightpanda-io/same-page-reload

Don't skip navigation when page isn't loaded (or had error loading)
This commit is contained in:
Karl Seguin authored and GitHub committed 2026-09-27 07:12:40 +08:00
commit 727724bf85
1 file changed
+19 -1
+19 -1
View File
@@ -2375,7 +2375,10 @@ fn renderJson(arena: std.mem.Allocator, value: anytype) ToolError![]const u8 {
fn ensurePage(session: *lp.Session, registry: *NodeRegistry, url: ?[:0]const u8, timeout: ?u32) ToolError!*lp.Frame {
if (url) |u| {
if (session.currentFrame()) |frame| {
if (std.mem.eql(u8, frame.url, u)) return frame;
const is_loaded = frame._parse_state != .pre and frame._last_navigate_error == null;
if (is_loaded and std.mem.eql(u8, frame.url, u)) {
return frame;
}
}
_ = try performGoto(session, registry, u, .{ .timeout = timeout });
}
@@ -3023,3 +3026,18 @@ test "isPathSafe: absolute paths and traversal are rejected" {
try std.testing.expect(!isPathSafe("sub/.."));
try std.testing.expect(!isPathSafe(".."));
}
test "markdown: a same-url page whose navigation failed is navigated again" {
var registry: NodeRegistry = .init(std.testing.allocator);
defer registry.deinit();
const session = testing.test_session;
defer if (session.primaryPage()) |page| page.close();
const aa = testing.arena_allocator;
const args = try std.json.parseFromSliceLeaky(std.json.Value, aa,
\\{"url":"http://localhost:1/"}
, .{});
try std.testing.expect((try call(aa, session, &registry, "goto", args, .{})).is_error);
try std.testing.expect((try call(aa, session, &registry, "markdown", args, .{})).is_error);
}