Files
craft-anything/crates/js/tests/regression_html_raw_text.rs
BFlatandAfloat 0eea78d7aa Read HTML pages' scripts and preloads correctly in more cases (#645)
Replays #591–#596. The HTML scanner reads rel token lists, decodes asset URLs once, keeps script and title text through lookalike closing tags, and skips raw-text elements, markup inside attribute values and custom tag names.

Co-authored-by: Afloat <132809511+Afloat16@users.noreply.github.com>
2026-11-03 19:58:08 +07:00

13 lines
568 B
Rust

use craft_anything_js::html::scan_html;
#[test]
fn regression_text_elements_do_not_invent_script_dependencies() {
for tag in ["style", "textarea", "xmp", "iframe", "noembed", "noframes"] {
let page = format!("<{tag}><script src='ghost.js'></script></{tag}><script src='real.js'></script>");
let f = scan_html(&page);
assert_eq!(f.scripts.len(), 1, "{tag}: {:?}", f.scripts);
assert_eq!(f.scripts[0].src.as_deref(), Some("real.js"));
}
assert!(scan_html("<plaintext><script src='ghost.js'></script>").scripts.is_empty());
}