blob: 8ace5b9550207480f53c95eebb48e0c56bb746f8 [file] [log] [blame]
Xiaocheng Hu74b1ccb2019-09-24 08:14:371<!DOCTYPE html>
2<link rel="help" href="https://drafts.csswg.org/css-values-4/#comp-func">
3<link rel="author" title="Xiaocheng Hu" href="mailto:[email protected]">
4<script src="/resources/testharness.js"></script>
5<script src="/resources/testharnessreport.js"></script>
6<script src="../support/computed-testcommon.js"></script>
7<div id="container" style="font-size: 20px">
8 <div id="target"></div>
9 <div id="reference"></div>
10</div>
11<script>
12const property = 'letter-spacing';
13
14function test_length_equals(value, expected) {
15 const reference = document.getElementById('reference');
16 reference.style[property] = '';
17 reference.style[property] = expected;
18 const computed = getComputedStyle(reference)[property];
19 test_computed_value(property, value, computed);
20}
21
22test_length_equals('clamp(10px, 20px, 30px)', '20px');
23test_length_equals('clamp(10px, 5px, 30px)', '10px');
24test_length_equals('clamp(10px, 35px, 30px)', '30px');
Emilio Cobos Álvarezc3328422021-04-21 15:00:3925test_length_equals('clamp(10px, 35px , 30px)', '30px');
26test_length_equals('clamp(10px, 35px /*foo*/, 30px)', '30px');
27test_length_equals('clamp(10px /* foo */ , 35px, 30px)', '30px');
28test_length_equals('clamp(10px , 35px, 30px)', '30px');
Xiaocheng Hu74b1ccb2019-09-24 08:14:3729
30// clamp(MIN, VAL, MAX) is identical to max(MIN, min(VAL, MAX)),
31// so MIN wins over MAX if they are in the wrong order.
32test_length_equals('clamp(30px, 100px, 20px)', '30px');
33
34</script>