-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathfont-face-width.html
More file actions
63 lines (58 loc) · 1.75 KB
/
Copy pathfont-face-width.html
File metadata and controls
63 lines (58 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!doctype html>
<meta charset="utf-8">
<title>CSS Fonts: parsing the @font-face font-width descriptor</title>
<link rel="help" href="https://drafts.csswg.org/css-fonts-4/#font-prop-desc">
<meta name="assert" content="The font-width descriptor is an alias for font-stretch and accepts the @font-face width descriptor grammar.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style id="test-style"></style>
<script>
const sheet = document.getElementById("test-style").sheet;
const validValues = [
"auto",
"normal",
"condensed",
"125%",
"75% 125%",
];
const invalidValues = [
"-1%",
"125",
"condensed expanded normal",
"normal, expanded",
];
for (const descriptor of ["font-width", "font-stretch"]) {
for (const value of validValues) {
test(() => {
sheet.insertRule(`@font-face { ${descriptor}: ${value}; }`);
try {
assert_equals(sheet.cssRules[0].style.getPropertyValue("font-stretch"), value);
} finally {
sheet.deleteRule(0);
}
}, `${descriptor}: ${value} is valid`);
}
for (const value of invalidValues) {
test(() => {
sheet.insertRule(`@font-face { ${descriptor}: ${value}; }`);
try {
assert_equals(sheet.cssRules[0].style.getPropertyValue("font-stretch"), "");
} finally {
sheet.deleteRule(0);
}
}, `${descriptor}: ${value} is invalid`);
}
}
test(() => {
sheet.insertRule(`@font-face {
font-stretch: condensed;
font-width: expanded;
}`);
try {
const descriptors = sheet.cssRules[0].style;
assert_equals(descriptors.getPropertyValue("font-stretch"), "expanded");
} finally {
sheet.deleteRule(0);
}
}, "font-width and font-stretch address the same descriptor");
</script>