Skip to content

Commit

Permalink
Fix crash during serialization of the font shorthand.
Browse files Browse the repository at this point in the history
It's not clear whether calc() expressions should be converted into
font keywords; not doing it seems like the most consistent handling,
given that calc() is never converted into literals anywhere else,
but it clashes with existing practice.

Bug: 40946458
Change-Id: I60c4fa354ec016ceeb872b7dabbef14d69412814
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6057817
Commit-Queue: Steinar H Gunderson <[email protected]>
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1389776}
  • Loading branch information
Steinar H. Gunderson authored and chromium-wpt-export-bot committed Nov 29, 2024
1 parent f1338db commit 3321d7e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions css/css-fonts/font-shorthand-serialization-font-stretch.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,18 @@
assert_equals(div.style.fontStretch, "50.01%");
assert_equals(div.style.font, "");
}, "Percentages which cannot be transformed into keywords should prevent the font shorthand from serializing, but not fontStretch");

test(function() {
const div = document.getElementById("test");

// This isn't well-specified, but appears to be consistent across browsers.
div.style.fontStretch = "calc(50%)";
assert_equals(div.style.fontStretch, "calc(50%)");
assert_equals(div.style.font, "ultra-condensed medium serif");

div.style.fontStretch = "calc(50% + 25% * sign(100em - 1px))";
assert_equals(div.style.fontStretch, "calc(50% + 25% * sign(100em - 1px))");
assert_equals(div.style.font, "");
}, "calc() transformation into keywords");

</script>

0 comments on commit 3321d7e

Please sign in to comment.