From f1c771c61ef89ac0ec04b929583f7527990eb7b3 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Fri, 8 Nov 2024 15:04:38 +1300 Subject: [PATCH] WPT: Enable xhtml tests --- Cargo.toml | 1 + apps/wpt/src/main.rs | 2 +- packages/blitz-dom/Cargo.toml | 1 + packages/blitz-dom/src/htmlsink.rs | 17 +++++++++++++---- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5f082005..6aa26bd0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ style_traits = { version = "0.1", package = "stylo_traits" } style_dom = { version = "0.1", package = "stylo_dom" } selectors = { version = "0.26", package = "stylo_selectors" } html5ever = "0.29" # needs to match stylo markup5ever version +xml5ever = "0.20" # needs to match stylo markup5ever version euclid = "0.22" string_cache = "0.8.7" atomic_refcell = "0.1.13" diff --git a/apps/wpt/src/main.rs b/apps/wpt/src/main.rs index 9563cd6d..71929d62 100644 --- a/apps/wpt/src/main.rs +++ b/apps/wpt/src/main.rs @@ -57,7 +57,7 @@ fn collect_tests(wpt_dir: &Path) -> Vec { } for suite in suites { - for ext in ["htm", "html" /*, "xht", "xhtml"*/] { + for ext in ["htm", "html", "xht", "xhtml"] { let pattern = format!("{}/{}/**/*.{}", wpt_dir.display(), suite, ext); let glob_results = glob::glob(&pattern).expect("Invalid glob pattern."); diff --git a/packages/blitz-dom/Cargo.toml b/packages/blitz-dom/Cargo.toml index 83713f97..a302ce5e 100644 --- a/packages/blitz-dom/Cargo.toml +++ b/packages/blitz-dom/Cargo.toml @@ -22,6 +22,7 @@ app_units = { workspace = true } euclid = { workspace = true, features = ["serde"] } atomic_refcell = { workspace = true, features = ["serde"] } html5ever = { workspace = true } +xml5ever = { workspace = true } string_cache ={ workspace = true } # DioxusLabs dependencies diff --git a/packages/blitz-dom/src/htmlsink.rs b/packages/blitz-dom/src/htmlsink.rs index fa3ee6a8..652672d8 100644 --- a/packages/blitz-dom/src/htmlsink.rs +++ b/packages/blitz-dom/src/htmlsink.rs @@ -53,10 +53,19 @@ impl DocumentHtmlParser<'_> { net_provider: SharedProvider, ) -> &'d mut Document { let sink = Self::new(doc, net_provider); - html5ever::parse_document(sink, Default::default()) - .from_utf8() - .read_from(&mut html.as_bytes()) - .unwrap() + if html.starts_with("