fix(navigation): preserve paused lifecycle ordering after main rebase

Use the upstream owner-settlement API and publish nested command output at
the shared completion boundary. Inspector callbacks can already publish the
pending prefix while an owner remains paused; fence the concrete published
tail even when settlement has no new batch. This keeps beforeunload output
ahead of navigation fetch without closing the suspended command recorder.

Include before-fetch messages and completion details in the existing
paused-navigation regression assertions, and format replayed imports.

Validation: cargo fmt --all; workspace/all-target/all-feature Clippy with
warnings denied; nextest 20,797 passed, 16 skipped, 32 threads, zero retries.
Both paused beforeunload regressions also passed 10 consecutive rounds.
This commit is contained in:
ldm0
2026-11-19 00:51:27 +08:00
parent 5c9be846f7
commit 3df2b5f43f
3 changed files with 17 additions and 11 deletions
@@ -185,7 +185,11 @@ async fn check_beforeunload_while_paused(runtime_command: bool) {
let _ = socket.close(None).await;
abort_test_cdp_server(server).await;
fixture.abort();
assert_eq!(bindings, vec![json!("root:false"), json!("child:false")]);
assert_eq!(
bindings,
vec![json!("root:false"), json!("child:false")],
"before fetch: {messages:#?}; navigation completion: {completed:#?}"
);
assert_eq!(
consoles,
vec![json!("beforeunload:root"), json!("beforeunload:child")]
@@ -54,9 +54,15 @@ impl PageVm {
self.vm().append_live_command_output_prefix();
self.absorb_pending_dom_mutations_into_output_journal();
self.record_document_title_change_if_needed();
let publication = self.vm_mut().settle_renderer_output_prefix()?;
let journal = self.vm().renderer_command_output_journal();
journal.publish_resolved_prefix_and_declare_fence(publication)
if let Some(publication) = self.vm_mut().settle_renderer_output_prefix() {
let journal = self.vm().renderer_command_output_journal();
return journal.publish_resolved_prefix_and_declare_fence(publication);
}
// Inspector callbacks can publish the prefix while the owner remains
// paused. An empty pending journal still needs a fence for that concrete
// tail before an internal reply starts navigation or replaces the Page.
let cursor = self.renderer_output_tail_cursor()?;
Some(self.declare_renderer_output_fence(cursor))
}
pub(super) fn runtime_inspector_session_restore_snapshots(
@@ -542,13 +542,9 @@ impl ScriptVm {
// alive without a RefCell borrow across reentrant author callbacks.
let context_host = Rc::clone(&self._context_host);
let host_ptr = (*context_host).as_ptr();
let allowed = unsafe { &mut *host_ptr }.dispatch_main_document_tree_beforeunload(scope);
// A paused Runtime command may own the active recorder. Flush its
// concrete prefix just as for a modal dialog, without closing that
// recorder or completing the suspended task. The navigation reply
// fences this prefix so console/binding output precedes the fetch.
unsafe { &*host_ptr }.publish_live_turn_output_prefix();
allowed
// The nested command boundary resolves the remaining output and fences
// the concrete stream tail without closing the paused command recorder.
unsafe { &mut *host_ptr }.dispatch_main_document_tree_beforeunload(scope)
}
pub(crate) fn unload_main_document_for_navigation_commit(&mut self) -> anyhow::Result<()> {