Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

fix(css): enable starting-style parsing

ldm08371d328ddc5
diff --git a/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/tests.rs b/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/tests.rs
index e5af1b5e5..d8aa617dd 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/tests.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/tests.rs
@@ -777,6 +777,27 @@ fn grouping_rule_css_text_uses_stylo_rule_view_serialization() {
);
}
+#[test]
+fn starting_style_rule_accepts_an_empty_prelude_and_rejects_nonempty_preludes() {
+ crate::style_engine::ensure_stylo_browser_compat_prefs();
+
+ assert_eq!(
+ parsed_top_level_rule_texts("@starting-style {}"),
+ ["@starting-style {\n}"]
+ );
+ for css_text in [
+ "@starting-style div {}",
+ "@starting-style () {}",
+ "@starting-style ( {}",
+ "@starting-style }{}",
+ ] {
+ assert!(
+ parsed_top_level_rule_texts(css_text).is_empty(),
+ "unexpectedly accepted {css_text:?}"
+ );
+ }
+}
+
#[test]
fn grouping_rule_css_text_uses_stylo_page_rule_child_serialization() {
let css_text =
diff --git a/moli-renderer-v8/src/style_engine/mod.rs b/moli-renderer-v8/src/style_engine/mod.rs
index fe336fea4..f4d0d1a97 100644
--- a/moli-renderer-v8/src/style_engine/mod.rs
+++ b/moli-renderer-v8/src/style_engine/mod.rs
@@ -1119,6 +1119,7 @@ pub(crate) fn ensure_stylo_browser_compat_prefs() {
stylo_static_prefs::set_pref!("layout.css.content.alt-text.enabled", true);
stylo_static_prefs::set_pref!("layout.css.margin-rules.enabled", true);
stylo_static_prefs::set_pref!("layout.css.scroll-driven-animations.enabled", true);
+ stylo_static_prefs::set_pref!("layout.css.starting-style-at-rules.enabled", true);
stylo_static_prefs::set_pref!("layout.css.style-queries.enabled", true);
stylo_static_prefs::set_pref!("layout.css.tree-counting-functions.enabled", true);
stylo_static_prefs::set_pref!("layout.css.zoom.enabled", true);