Tests: Reimport font-stretch tests as font-width

Corresponds to 7c0c4806bb
This commit is contained in:
Sam Atkins
2025-04-02 12:45:16 +01:00
parent cbb169820a
commit bd7a08da3b
Notes: github-actions[bot] 2025-04-02 13:56:25 +00:00
9 changed files with 142 additions and 102 deletions

View File

@@ -1,41 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Fonts Module Level 4: getComputedStyle().fontStretch</title>
<link rel="help" href="https://www.w3.org/TR/css-fonts-4/#font-stretch-prop">
<meta name="assert" content="font-stretch computed value is a percentage.">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../css/support/computed-testcommon.js"></script>
<style>
#container {
container-type: inline-size;
width: 10px;
}
</style>
</head>
<body>
<div id="container">
<div id="target"></div>
</div>
<script>
test_computed_value('font-stretch', 'ultra-condensed', '50%');
test_computed_value('font-stretch', 'extra-condensed', '62.5%');
test_computed_value('font-stretch', 'condensed', '75%');
test_computed_value('font-stretch', 'semi-condensed', '87.5%');
test_computed_value('font-stretch', 'normal', '100%');
test_computed_value('font-stretch', 'semi-expanded', '112.5%');
test_computed_value('font-stretch', 'expanded', '125%');
test_computed_value('font-stretch', 'extra-expanded', '150%');
test_computed_value('font-stretch', 'ultra-expanded', '200%');
test_computed_value('font-stretch', '234.5%');
test_computed_value('font-stretch', 'calc(100%)', '100%');
test_computed_value('font-stretch', 'calc(0%)', '0%');
test_computed_value('font-stretch', 'calc(-100%)', '0%');
test_computed_value('font-stretch', 'calc(100% + 100%)', '200%');
test_computed_value('font-stretch', 'calc(100% + (sign(20cqw - 10px) * 5%))', '95%');
</script>
</body>
</html>

View File

@@ -1,21 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Fonts Module Level 4: parsing font-stretch with invalid values</title>
<link rel="help" href="https://www.w3.org/TR/css-fonts-4/#font-stretch-prop">
<meta name="assert" content="font-stretch supports only the grammar 'normal | <percentage [0,∞]> | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded'.">
<meta name="assert" content="Values less than 0% are invalid.">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_invalid_value('font-stretch', 'auto');
test_invalid_value('font-stretch', 'normal, ultra-condensed');
test_invalid_value('font-stretch', 'condensed expanded');
test_invalid_value('font-stretch', '-50%');
</script>
</body>
</html>

View File

@@ -1,32 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Fonts Module Level 4: parsing font-stretch with valid values</title>
<link rel="help" href="https://www.w3.org/TR/css-fonts-4/#font-stretch-prop">
<meta name="assert" content="font-stretch supports the full grammar 'normal | <percentage [0,∞]> | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded'.">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_valid_value('font-stretch', 'normal');
test_valid_value('font-stretch', 'ultra-condensed');
test_valid_value('font-stretch', 'extra-condensed');
test_valid_value('font-stretch', 'condensed');
test_valid_value('font-stretch', 'semi-condensed');
test_valid_value('font-stretch', 'semi-expanded');
test_valid_value('font-stretch', 'expanded');
test_valid_value('font-stretch', 'extra-expanded');
test_valid_value('font-stretch', 'ultra-expanded');
test_valid_value('font-stretch', '234.5%');
test_valid_value('font-stretch', 'calc(100%)');
test_valid_value('font-stretch', 'calc(0%)');
test_valid_value('font-stretch', 'calc(-100%)');
test_valid_value('font-stretch', 'calc(100% + 100%)', 'calc(200%)');
test_valid_value('font-stretch', 'calc(100% + (sign(20cqw - 10px) * 5%))', 'calc(100% + (5% * sign(20cqw - 10px)))');
</script>
</body>
</html>

View File

@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Fonts Module Level 4: getComputedStyle().fontWidth</title>
<link rel="help" href="https://www.w3.org/TR/css-fonts-4/#font-width-prop">
<meta name="assert" content="font-width computed value is a percentage.">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../css/support/computed-testcommon.js"></script>
<style>
#container {
container-type: inline-size;
width: 10px;
}
</style>
</head>
<body>
<div id="container">
<div id="target"></div>
</div>
<script>
for (const property of ['font-width','font-stretch']) {
test_computed_value(property, 'ultra-condensed', '50%');
test_computed_value(property, 'extra-condensed', '62.5%');
test_computed_value(property, 'condensed', '75%');
test_computed_value(property, 'semi-condensed', '87.5%');
test_computed_value(property, 'normal', '100%');
test_computed_value(property, 'semi-expanded', '112.5%');
test_computed_value(property, 'expanded', '125%');
test_computed_value(property, 'extra-expanded', '150%');
test_computed_value(property, 'ultra-expanded', '200%');
test_computed_value(property, '234.5%');
test_computed_value(property, 'calc(100%)', '100%');
test_computed_value(property, 'calc(0%)', '0%');
test_computed_value(property, 'calc(-100%)', '0%');
test_computed_value(property, 'calc(100% + 100%)', '200%');
test_computed_value(property, 'calc(100% + (sign(20cqw - 10px) * 5%))', '95%');
}
</script>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Fonts Module Level 4: parsing font-width with invalid values</title>
<link rel="help" href="https://www.w3.org/TR/css-fonts-4/#font-width-prop">
<meta name="assert" content="font-width supports only the grammar 'normal | <percentage [0,∞]> | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded'.">
<meta name="assert" content="Values less than 0% are invalid.">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
for (const property of ['font-width','font-stretch']) {
test_invalid_value(property, 'auto');
test_invalid_value(property, 'normal, ultra-condensed');
test_invalid_value(property, 'condensed expanded');
test_invalid_value(property, '-50%');
}
</script>
</body>
</html>

View File

@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Fonts Module Level 4: parsing font-width with valid values</title>
<link rel="help" href="https://www.w3.org/TR/css-fonts-4/#font-width-prop">
<meta name="assert" content="font-width supports the full grammar 'normal | <percentage [0,∞]> | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded'.">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
for (const property of ['font-width','font-stretch']) {
test_valid_value(property, 'normal');
test_valid_value(property, 'ultra-condensed');
test_valid_value(property, 'extra-condensed');
test_valid_value(property, 'condensed');
test_valid_value(property, 'semi-condensed');
test_valid_value(property, 'semi-expanded');
test_valid_value(property, 'expanded');
test_valid_value(property, 'extra-expanded');
test_valid_value(property, 'ultra-expanded');
test_valid_value(property, '234.5%');
test_valid_value(property, 'calc(100%)');
test_valid_value(property, 'calc(0%)');
test_valid_value(property, 'calc(-100%)');
test_valid_value(property, 'calc(100% + 100%)', 'calc(200%)');
test_valid_value(property, 'calc(100% + (sign(20cqw - 10px) * 5%))', 'calc(100% + (5% * sign(20cqw - 10px)))');
}
</script>
</body>
</html>