fix(navigation): replace Location entries until document loading completes

Track complete loading separately from readyState for main and child documents, retaining the state through document.open(). Apply before-load replacement to Location assignments with the transient user activation exception, and settle inherited main load completion after a load-callback rewrite.

Keep Window.open on the generic navigation path so its history behavior remains independent of the Location API.

Cover real child history length and entry indices across parser, DOMContentLoaded, load, pageshow, and post-load document.open(), plus main navigation event classification and activation. Update the measured Location WPT results.
This commit is contained in:
ldm0
2026-11-19 00:29:03 +08:00
parent 29b6a70f55
commit 856461e91b
11 changed files with 461 additions and 25 deletions
@@ -7402,7 +7402,6 @@ html/semantics/scripting-1/the-script-element/execution-timing/079.html
html/semantics/scripting-1/the-script-element/execution-timing/081.html
html/semantics/scripting-1/the-script-element/execution-timing/082.html
html/semantics/scripting-1/the-script-element/execution-timing/084.html
html/semantics/scripting-1/the-script-element/execution-timing/085.html
html/semantics/scripting-1/the-script-element/execution-timing/086.html
html/semantics/scripting-1/the-script-element/execution-timing/087.html
html/semantics/scripting-1/the-script-element/execution-timing/088.html
+7 -3
View File
@@ -6,6 +6,8 @@ use support::FixtureServer;
use tokio::time::Duration;
use url::Url;
#[path = "history_child/location_before_load.rs"]
mod location_before_load;
#[path = "history_child/src_during_load.rs"]
mod src_during_load;
@@ -4151,7 +4153,7 @@ async fn child_browsing_context_location_hash_assignment_dispatches_local_popsta
page.serialize_html_async()
.await
.unwrap()
.contains("data-top-history-unchanged=\"false\""),
.contains("data-top-history-unchanged=\"true\""),
"{}",
page.serialize_html_async().await.unwrap()
);
@@ -4190,11 +4192,13 @@ async fn child_browsing_context_location_hash_assignment_dispatches_local_popsta
"{}",
page.serialize_html_async().await.unwrap()
);
// The owner element's load callback runs before the child's pageshow
// completes, so this Location assignment replaces its history entry.
assert!(
page.serialize_html_async()
.await
.unwrap()
.contains("data-child-sync-history-length=\"2\""),
.contains("data-child-sync-history-length=\"1\""),
"{}",
page.serialize_html_async().await.unwrap()
);
@@ -4225,7 +4229,7 @@ async fn child_browsing_context_location_hash_assignment_dispatches_local_popsta
page.serialize_html_async()
.await
.unwrap()
.contains("data-child-timeout-history-length=\"2\""),
.contains("data-child-timeout-history-length=\"1\""),
"{}",
page.serialize_html_async().await.unwrap()
);
@@ -0,0 +1,223 @@
use super::*;
fn markup_url(server: &FixtureServer, markup: &str) -> String {
let mut url = Url::parse(&server.url("/compat/child-dynamic-markup-document")).unwrap();
url.query_pairs_mut().append_pair("markup", markup);
url.into()
}
async fn child_navigation_history(phase: &str, api: &str, replaces: bool) -> Result<()> {
let server = FixtureServer::spawn().await?;
let browser = Browser::new(AppConfig::default())?;
let destination = server.url("/static?location-destination");
let source = format!(
r#"<!doctype html><body><script>
function go() {{
parent.navigationReadiness = document.readyState;
navigation.addEventListener('navigate', e => parent.navigationType = e.navigationType);
const target = {};
if ({} === 'window-open') window.open(target, '_self');
else location.assign(target);
}}
const phase = {};
if (phase === 'parser') go();
else if (phase === 'DOMContentLoaded') document.addEventListener(phase, go, {{once: true}});
else if (phase === 'load' || phase === 'pageshow') addEventListener(phase, go, {{once: true}});
else addEventListener('load', () => setTimeout(() => {{
if (phase === 'reopen') document.open();
go();
}}, 0), {{once: true}});
</script>"#,
serde_json::to_string(&destination)?,
serde_json::to_string(api)?,
serde_json::to_string(phase)?
);
let parent = format!(
r#"<!doctype html><body><script>
window.finished = new Promise(resolve => window.finish = resolve);
const initialLength = history.length;
const frame = document.createElement('iframe');
frame.onload = () => {{
if (frame.contentWindow.location.href === {}) setTimeout(() => finish({{
delta: history.length - initialLength,
navigationType, navigationReadiness,
childEntryIndex: frame.contentWindow.navigation.currentEntry.index
}}), 0);
}};
frame.src = {};
document.body.append(frame);
</script>"#,
serde_json::to_string(&destination)?,
serde_json::to_string(&markup_url(&server, &source))?.replace("</script>", "<\\/script>")
);
let result = tokio::time::timeout(Duration::from_secs(10), async {
let mut page = browser.fetch(&markup_url(&server, &parent)).await?;
page.evaluate_runtime_expression_with_await_async(
"finished.then(value => JSON.stringify(value))",
true,
)
.await
})
.await??;
let result: serde_json::Value =
serde_json::from_str(result["value"].as_str().expect("navigation history result"))?;
let expected_delta = if replaces { 0 } else { 1 };
assert_eq!(result["delta"], expected_delta, "phase={phase}, {result}");
assert_eq!(result["childEntryIndex"], expected_delta, "phase={phase}");
assert_eq!(
result["navigationType"],
if replaces { "replace" } else { "push" },
"phase={phase}"
);
assert_eq!(
result["navigationReadiness"],
match phase {
"parser" | "reopen" => "loading",
"DOMContentLoaded" => "interactive",
_ => "complete",
},
"phase={phase}"
);
server.shutdown().await;
Ok(())
}
#[tokio::test(flavor = "multi_thread")]
async fn child_location_navigation_replaces_until_load_callbacks_finish() -> Result<()> {
for phase in ["parser", "DOMContentLoaded", "load", "pageshow"] {
child_navigation_history(phase, "location", true).await?;
}
Ok(())
}
#[tokio::test(flavor = "multi_thread")]
async fn child_location_navigation_pushes_after_complete_even_after_document_open() -> Result<()> {
for phase in ["after-load", "reopen"] {
child_navigation_history(phase, "location", false).await?;
}
Ok(())
}
#[tokio::test(flavor = "multi_thread")]
async fn child_window_open_self_before_load_keeps_push_history() -> Result<()> {
for phase in ["parser", "DOMContentLoaded", "load", "pageshow"] {
child_navigation_history(phase, "window-open", false).await?;
}
Ok(())
}
#[tokio::test(flavor = "multi_thread")]
async fn main_location_before_load_exposes_replace_navigation_events() -> Result<()> {
let server = FixtureServer::spawn().await?;
for phase in ["parser", "DOMContentLoaded", "load", "pageshow"] {
let browser = Browser::new(AppConfig::default())?;
let source = format!(
r#"<!doctype html><script>
const startingLength = history.length;
navigation.addEventListener('navigate', e => {{
window.navigationType = e.navigationType;
e.preventDefault();
}});
function go() {{
location.assign('/destination');
window.historyResult = JSON.stringify({{
navigationType, delta: history.length - startingLength,
readiness: document.readyState
}});
}}
const phase = {};
if (phase === 'parser') go();
else if (phase === 'DOMContentLoaded') document.addEventListener(phase, go);
else addEventListener(phase, go);
</script>"#,
serde_json::to_string(phase)?
);
// Observe the real main-document lifecycle without handing the Page
// off to another navigation: Browser::fetch owns only this document.
let result = tokio::time::timeout(Duration::from_secs(10), async {
let mut page = browser.fetch(&markup_url(&server, &source)).await?;
page.evaluate_runtime_expression_with_await_async("historyResult", true)
.await
})
.await??;
let result: serde_json::Value = serde_json::from_str(
result["value"]
.as_str()
.expect("main navigation history result"),
)?;
let readiness = match phase {
"parser" => "loading",
"DOMContentLoaded" => "interactive",
_ => "complete",
};
assert_eq!(
result,
serde_json::json!({"delta": 0, "navigationType": "replace", "readiness": readiness}),
"phase={phase}"
);
}
server.shutdown().await;
Ok(())
}
#[tokio::test(flavor = "multi_thread")]
async fn main_location_navigation_pushes_after_load_and_document_open() -> Result<()> {
let server = FixtureServer::spawn().await?;
for phase in ["after-load", "reopen", "load-rewrite", "pageshow-rewrite"] {
let browser = Browser::new(AppConfig::default())?;
let source = format!(
r#"<!doctype html><body><script>
window.finished = new Promise(resolve => window.finish = resolve);
function go() {{
navigation.addEventListener('navigate', e => {{
finish({{type: e.navigationType, readiness: document.readyState}});
e.preventDefault();
}}, {{once: true}});
location.assign('/destination');
}}
const phase = {};
if (phase === 'after-load' || phase === 'reopen') {{
addEventListener('load', () => setTimeout(() => {{
if (phase === 'reopen') document.open();
go();
}}, 0), {{once: true}});
}} else {{
const event = phase === 'load-rewrite' ? 'load' : 'pageshow';
addEventListener(event, () => {{
document.open();
document.write('<!doctype html><body>rewritten');
document.close();
setTimeout(go, 0);
}}, {{once: true}});
}}
</script>"#,
serde_json::to_string(phase)?
);
let result = tokio::time::timeout(Duration::from_secs(10), async {
let mut page = browser.fetch(&markup_url(&server, &source)).await?;
page.evaluate_runtime_expression_with_await_async(
"finished.then(value => JSON.stringify(value))",
true,
)
.await
})
.await??;
let result: serde_json::Value = serde_json::from_str(
result["value"]
.as_str()
.expect("main post-load navigation result"),
)?;
assert_eq!(result["type"], "push", "phase={phase}, {result}");
assert_eq!(
result["readiness"],
if phase == "reopen" {
"loading"
} else {
"complete"
},
"phase={phase}"
);
}
server.shutdown().await;
Ok(())
}
@@ -90,13 +90,26 @@ pub(crate) fn navigate_location_object<'s>(
kind: LocationNavigationKind,
raw_target: Option<String>,
) {
let owner = runtime_window_owner(scope, location);
let replaces_unloaded_document = kind == LocationNavigationKind::Assign
&& location_document_is_before_load_complete(scope, owner)
&& !context_host_ptr_for_navigation_owner(scope, owner)
.is_some_and(|host| unsafe { &*host }.protocol_user_gesture_activation());
let kind = if replaces_unloaded_document {
LocationNavigationKind::Replace
} else {
kind
};
navigate_location_object_with_source_element_and_child_navigate_event(
scope,
location,
kind,
raw_target,
None,
LocationNavigationOptions::default(),
LocationNavigationOptions {
dispatch_child_navigate_event_for_all_kinds: replaces_unloaded_document,
..LocationNavigationOptions::default()
},
);
}
@@ -433,17 +446,6 @@ fn navigate_location_object_with_source_element_and_child_navigate_event<'s>(
LocationNavigationKind::Assign if source_element.is_some() && exact_same_href => {
LocationNavigationKind::Replace
}
LocationNavigationKind::Assign
if source_element.is_none()
&& runtime_window_is_global(scope, owner)
&& top_level_document_is_before_load_complete(scope) =>
{
if force_exact_same_document_navigation {
LocationNavigationKind::Assign
} else {
LocationNavigationKind::Replace
}
}
_ => kind,
};
let navigation_type = match effective_kind {
@@ -1027,11 +1029,23 @@ pub(crate) fn dispatch_top_level_form_navigation_event<'s>(
!outcome.intercepted
}
fn top_level_document_is_before_load_complete(scope: &mut v8::PinScope<'_, '_>) -> bool {
context_host_ptr_from_global_bridge(scope).is_some_and(|host_ptr| {
unsafe { &*host_ptr }.host_document().ready_state()
!= crate::dom::native::DocumentReadyState::Complete
})
fn location_document_is_before_load_complete<'s>(
scope: &mut v8::PinScope<'s, '_>,
owner: v8::Local<'s, v8::Object>,
) -> bool {
let Some(host_ptr) = context_host_ptr_for_navigation_owner(scope, owner) else {
return false;
};
let host = unsafe { &*host_ptr };
let document_handle = if runtime_window_is_global(scope, owner) {
Some(host.document_handle())
} else {
child_browsing_context_handle_for_runtime_owner(scope, owner)
.and_then(|handle| host.frame_owner_current_child_snapshot(handle))
.map(|snapshot| snapshot.document_handle)
};
document_handle
.is_some_and(|document| host.document_is_completely_loaded(document) == Some(false))
}
fn finish_location_navigation_canceled<'s>(
@@ -1,5 +1,5 @@
use super::super::{
location_navigation::{LocationNavigationKind, navigate_location_object},
location_navigation::{LocationNavigationKind, navigate_location_object_with_source_element},
navigation_cancellation::inform_about_canceled_navigation_for_window,
};
use crate::{
@@ -638,11 +638,14 @@ fn navigate_window_open_self<'s>(
rv.set(v8::null(scope).into());
return;
};
navigate_location_object(
// Window.open keeps its own history behavior while the target loads;
// it does not run the Location API's before-load replacement algorithm.
navigate_location_object_with_source_element(
scope,
location,
LocationNavigationKind::Assign,
Some(url.to_owned()),
None,
);
rv.set(receiver.into());
}
@@ -624,6 +624,9 @@ pub(crate) struct DocumentLifecycleRecord {
domcontentloaded_transition_token: Option<DocumentLoadDelayTokenId>,
complete_transition_token: Option<DocumentLoadDelayTokenId>,
readiness: Option<DocumentReadinessState>,
// Unlike readiness and load-event progress, this is retained by
// document.open(). It becomes true only after the loading algorithm ends.
completely_loaded: bool,
load: DocumentLoadEventProgress,
child_load_delivery_admission: Option<FrameDocumentLoadDeliveryAdmissionId>,
unload: DocumentUnloadEventProgress,
@@ -644,6 +647,7 @@ impl DocumentLifecycleRecord {
domcontentloaded_transition_token: Some(domcontentloaded_transition_token),
complete_transition_token: None,
readiness: Some(DocumentReadinessState::Loading),
completely_loaded: false,
load: DocumentLoadEventProgress::Pending,
child_load_delivery_admission: None,
unload: DocumentUnloadEventProgress::Pending,
@@ -655,12 +659,14 @@ impl DocumentLifecycleRecord {
parsing_delay_token: DocumentLoadDelayTokenId,
domcontentloaded_transition_token: DocumentLoadDelayTokenId,
continuation: Option<DocumentOpenLoadContinuation>,
completely_loaded: bool,
) -> Self {
let mut lifecycle = Self::loading(
load_delivery_kind,
parsing_delay_token,
domcontentloaded_transition_token,
);
lifecycle.completely_loaded = completely_loaded;
lifecycle.load = match (load_delivery_kind, continuation) {
(_, None) => DocumentLoadEventProgress::Pending,
(DocumentLoadDeliveryKind::Main, Some(DocumentOpenLoadContinuation::MainLoad)) => {
@@ -701,6 +707,10 @@ impl DocumentLifecycleRecord {
}
}
pub(super) fn is_completely_loaded(&self) -> bool {
self.completely_loaded
}
pub(super) fn can_finish_parsing(&self) -> bool {
self.parsing_delay_token.is_some()
&& self.readiness == Some(DocumentReadinessState::Loading)
@@ -855,6 +865,12 @@ impl DocumentLifecycleRecord {
self.complete_transition_token = None;
self.readiness = Some(DocumentReadinessState::Complete);
self.load = next_load;
if next_load == DocumentLoadEventProgress::Dispatched {
// document.open() inside a main load callback inherits that
// delivery instead of dispatching load again. Completing the
// replacement parser must also settle its loaded status.
self.completely_loaded = true;
}
true
}
@@ -877,6 +893,7 @@ impl DocumentLifecycleRecord {
self.complete_transition_token = None;
self.readiness = Some(DocumentReadinessState::Complete);
self.load = DocumentLoadEventProgress::Suppressed;
self.completely_loaded = true;
self.child_load_delivery_admission = None;
Some(ready_state_changed)
@@ -905,6 +922,7 @@ impl DocumentLifecycleRecord {
self.complete_transition_token = None;
self.readiness = Some(DocumentReadinessState::Complete);
self.load = DocumentLoadEventProgress::Ready;
self.completely_loaded = true;
true
}
@@ -999,6 +1017,7 @@ impl DocumentLifecycleRecord {
return Some(MainDocumentLoadCompletionState::WaitingForDescendants);
}
self.load = DocumentLoadEventProgress::Dispatched;
self.completely_loaded = true;
Some(MainDocumentLoadCompletionState::Completed)
}
@@ -1012,6 +1031,7 @@ impl DocumentLifecycleRecord {
return Some(MainDocumentLoadCompletionState::WaitingForDescendants);
}
self.load = DocumentLoadEventProgress::Dispatched;
self.completely_loaded = true;
Some(MainDocumentLoadCompletionState::Completed)
}
@@ -1108,6 +1128,9 @@ impl DocumentLifecycleRecord {
}
};
self.load = next;
if finished {
self.completely_loaded = true;
}
Some(finished)
}
@@ -93,6 +93,7 @@ impl FrameOwnerStore {
&mut self,
load_delivery_kind: DocumentLoadDeliveryKind,
continuation: Option<super::records::DocumentOpenLoadContinuation>,
completely_loaded: bool,
) -> DocumentLifecycleRecord {
let parsing_delay_token = self.ids.document_load_delay_token();
let domcontentloaded_transition_token = self.ids.document_load_delay_token();
@@ -101,6 +102,7 @@ impl FrameOwnerStore {
parsing_delay_token,
domcontentloaded_transition_token,
continuation,
completely_loaded,
)
}
@@ -417,6 +419,7 @@ impl FrameOwnerStore {
let load_continuation = retired_document
.lifecycle_progress
.document_open_load_continuation();
let completely_loaded = retired_document.lifecycle_progress.is_completely_loaded();
retired_document.lifecycle = DocumentLifecycleState::Replaced;
retired_document.lifecycle_progress.retire();
retired_document.active_requests.clear();
@@ -426,6 +429,7 @@ impl FrameOwnerStore {
self.new_loading_document_lifecycle_for_document_open(
DocumentLoadDeliveryKind::Main,
load_continuation,
completely_loaded,
)
} else {
self.new_loading_document_lifecycle(DocumentLoadDeliveryKind::Main)
@@ -980,6 +984,7 @@ impl FrameOwnerStore {
let load_continuation = retired_document
.lifecycle_progress
.document_open_load_continuation();
let completely_loaded = retired_document.lifecycle_progress.is_completely_loaded();
retired_document.lifecycle = DocumentLifecycleState::Replaced;
retired_document.lifecycle_progress.retire();
retired_document.active_requests.clear();
@@ -988,6 +993,7 @@ impl FrameOwnerStore {
let lifecycle_progress = self.new_loading_document_lifecycle_for_document_open(
DocumentLoadDeliveryKind::Child,
load_continuation,
completely_loaded,
);
self.documents.insert(
document_id,
@@ -3510,6 +3516,18 @@ impl FrameOwnerStore {
}
}
pub(crate) fn current_document_is_completely_loaded(
&self,
owner: FrameDocumentOwner,
) -> Option<bool> {
if !self.frame_document_owner_is_current(owner) {
return None;
}
self.documents
.get(&owner.document_id)
.map(|document| document.lifecycle_progress.is_completely_loaded())
}
pub(crate) fn frame_document_owner_is_current(&self, owner: FrameDocumentOwner) -> bool {
let Some(document) = self.documents.get(&owner.document_id) else {
return false;
@@ -563,11 +563,35 @@ fn main_document_lifecycle_actions_are_owned_and_replacement_stale_drops_them()
.prepare_current_main_document_complete_transition(third_owner)
.expect("third replacement should prepare complete");
assert!(store.apply_current_main_document_complete_transition(third_complete));
assert_eq!(
store.current_document_is_completely_loaded(third_owner.document_owner()),
Some(false)
);
assert!(store.begin_current_main_document_load_dispatch(third_owner));
assert_eq!(
store.current_document_is_completely_loaded(third_owner.document_owner()),
Some(false)
);
assert_eq!(
store.finish_current_main_document_load_dispatch(third_owner),
Some(MainDocumentLoadCompletionState::Completed)
);
assert_eq!(
store.current_document_is_completely_loaded(third_owner.document_owner()),
Some(true)
);
let reopened = store
.replace_main_document(
handle(1),
url("https://example.test/reopened"),
url("https://example.test/reopened"),
)
.expect("completed main document can reopen");
assert_eq!(
store.current_document_is_completely_loaded(reopened.current_owner().document_owner()),
Some(true),
"a reopened main document must retain completely-loaded status"
);
}
#[test]
@@ -3452,6 +3476,11 @@ fn child_document_open_during_owner_load_resumes_with_pageshow() {
let replacement_owner = replacement
.current_owner()
.expect("document.open should install a replacement owner");
assert_eq!(
store.current_document_is_completely_loaded(replacement_owner.document_owner()),
Some(false),
"document.open during load must preserve the not-yet-completely-loaded state"
);
assert!(
store
.finish_current_child_document_load_delivery(owner_element_load)
@@ -3496,6 +3525,65 @@ fn child_document_open_during_owner_load_resumes_with_pageshow() {
));
}
#[test]
fn child_completely_loaded_waits_for_delivery_and_survives_document_open() {
let mut store = FrameOwnerStore::default();
let child_handle = handle(500);
let document_handle = handle(501);
let owner = commit_test_child_document(
&mut store,
child_handle,
document_handle,
"completely-loaded",
Some("main"),
);
let task = prepare_test_child_load_delivery(&mut store, child_handle, owner);
for phase in [
FrameDocumentLoadDeliveryPhase::WindowLoad,
FrameDocumentLoadDeliveryPhase::OwnerElementLoad,
FrameDocumentLoadDeliveryPhase::PageShow,
FrameDocumentLoadDeliveryPhase::FrameFinish,
] {
let action = store
.begin_current_child_document_load_delivery(task)
.unwrap();
assert_eq!(action.phase(), phase);
assert_eq!(
store.current_document_is_completely_loaded(owner.document_owner()),
Some(false),
"complete readiness must not stand in for complete load delivery"
);
assert!(
store
.finish_current_child_document_load_delivery(action)
.is_some()
);
}
assert_eq!(
store.current_document_is_completely_loaded(owner.document_owner()),
Some(true)
);
let plan = store
.plan_child_document_open_replacement(
child_handle,
document_handle,
url("https://completely-loaded.test/reopened"),
url("https://completely-loaded.test/reopened"),
)
.unwrap();
let replacement = store.commit_child_document_open_replacement(plan);
let replacement_owner = replacement.current_owner().unwrap();
assert_eq!(
store.current_document_is_completely_loaded(owner.document_owner()),
None
);
assert_eq!(
store.current_document_is_completely_loaded(replacement_owner.document_owner()),
Some(true),
"document.open changes readiness but retains completely-loaded status"
);
}
#[test]
fn child_document_open_during_pageshow_resumes_after_pageshow() {
let mut store = FrameOwnerStore::default();
@@ -115,6 +115,22 @@ impl PageScriptHost {
);
}
pub(crate) fn document_is_completely_loaded(
&self,
document_handle: crate::document_runtime::DomHandle,
) -> Option<bool> {
let owner = if document_handle == self.document_handle() {
self.current_main_document_task_owner()?.document_owner()
} else {
let child_handle =
self.child_browsing_context_host_for_document_handle(document_handle)?;
self.frame_owner_store
.current_child_document_owner(child_handle)?
};
self.frame_owner_store
.current_document_is_completely_loaded(owner)
}
/// Replace the dynamically scoped Runtime command cause and return the
/// previous scope for exact restoration after V8 dispatch.
///
@@ -1074,6 +1074,52 @@ async fn javascript_form_actions_execute_without_serializing_the_entry_list() {
}
}
#[cfg(feature = "devtools")]
#[test]
fn location_assign_before_complete_load_respects_user_activation() {
for activated in [false, true] {
let mut vm = new_storage_test_vm("https://location-before-load.test/source");
if activated {
vm._context_host
.borrow_mut()
.begin_protocol_user_gesture_activation();
}
let navigation_type = vm
.eval(
r#"
window.observedNavigationType = null;
navigation.addEventListener('navigate', e => observedNavigationType = e.navigationType);
location.assign('/destination');
observedNavigationType
"#,
)
.expect("Location navigation must expose its resolved history behavior");
if activated {
vm._context_host
.borrow_mut()
.end_protocol_user_gesture_activation();
}
assert_eq!(navigation_type, if activated { "push" } else { "replace" });
let pending = vm.take_pending_location_navigation_with_seed().unwrap();
let seed = pending.entry_seed.unwrap();
let from = seed.activation.as_ref().unwrap().from.as_ref().unwrap();
assert_eq!(
seed.current_index,
from.history_index + u32::from(activated)
);
assert_eq!(
seed.entries
.iter()
.any(|entry| entry.url == "https://location-before-load.test/source"),
activated
);
assert_eq!(
seed.entries.last().unwrap().url,
"https://location-before-load.test/destination"
);
}
}
#[test]
fn form_target_blank_reloads_rel_opener_policy_for_each_submission() {
for (rel, expected_exposes_opener) in [
@@ -1642,6 +1642,8 @@ async fn location_href_double_intercept_cancels_first_settlement() {
let loader = ResourceRequestClient::new(&moli_fetch::FetchConfig::default()).expect("loader");
let mut vm = new_storage_test_vm_with_loader("https://example.com/start", &loader);
// Both assignments occur before complete loading, so both intercepted
// navigations replace the entry while preserving their abort ordering.
let setup = vm
.eval(
r##"
@@ -1695,7 +1697,7 @@ async fn location_href_double_intercept_cancels_first_settlement() {
.expect("location double setup should evaluate");
assert_eq!(
setup,
"locationInterceptSpoof:false:spoof-location.js:https://example.com/start:null|navigate:https://example.com/start:null|currententrychange:https://example.com/common/blank.html#1:push|handler:https://example.com/common/blank.html#1:push|abort:AbortError:https://example.com/common/blank.html#1:push|navigateerror:AbortError:https://example.com/common/blank.html#1:push|navigate:https://example.com/common/blank.html#1:null|currententrychange:https://example.com/common/blank.html#2:replace|handler:https://example.com/common/blank.html#2:replace"
"locationInterceptSpoof:false:spoof-location.js:https://example.com/start:null|navigate:https://example.com/start:null|currententrychange:https://example.com/common/blank.html#1:replace|handler:https://example.com/common/blank.html#1:replace|abort:AbortError:https://example.com/common/blank.html#1:replace|navigateerror:AbortError:https://example.com/common/blank.html#1:replace|navigate:https://example.com/common/blank.html#1:null|currententrychange:https://example.com/common/blank.html#2:replace|handler:https://example.com/common/blank.html#2:replace"
);
vm.advance_timers_until_deadline_for_test(&loader)
@@ -1706,6 +1708,6 @@ async fn location_href_double_intercept_cancels_first_settlement() {
.expect("location double log should evaluate");
assert_eq!(
settled,
"locationInterceptSpoof:false:spoof-location.js:https://example.com/start:null|navigate:https://example.com/start:null|currententrychange:https://example.com/common/blank.html#1:push|handler:https://example.com/common/blank.html#1:push|abort:AbortError:https://example.com/common/blank.html#1:push|navigateerror:AbortError:https://example.com/common/blank.html#1:push|navigate:https://example.com/common/blank.html#1:null|currententrychange:https://example.com/common/blank.html#2:replace|handler:https://example.com/common/blank.html#2:replace|transition-rejected:AbortError:https://example.com/common/blank.html#2:replace|microtask:https://example.com/common/blank.html#2:replace|handler-timeout:https://example.com/common/blank.html#2:replace|handler-timeout:https://example.com/common/blank.html#2:replace|navigatesuccess:https://example.com/common/blank.html#2:replace|transition-finished:https://example.com/common/blank.html#2:null"
"locationInterceptSpoof:false:spoof-location.js:https://example.com/start:null|navigate:https://example.com/start:null|currententrychange:https://example.com/common/blank.html#1:replace|handler:https://example.com/common/blank.html#1:replace|abort:AbortError:https://example.com/common/blank.html#1:replace|navigateerror:AbortError:https://example.com/common/blank.html#1:replace|navigate:https://example.com/common/blank.html#1:null|currententrychange:https://example.com/common/blank.html#2:replace|handler:https://example.com/common/blank.html#2:replace|transition-rejected:AbortError:https://example.com/common/blank.html#2:replace|microtask:https://example.com/common/blank.html#2:replace|handler-timeout:https://example.com/common/blank.html#2:replace|handler-timeout:https://example.com/common/blank.html#2:replace|navigatesuccess:https://example.com/common/blank.html#2:replace|transition-finished:https://example.com/common/blank.html#2:null"
);
}