diff --git a/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/frame_navigation_and_history.rs b/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/frame_navigation_and_history.rs index d6faca5a979..946d11cdf64 100644 --- a/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/frame_navigation_and_history.rs +++ b/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/frame_navigation_and_history.rs @@ -4119,3 +4119,48 @@ fn moving_iframe_into_own_child_document_discards_retained_window_relations() { r#"{"before":{"parentIsTop":true,"topIsTop":true,"frameElementIsOwner":true,"contentWindowIsStable":true},"after":{"parentIsNull":true,"topIsNull":true,"frameElementIsNull":true,"contentWindowIsNull":true,"documentIsRetained":true,"movedIntoChildDocument":true,"remainsInserted":true}}"# ); } + +#[test] +fn iframe_src_navigation_uses_owner_document_encoding_for_query() { + let mut vm = new_storage_test_vm("https://iframe-src-encoding.test/page.html"); + vm.document_runtime + .set_document_character_set("windows-1252"); + + let reflected_src = vm + .eval( + r#" +(() => { + const frame = document.createElement("iframe"); + frame.id = "encoded-src-frame"; + frame.src = "resources/frame.html?\u00DF"; + (document.body || document.documentElement || document).appendChild(frame); + return frame.src; +})() +"#, + ) + .expect("legacy-encoded iframe src setup should evaluate"); + assert_eq!( + reflected_src, + "https://iframe-src-encoding.test/resources/frame.html?%DF" + ); + + let child_handle = vm + .document_runtime + .dom_host() + .element_handle_by_id("encoded-src-frame") + .expect("encoded src iframe owner"); + let attribute_bootstrap = vm + ._context_host + .borrow() + .child_browsing_context_attribute_bootstrap_for_test(child_handle) + .expect("encoded src attribute bootstrap should exist"); + assert!( + matches!( + attribute_bootstrap, + crate::native_bridge::ChildBrowsingContextBootstrap::Url(ref url) + if url.as_str() + == "https://iframe-src-encoding.test/resources/frame.html?%DF" + ), + "iframe navigation must use the same owner-document encoding as its reflected src: {attribute_bootstrap:?}" + ); +}