diff --git a/crates/obscura-browser/src/page.rs b/crates/obscura-browser/src/page.rs index fd92f12..0e4ccc5 100644 --- a/crates/obscura-browser/src/page.rs +++ b/crates/obscura-browser/src/page.rs @@ -425,6 +425,27 @@ fn parse_import_url(stmt: &str) -> Option { Some(url) } +/// Materialize a fetched linked sheet immediately after its source ``. +/// +/// Keeping each sheet at its document position matters when linked and inline +/// author sheets are interleaved. Appending one aggregate ` + + "#, + ); + let mut runtime = obscura_js::runtime::ObscuraJsRuntime::new(); + runtime.set_dom(dom); + runtime.run_page_init(); + runtime + .execute_script( + "", + &materialize_linked_stylesheet_script(0, ".target{height:10px}"), + ) + .expect("materialize first linked sheet"); + runtime + .execute_script( + "", + &materialize_linked_stylesheet_script(1, ".target{height:30px}"), + ) + .expect("materialize second linked sheet"); + + let sheet_text = runtime + .with_dom(|dom| { + dom.query_selector_all("style") + .expect("valid selector") + .into_iter() + .map(|nid| dom.text_content(nid)) + .collect::>() + }) + .expect("live DOM"); + assert_eq!( + sheet_text, + vec![ + ".target{height:10px}", + ".target{height:20px}", + ".target{height:30px}", + ] + ); + } + #[test] fn hydration_recovery_requires_a_catastrophic_content_wipe() { assert!(should_restore_hydration_snapshot(