Skip to content

Truly independent web browser

LibWeb: Include position in the font-synthesis shorthand

Andreas Klingb49c57ae7825
diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.json
index b61152ba863..95e629bad04 100644
--- a/Libraries/LibWeb/CSS/Properties.json
+++ b/Libraries/LibWeb/CSS/Properties.json
@@ -2595,8 +2595,9 @@
]
},
"font-synthesis": {
- "initial": "weight style small-caps",
+ "initial": "weight style small-caps position",
"longhands": [
+ "font-synthesis-position",
"font-synthesis-small-caps",
"font-synthesis-style",
"font-synthesis-weight"
diff --git a/Libraries/LibWeb/Rust/src/css/declaration_block.rs b/Libraries/LibWeb/Rust/src/css/declaration_block.rs
index 5f2602c29ef..fb4f3f06397 100644
--- a/Libraries/LibWeb/Rust/src/css/declaration_block.rs
+++ b/Libraries/LibWeb/Rust/src/css/declaration_block.rs
@@ -644,4 +644,97 @@ mod tests {
drop(snapshot);
assert!(old_data.upgrade().is_none());
}
+ #[test]
+ fn font_synthesis_expands_existing_position_for_ordinary_values() {
+ use crate::css::css_enums::keyword;
+ let mut observed = Vec::new();
+ for source in ["none", "weight", "style", "small-caps", "weight style small-caps"] {
+ let data = parsed_declarations(&format!("font-synthesis-position: auto; font-synthesis: {source}"));
+ let position = data
+ .properties
+ .iter()
+ .find(|property| property.property_id == property_id::FONT_SYNTHESIS_POSITION)
+ .unwrap();
+ let StyleValueData::Keyword { keyword: value } = position.value.as_ref() else {
+ panic!("keyword expected")
+ };
+ observed.push((source, keyword::NAMES[*value as usize]));
+ }
+ assert_eq!(
+ observed,
+ vec![
+ ("none", "none"),
+ ("weight", "none"),
+ ("style", "none"),
+ ("small-caps", "none"),
+ ("weight style small-caps", "none")
+ ]
+ );
+ }
+
+ #[test]
+ fn font_synthesis_stylesheet_importance_covers_position() {
+ use crate::css::css_enums::keyword;
+ let kept = parsed_declarations("font-synthesis-position: auto !important; font-synthesis: none");
+ let position = kept
+ .properties
+ .iter()
+ .find(|property| property.property_id == property_id::FONT_SYNTHESIS_POSITION)
+ .unwrap();
+ assert!(position.important);
+ assert!(
+ matches!(position.value.as_ref(), StyleValueData::Keyword { keyword: value } if *value == keyword::AUTO)
+ );
+ let changed =
+ parsed_declarations("font-synthesis-position: auto !important; font-synthesis: weight !important");
+ assert_eq!(changed.properties.len(), 4);
+ for property in &changed.properties {
+ assert!(property.important);
+ }
+ let position = changed
+ .properties
+ .iter()
+ .find(|property| property.property_id == property_id::FONT_SYNTHESIS_POSITION)
+ .unwrap();
+ assert!(
+ matches!(position.value.as_ref(), StyleValueData::Keyword { keyword: value } if *value == keyword::NONE)
+ );
+ }
+
+ #[test]
+ fn font_synthesis_css_wide_and_pending_substitutions_cover_all_four() {
+ use crate::css::css_enums::keyword;
+ for (source, expected) in [
+ ("initial", keyword::INITIAL),
+ ("inherit", keyword::INHERIT),
+ ("unset", keyword::UNSET),
+ ("revert", keyword::REVERT),
+ ("revert-layer", keyword::REVERT_LAYER),
+ ] {
+ let data = parsed_declarations(&format!("font-synthesis: {source} !important"));
+ assert_eq!(data.properties.len(), 4, "{source}");
+ assert!(
+ data.properties
+ .iter()
+ .any(|property| property.property_id == property_id::FONT_SYNTHESIS_POSITION)
+ );
+ for property in &data.properties {
+ assert!(property.important);
+ assert!(matches!(property.value.as_ref(), StyleValueData::Keyword { keyword } if *keyword == expected));
+ }
+ }
+ let pending = parsed_declarations("font-synthesis: var(--s)");
+ assert_eq!(pending.properties.len(), 5);
+ assert_eq!(pending.properties[0].property_id, property_id::FONT_SYNTHESIS);
+ assert!(
+ pending.properties[1..]
+ .iter()
+ .any(|property| property.property_id == property_id::FONT_SYNTHESIS_POSITION)
+ );
+ assert!(
+ pending.properties[1..]
+ .iter()
+ .all(|property| matches!(property.value.as_ref(), StyleValueData::PendingSubstitution { .. }))
+ );
+ }
}
diff --git a/Libraries/LibWeb/Rust/src/css/parser/value_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/value_parser.rs
index 2d123a7fc35..e526b8b90d0 100644
--- a/Libraries/LibWeb/Rust/src/css/parser/value_parser.rs
+++ b/Libraries/LibWeb/Rust/src/css/parser/value_parser.rs
@@ -5015,26 +5015,30 @@ fn parse_border_image_shorthand(context: &ParseContext, values: &[ComponentValue
// https://drafts.csswg.org/css-fonts-4/#font-synthesis
fn parse_font_synthesis_shorthand(values: &[ComponentValue]) -> ParseOutcome {
- // INTEROP: Chrome and Safari support weight, style, and small-caps, but not position or oblique-only.
+ // https://drafts.csswg.org/css-fonts-4/#font-synthesis
let Some(keywords) = values
.iter()
.filter(|value| !value.is_whitespace())
- .map(|value| value.ident().and_then(keyword_from_ascii_case_insensitive))
+ .map(|value| value.ident())
.collect::<Option<Vec<_>>>()
else {
return ParseOutcome::Invalid;
};
- if keywords.is_empty() || keywords.len() > 3 {
+ if keywords.is_empty() || keywords.len() > 4 {
return ParseOutcome::Invalid;
}
- let mut enabled = [false; 3];
- if keywords.as_slice() != [keyword::NONE] {
- for keyword in keywords {
- let index = match keyword {
- keyword::WEIGHT => 0,
- keyword::STYLE => 1,
- keyword::SMALL_CAPS => 2,
- _ => return ParseOutcome::Invalid,
+ let mut enabled = [false; 4];
+ if keywords.len() != 1 || !equals_ascii_case_insensitive(keywords[0], b"none") {
+ for ident in keywords {
+ let index = if equals_ascii_case_insensitive(ident, b"position") {
+ 3
+ } else {
+ match keyword_from_ascii_case_insensitive(ident) {
+ Some(keyword::WEIGHT) => 0,
+ Some(keyword::STYLE) => 1,
+ Some(keyword::SMALL_CAPS) => 2,
+ _ => return ParseOutcome::Invalid,
+ }
};
if enabled[index] {
return ParseOutcome::Invalid;
@@ -5050,6 +5054,7 @@ fn parse_font_synthesis_shorthand(values: &[ComponentValue]) -> ParseOutcome {
property_id::FONT_SYNTHESIS_WEIGHT => 0,
property_id::FONT_SYNTHESIS_STYLE => 1,
property_id::FONT_SYNTHESIS_SMALL_CAPS => 2,
+ property_id::FONT_SYNTHESIS_POSITION => 3,
_ => unreachable!(),
};
StyleValueData::Keyword {
diff --git a/Libraries/LibWeb/Rust/src/css/serialize/shorthand.rs b/Libraries/LibWeb/Rust/src/css/serialize/shorthand.rs
index 224b5752d9d..fd25b5519c8 100644
--- a/Libraries/LibWeb/Rust/src/css/serialize/shorthand.rs
+++ b/Libraries/LibWeb/Rust/src/css/serialize/shorthand.rs
@@ -84,6 +84,112 @@ mod tests {
.join()
.unwrap();
}
+ #[test]
+ fn font_synthesis_four_keyword_initial_round_trip() {
+ let value = initial(property_id::FONT_SYNTHESIS);
+ assert_eq!(
+ text(value.as_ref(), SerializationMode::Normal).into_utf16(),
+ "weight style small-caps position".encode_utf16().collect::<Vec<_>>()
+ );
+ }
+
+ #[test]
+ fn font_synthesis_four_keyword_combinations() {
+ let components = [
+ (property_id::FONT_SYNTHESIS_WEIGHT, "weight"),
+ (property_id::FONT_SYNTHESIS_STYLE, "style"),
+ (property_id::FONT_SYNTHESIS_SMALL_CAPS, "small-caps"),
+ (property_id::FONT_SYNTHESIS_POSITION, "position"),
+ ];
+ let mut missing = Vec::new();
+ for mask in 0..16 {
+ let names = components
+ .iter()
+ .enumerate()
+ .filter(|(index, _)| mask & (1 << index) != 0)
+ .map(|(_, (_, name))| *name)
+ .collect::<Vec<_>>();
+ let expected = if names.is_empty() {
+ "none".to_owned()
+ } else {
+ names.join(" ")
+ };
+ let source = if names.is_empty() {
+ "none".to_owned()
+ } else {
+ names.iter().rev().copied().collect::<Vec<_>>().join(" ")
+ };
+ let units: Vec<_> = source.encode_utf16().collect();
+ let Some(value) = parse(property_id::FONT_SYNTHESIS, TokenizerInput::Utf16(&units)) else {
+ missing.push(source);
+ continue;
+ };
+ assert_eq!(
+ text(&value, SerializationMode::Normal).into_utf16(),
+ expected.encode_utf16().collect::<Vec<_>>(),
+ "{source}"
+ );
+ for (index, (property, _)) in components.iter().enumerate() {
+ let expected = if mask & (1 << index) != 0 {
+ keyword::AUTO
+ } else {
+ keyword::NONE
+ };
+ assert!(
+ matches!(longhand(&value, *property), Some(StyleValueData::Keyword { keyword }) if *keyword == expected),
+ "{source}"
+ );
+ }
+ }
+ assert!(missing.is_empty(), "rejected valid combinations: {missing:?}");
+ }
+
+ #[test]
+ fn font_synthesis_four_keyword_invalid_values() {
+ for source in [
+ "position position",
+ "position none",
+ "none position",
+ "none none",
+ "weight style small-caps position weight",
+ "position unsupported",
+ "oblique-only",
+ ] {
+ let units: Vec<_> = source.encode_utf16().collect();
+ assert!(
+ parse(property_id::FONT_SYNTHESIS, TokenizerInput::Utf16(&units)).is_none(),
+ "{source}"
+ );
+ }
+ }
+
+ #[test]
+ fn font_synthesis_ordinary_and_css_wide_serialization_controls() {
+ for (source, expected) in [
+ ("none", "none"),
+ ("style weight", "weight style"),
+ ("small-caps weight style", "weight style small-caps"),
+ ("initial", "initial"),
+ ("inherit", "inherit"),
+ ("unset", "unset"),
+ ("revert", "revert"),
+ ("revert-layer", "revert-layer"),
+ ] {
+ let units: Vec<_> = source.encode_utf16().collect();
+ let value = parse(property_id::FONT_SYNTHESIS, TokenizerInput::Utf16(&units)).unwrap();
+ assert_eq!(
+ text(&value, SerializationMode::Normal).into_utf16(),
+ expected.encode_utf16().collect::<Vec<_>>()
+ );
+ }
+ for source in ["oblique-only", "weight weight", "none weight"] {
+ let units: Vec<_> = source.encode_utf16().collect();
+ assert!(
+ parse(property_id::FONT_SYNTHESIS, TokenizerInput::Utf16(&units)).is_none(),
+ "{source}"
+ );
+ }
+ }
}
fn longhand(value: &StyleValueData, property: u16) -> Option<&StyleValueData> {
@@ -459,6 +565,7 @@ pub(super) fn serialize(
(property_id::FONT_SYNTHESIS_WEIGHT, "weight"),
(property_id::FONT_SYNTHESIS_STYLE, "style"),
(property_id::FONT_SYNTHESIS_SMALL_CAPS, "small-caps"),
+ (property_id::FONT_SYNTHESIS_POSITION, "position"),
];
if components.iter().any(|(property, _)| {
!keyword_is(get(*property), keyword::NONE) && !keyword_is(get(*property), keyword::AUTO)
diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt
index d3a9fb667e7..1fe7f4e35b5 100644
--- a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt
+++ b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt
@@ -555,8 +555,8 @@ All supported properties and their default values exposed from CSSStylePropertie
'font-stretch': '100%'
'fontStyle': 'normal'
'font-style': 'normal'
-'fontSynthesis': 'weight style small-caps'
-'font-synthesis': 'weight style small-caps'
+'fontSynthesis': 'weight style small-caps position'
+'font-synthesis': 'weight style small-caps position'
'fontSynthesisPosition': 'auto'
'font-synthesis-position': 'auto'
'fontSynthesisSmallCaps': 'auto'
diff --git a/Tests/LibWeb/Text/expected/css/font-synthesis-shorthand-reset.txt b/Tests/LibWeb/Text/expected/css/font-synthesis-shorthand-reset.txt
new file mode 100644
index 00000000000..b4e50348d3f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/font-synthesis-shorthand-reset.txt
@@ -0,0 +1,31 @@
+none resets all four: ["none","none","none","none"]
+important expands to four: ["important","important","important","important"]
+none shorthand: "none"
+remove representable shorthand: "none"
+remove clears four: ["","","",""]
+position auto is represented: "weight position"
+remove position shorthand: "weight position"
+position removal clears four: ["","","",""]
+CSSOM replacement resets important position: ["auto","none","none","none"]
+CSSOM replacement clears priority: ["","","",""]
+mixed priority shorthand: ""
+mixed priority removal clears four: ["","","",""]
+typed keyword position: ["none","none","none","auto"]
+typed position roundtrip: "position"
+initial specified four: ["initial","initial","initial","initial"]
+initial shorthand: "initial"
+inherit specified four: ["inherit","inherit","inherit","inherit"]
+inherit shorthand: "inherit"
+unset specified four: ["unset","unset","unset","unset"]
+unset shorthand: "unset"
+revert specified four: ["revert","revert","revert","revert"]
+revert shorthand: "revert"
+revert-layer specified four: ["revert-layer","revert-layer","revert-layer","revert-layer"]
+revert-layer shorthand: "revert-layer"
+initial computed shorthand: "weight style small-caps position"
+initial computed position: "auto"
+inherit computed position: "none"
+unset computed position: "none"
+pending shorthand: "var(--s)"
+pending shorthand resets computed position: "none"
+position grammar: [true,false]
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt
index 33c94fe5319..2c63fc5ad91 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt
@@ -1,8 +1,8 @@
Harness status: OK
-Found 353 tests
+Found 354 tests
-349 Pass
+350 Pass
4 Fail
Pass accent-color
Pass border-collapse
@@ -30,6 +30,7 @@ Pass font-palette
Pass font-size
Pass font-size-adjust
Pass font-style
+Pass font-synthesis-position
Pass font-synthesis-small-caps
Pass font-synthesis-style
Pass font-synthesis-weight
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/inheritance.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/inheritance.txt
index 27664b83553..2693f8498e4 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/inheritance.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/inheritance.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 39 tests
-38 Pass
-1 Fail
+39 Pass
Pass Property font-family inherits
Pass Property font-feature-settings has initial value normal
Pass Property font-feature-settings inherits
@@ -21,7 +20,7 @@ Pass Property font-stretch has initial value 100%
Pass Property font-stretch inherits
Pass Property font-style has initial value normal
Pass Property font-style inherits
-Fail Property font-synthesis has initial value weight style small-caps position
+Pass Property font-synthesis has initial value weight style small-caps position
Pass Property font-synthesis inherits
Pass Property font-variant has initial value normal
Pass Property font-variant inherits
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/parsing/font-synthesis-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/parsing/font-synthesis-computed.txt
index a0083a2c926..41fa069348d 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/parsing/font-synthesis-computed.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/parsing/font-synthesis-computed.txt
@@ -2,26 +2,26 @@ Harness status: OK
Found 21 tests
-8 Pass
-13 Fail
+14 Pass
+7 Fail
Pass Property font-synthesis value 'none'
Pass Property font-synthesis value 'weight'
Pass Property font-synthesis value 'style'
Fail Property font-synthesis value 'oblique-only'
Pass Property font-synthesis value 'small-caps'
-Fail Property font-synthesis value 'position'
-Fail Property font-synthesis value 'small-caps position'
+Pass Property font-synthesis value 'position'
+Pass Property font-synthesis value 'small-caps position'
Pass Property font-synthesis value 'style small-caps'
-Fail Property font-synthesis value 'style position'
-Fail Property font-synthesis value 'style small-caps position'
+Pass Property font-synthesis value 'style position'
+Pass Property font-synthesis value 'style small-caps position'
Fail Property font-synthesis value 'oblique-only small-caps'
Fail Property font-synthesis value 'oblique-only position'
Fail Property font-synthesis value 'oblique-only small-caps position'
Pass Property font-synthesis value 'weight small-caps'
Pass Property font-synthesis value 'weight style'
Fail Property font-synthesis value 'weight oblique-only'
-Fail Property font-synthesis value 'weight position'
+Pass Property font-synthesis value 'weight position'
Pass Property font-synthesis value 'weight style small-caps'
-Fail Property font-synthesis value 'weight style small-caps position'
+Pass Property font-synthesis value 'weight style small-caps position'
Fail Property font-synthesis value 'weight oblique-only small-caps'
Fail Property font-synthesis value 'weight oblique-only small-caps position'
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/parsing/font-synthesis-valid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/parsing/font-synthesis-valid.txt
index 9d4cda0d35b..7ae3dd1a1a1 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/parsing/font-synthesis-valid.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/parsing/font-synthesis-valid.txt
@@ -2,14 +2,14 @@ Harness status: OK
Found 23 tests
-10 Pass
-13 Fail
+14 Pass
+9 Fail
Pass e.style['font-synthesis'] = "none" should set the property value
Pass e.style['font-synthesis'] = "weight" should set the property value
Pass e.style['font-synthesis'] = "style" should set the property value
Fail e.style['font-synthesis'] = "oblique-only" should set the property value
Pass e.style['font-synthesis'] = "small-caps" should set the property value
-Fail e.style['font-synthesis'] = "position" should set the property value
+Pass e.style['font-synthesis'] = "position" should set the property value
Pass e.style['font-synthesis'] = "style weight" should set the property value
Fail e.style['font-synthesis'] = "oblique-only weight" should set the property value
Pass e.style['font-synthesis'] = "small-caps weight" should set the property value
@@ -21,9 +21,9 @@ Pass e.style['font-synthesis'] = "small-caps style weight " should set the prope
Fail e.style['font-synthesis'] = "oblique-only weight small-caps" should set the property value
Fail e.style['font-synthesis'] = "oblique-only small-caps weight " should set the property value
Fail e.style['font-synthesis'] = "small-caps oblique-only weight " should set the property value
-Fail e.style['font-synthesis'] = "position style" should set the property value
+Pass e.style['font-synthesis'] = "position style" should set the property value
Fail e.style['font-synthesis'] = "position oblique-only" should set the property value
-Fail e.style['font-synthesis'] = "position weight style" should set the property value
+Pass e.style['font-synthesis'] = "position weight style" should set the property value
Fail e.style['font-synthesis'] = "position weight oblique-only" should set the property value
-Fail e.style['font-synthesis'] = "position weight small-caps style" should set the property value
+Pass e.style['font-synthesis'] = "position weight small-caps style" should set the property value
Fail e.style['font-synthesis'] = "position weight small-caps oblique-only" should set the property value
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/css/font-synthesis-shorthand-reset.html b/Tests/LibWeb/Text/input/css/font-synthesis-shorthand-reset.html
new file mode 100644
index 00000000000..84239d93dc3
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/font-synthesis-shorthand-reset.html
@@ -0,0 +1,79 @@
+<!doctype html>
+<script src="../include.js"></script>
+<div id="parent"><div id="target"></div></div>
+<script>
+ test(() => {
+ const parent = document.getElementById("parent");
+ const target = document.getElementById("target");
+ const style = target.style;
+ const names = ["weight", "style", "small-caps", "position"].map(name => `font-synthesis-${name}`);
+ const values = () => names.map(name => style.getPropertyValue(name));
+ const priorities = () => names.map(name => style.getPropertyPriority(name));
+ const check = (label, actual, expected) => {
+ println(`${label}: ${JSON.stringify(actual)}`);
+ if (JSON.stringify(actual) !== JSON.stringify(expected))
+ throw new Error(`${label}: expected ${JSON.stringify(expected)}`);
+ };
+ style.setProperty("font-synthesis-position", "auto", "important");
+ style.setProperty("font-synthesis", "none", "important");
+ check("none resets all four", values(), ["none", "none", "none", "none"]);
+ check("important expands to four", priorities(), ["important", "important", "important", "important"]);
+ check("none shorthand", style.getPropertyValue("font-synthesis"), "none");
+ check("remove representable shorthand", style.removeProperty("font-synthesis"), "none");
+ check("remove clears four", values(), ["", "", "", ""]);
+ style.setProperty("font-synthesis", "weight");
+ style.setProperty("font-synthesis-position", "auto");
+ check("position auto is represented", style.getPropertyValue("font-synthesis"), "weight position");
+ check("remove position shorthand", style.removeProperty("font-synthesis"), "weight position");
+ check("position removal clears four", values(), ["", "", "", ""]);
+ style.setProperty("font-synthesis-position", "auto", "important");
+ style.setProperty("font-synthesis", "weight");
+ check("CSSOM replacement resets important position", values(), ["auto", "none", "none", "none"]);
+ check("CSSOM replacement clears priority", priorities(), ["", "", "", ""]);
+ style.setProperty("font-synthesis-weight", "auto", "important");
+ check("mixed priority shorthand", style.getPropertyValue("font-synthesis"), "");
+ style.removeProperty("font-synthesis");
+ check("mixed priority removal clears four", values(), ["", "", "", ""]);
+ target.attributeStyleMap.set("font-synthesis", new CSSKeywordValue("position"));
+ check("typed keyword position", values(), ["none", "none", "none", "auto"]);
+ check("typed position roundtrip", String(target.attributeStyleMap.get("font-synthesis")), "position");
+ for (const keyword of ["initial", "inherit", "unset", "revert", "revert-layer"]) {
+ style.setProperty("font-synthesis", keyword);
+ check(`${keyword} specified four`, values(), [keyword, keyword, keyword, keyword]);
+ check(`${keyword} shorthand`, style.getPropertyValue("font-synthesis"), keyword);
+ }
+ style.setProperty("font-synthesis", "initial");
+ check(
+ "initial computed shorthand",
+ getComputedStyle(target).getPropertyValue("font-synthesis"),
+ "weight style small-caps position"
+ );
+ parent.style.setProperty("font-synthesis-position", "none");
+ for (const [keyword, expected] of [
+ ["initial", "auto"],
+ ["inherit", "none"],
+ ["unset", "none"],
+ ]) {
+ style.setProperty("font-synthesis", keyword);
+ check(
+ `${keyword} computed position`,
+ getComputedStyle(target).getPropertyValue("font-synthesis-position"),
+ expected
+ );
+ }
+ style.cssText = "";
+ style.setProperty("--s", "weight");
+ style.setProperty("font-synthesis", "var(--s)");
+ check("pending shorthand", style.getPropertyValue("font-synthesis"), "var(--s)");
+ check(
+ "pending shorthand resets computed position",
+ getComputedStyle(target).getPropertyValue("font-synthesis-position"),
+ "none"
+ );
+ check(
+ "position grammar",
+ [CSS.supports("font-synthesis", "position"), CSS.supports("font-synthesis", "oblique-only")],
+ [true, false]
+ );
+ });
+</script>