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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-values-4/#comp-func">
<link rel="help" href="https://drafts.csswg.org/css-values-4/#lengths">
<link rel="help" href="https://drafts.csswg.org/css-values-4/#calc-type-checking">
<link rel="author" title="Xiaocheng Hu" href="mailto:xiaochengh@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/numeric-testcommon.js"></script>
<div id="container" style="font-size: 20px">
<div id="target"></div>
</div>
<script>
const property = 'letter-spacing';
function test_length_equals(value, expected, msgExtra) {
test_math_used(value, expected, {msgExtra});
}
// Identity tests
test_length_equals('min(1px)', '1px');
test_length_equals('min(1cm)', '1cm');
test_length_equals('min(1mm)', '1mm');
test_length_equals('min(1Q)', '1Q');
test_length_equals('min(1in)', '1in');
test_length_equals('min(1pc)', '1pc');
test_length_equals('min(1pt)', '1pt');
test_length_equals('min(1em)', '1em');
test_length_equals('min(1ex)', '1ex');
test_length_equals('min(1ch)', '1ch');
test_length_equals('min(1rem)', '1rem');
test_length_equals('min(1vh)', '1vh');
test_length_equals('min(1vw)', '1vw');
test_length_equals('min(1vmin)', '1vmin');
test_length_equals('min(1vmax)', '1vmax');
test_length_equals('max(1px)', '1px');
test_length_equals('max(1cm)', '1cm');
test_length_equals('max(1mm)', '1mm');
test_length_equals('max(1Q)', '1Q');
test_length_equals('max(1in)', '1in');
test_length_equals('max(1pc)', '1pc');
test_length_equals('max(1pt)', '1pt');
test_length_equals('max(1em)', '1em');
test_length_equals('max(1ex)', '1ex');
test_length_equals('max(1ch)', '1ch');
test_length_equals('max(1rem)', '1rem');
test_length_equals('max(1vh)', '1vh');
test_length_equals('max(1vw)', '1vw');
test_length_equals('max(1vmin)', '1vmin');
test_length_equals('max(1vmax)', '1vmax');
// Comparisons between same units
test_length_equals('min(1px, 2px)', '1px');
test_length_equals('min(1cm, 2cm)', '1cm');
test_length_equals('min(1mm, 2mm)', '1mm');
test_length_equals('min(1Q, 2Q)', '1Q');
test_length_equals('min(1in, 2in)', '1in');
test_length_equals('min(1pc, 2pc)', '1pc');
test_length_equals('min(1pt, 2pt)', '1pt');
test_length_equals('min(1em, 2em)', '1em');
test_length_equals('min(1ex, 2ex)', '1ex');
test_length_equals('min(1ch, 2ch)', '1ch');
test_length_equals('min(1rem, 2rem)', '1rem');
test_length_equals('min(1vh, 2vh)', '1vh');
test_length_equals('min(1vw, 2vw)', '1vw');
test_length_equals('min(1vmin, 2vmin)', '1vmin');
test_length_equals('min(1vmax, 2vmax)', '1vmax');
test_length_equals('max(1px, 2px)', '2px');
test_length_equals('max(1cm, 2cm)', '2cm');
test_length_equals('max(1mm, 2mm)', '2mm');
test_length_equals('max(1Q, 2Q)', '2Q');
test_length_equals('max(1in, 2in)', '2in');
test_length_equals('max(1pc, 2pc)', '2pc');
test_length_equals('max(1pt, 2pt)', '2pt');
test_length_equals('max(1em, 2em)', '2em');
test_length_equals('max(1ex, 2ex)', '2ex');
test_length_equals('max(1ch, 2ch)', '2ch');
test_length_equals('max(1rem, 2rem)', '2rem');
test_length_equals('max(1vh, 2vh)', '2vh');
test_length_equals('max(1vw, 2vw)', '2vw');
test_length_equals('max(1vmin, 2vmin)', '2vmin');
test_length_equals('max(1vmax, 2vmax)', '2vmax');
// Comparisons between different absolute units
test_length_equals('min(95px, 1in)', '95px');
test_length_equals('max(95px, 1in)', '1in');
// Comparisons between absolute and relative units
test_length_equals('min(15px, 1em)', '15px');
test_length_equals('min(25px, 1em)', '20px');
test_length_equals('max(15px, 1em)', '20px');
test_length_equals('max(25px, 1em)', '25px');
document.getElementById('container').style.fontSize = '10px';
test_length_equals('min(15px, 1em)', '10px', 'fontSize=10px');
test_length_equals('max(15px, 2em)', '20px', 'fontSize=10px');
document.getElementById('container').style.fontSize = '20px';
// Nestings
test_length_equals('min(25px, max(15px, 1em))', '20px');
test_length_equals('max(15px, min(25px, 1em))', '20px');
// General calculations
test_length_equals('calc(min(1em, 21px) + 10px)', '30px');
test_length_equals('calc(min(1em, 21px) - 10px)', '10px');
test_length_equals('calc(min(1em, 21px) * 2', '40px');
test_length_equals('calc(min(1em, 21px) / 2', '10px');
test_length_equals('calc(max(1em, 19px) + 10px)', '30px');
test_length_equals('calc(max(1em, 19px) - 10px)', '10px');
test_length_equals('calc(max(1em, 19px) * 2', '40px');
test_length_equals('calc(max(1em, 19px) / 2', '10px');
test_length_equals('calc(min(1em, 21px) + max(0.9em, 20px))', '40px');
test_length_equals('calc(min(1em + 1px, 22px) - max(0.9em, 20px))', '1px');
</script>
|