summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-typed-om/the-stylepropertymap/properties/font-weight.html
blob: 7230cfb721c05482af9246f71af22d5001a8e073 (plain)
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
<!doctype html>
<meta charset="utf-8">
<title>'font-weight' property</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-get">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-set">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#property-stle-value-normalization">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/testhelper.js"></script>
<script src="resources/testsuite.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';

function assert_is_font_weight(weight, result) {
  assert_style_value_equals(result, new CSSUnitValue(weight, 'number'));
}

runPropertyTests('font-weight', [
  {
    syntax: 'normal',
    computed: (_, result) => assert_is_font_weight(400, result)
  },
  {
    syntax: 'bold',
    computed: (_, result) => assert_is_font_weight(700, result)
  },
  {
    syntax: 'bolder',
    computed: (_, result) => assert_is_unit('number', result)
  },
  {
    syntax: 'lighter',
    computed: (_, result) => assert_is_unit('number', result)
  },
  {
    syntax: '<number>',
    specified: (input, result) => {
      if (input instanceof CSSUnitValue &&
          (input.value < 1 || input.value > 1000))
        assert_style_value_equals(result, new CSSMathSum(input));
      else
        assert_style_value_equals(result, input);
    }
  },
]);

</script>