summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-contain/container-queries/font-relative-units.html
blob: 7f711ebf96c60efd793bcf4c03b92450cbfcdcd8 (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
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
<!doctype html>
<title>CSS Container Queries Test: font-relative units</title>
<link rel="help" href="https://drafts.csswg.org/css-contain-3/#size-container">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/cq-testcommon.js"></script>
<style>
  :root { font-size: 10px; line-height: 10px; }
  #em_container {
    container-type: inline-size;
    width: 100px;
    font-size: 100px;
  }
  #ex_container {
    container-type: inline-size;
    font-size: 50px;
    width: 10ex;
    height: 50rex;
  }
  #ch_container {
    container-type: inline-size;
    font-size: 50px;
    width: 10ch;
  }
  #ic_container {
    container-type: inline-size;
    font-size: 50px;
    width: 10ic;
  }
  #lh_container {
    container-type: inline-size;
    line-height: 50px;
    width: 10lh;
  }
  @container (width: 1em) {
    #em_test { color: green }
  }
  @container (width: 10rem) {
    #rem_test { color: green }
  }
  @container (width: 10ex) {
    #ex_test { color: green }
  }
  @container (49rex <= width <= 100rex) {
    #rex_test { color: green }
  }
  @container (width: 10ch) {
    #ch_test { color: green }
  }
  @container (width: 50rch) {
    #rch_test { color: green }
  }
  @container (width: 10ic) {
    #ic_test { color: green }
  }
  @container (width: 50ric) {
    #ric_test { color: green }
  }
  @container (width: 10lh) {
    #lh_test { color: green }
  }
  @container (width: 50rlh) {
    #rlh_test { color: green }
  }
</style>
<div id="em_container">
  <div id="em_test"></div>
  <div id="rem_test"></div>
</div>
<div id="ex_container">
  <div id="ex_test"></div>
  <div id="rex_test"></div>
</div>
<div id="ch_container">
  <div id="ch_test"></div>
  <div id="rch_test"></div>
</div>
<div id="ic_container">
  <div id="ic_test"></div>
  <div id="ric_test"></div>
</div>
<div id="lh_container">
  <div id="lh_test"></div>
  <div id="rlh_test"></div>
</div>
<script>
  setup(() => assert_implements_container_queries());

  const green = "rgb(0, 128, 0)";
  test(() => assert_equals(getComputedStyle(em_test).color, green), "em relative inline-size");
  test(() => assert_equals(getComputedStyle(rem_test).color, green), "rem relative inline-size");
  test(() => assert_equals(getComputedStyle(ex_test).color, green), "ex relative inline-size");
  test(() => assert_equals(getComputedStyle(rex_test).color, green), "rex relative inline-size");
  test(() => assert_equals(getComputedStyle(ch_test).color, green), "ch relative inline-size");
  test(() => assert_equals(getComputedStyle(rch_test).color, green), "rch relative inline-size");
  test(() => assert_equals(getComputedStyle(ic_test).color, green), "ic relative inline-size");
  test(() => assert_equals(getComputedStyle(ric_test).color, green), "ric relative inline-size");
  test(() => assert_equals(getComputedStyle(lh_test).color, green), "lh relative inline-size");
  test(() => assert_equals(getComputedStyle(rlh_test).color, green), "rlh relative inline-size");
</script>