keep the existing page active until the pending one is loaded

During a root navigation, we keep the existing page active until we get
the headers callback from the pending page. Then
Session.commitPendingPage makes the switch.

It delays the deinit of CPD execution context to handle JS execution in
the meantime.

Now session has an array of two pages, _active_idx points to the main
page.

Both active and pending pages share the same frame_id, it must remains
stable. So this PR adds a Request.protect_from_abort to avoid removing
the request form the pending page when deinit the previous active page.
This commit is contained in:
Pierre Tachoire
2026-04-27 15:27:52 +02:00
parent 0420802f8d
commit acdddb7ec8
11 changed files with 407 additions and 60 deletions

View File

@@ -204,7 +204,7 @@ const TestContext = struct {
if (self.cdp_) |*cdp__| {
if (cdp__.browser_context) |*bc| {
if (bc.session.page != null) {
if (bc.session.hasPage()) {
var runner = try bc.session.runner(.{});
_ = try runner.tick(.{ .ms = 1000 });
}