summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-contain/container-queries/container-inner-at-rules.html
blob: ac1800292984023262d5af86d96993139f671736 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!doctype html>
<title>@container: inner at-rules</title>
<link rel="help" href="https://drafts.csswg.org/css-contain-3/#container-rule">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/cq-testcommon.js"></script>
<style>
  #container {
    container-type: size;
    width: 100px;
    height: 100px;
  }

</style>
<div id=container>
  <div id=child></div>
</div>

<script>
  setup(() => assert_implements_container_queries());
</script>

<style>
  @container (width: 100px) {
    @keyframes anim1 {
      from { --anim1:true; }
      to { --anim1:true; }
    }
  }

  @container (width: 200px) {
    @keyframes anim2 {
      from { --anim2:true; }
      to { --anim2:true; }
    }
  }

  #child { animation: anim1 10s paused, anim2 10s paused; }
</style>
<script>
  test(() => {
    assert_equals(getComputedStyle(child).getPropertyValue('--anim1'), 'true');
    assert_equals(getComputedStyle(child).getPropertyValue('--anim2'), 'true');
  }, '@keyframes is defined regardless of evaluation');
</script>


<style>
  @container (width: 100px) {
    @property --prop1 {
      syntax: "<length>";
      inherits: false;
      initial-value: 0px;
    }
  }

  @container (width: 200px) {
    @property --prop2 {
      syntax: "<length>";
      inherits: false;
      initial-value: 0px;
    }
  }

  #child {
    font-size: 20px;
    --prop1:1em;
    --prop2:2em;
  }
</style>
<script>
  test(() => {
    assert_equals(getComputedStyle(child).getPropertyValue('--prop1'), '20px');
    assert_equals(getComputedStyle(child).getPropertyValue('--prop2'), '40px');
  }, '@property is defined regardless of evaluation');
</script>


<style>
  @container (width: 100px) {
    @layer a;
  }

  @container (width: 200px) {
    @layer b;
  }

  @layer b {
    #child { --layer:b; }
  }

  @layer a {
    #child { --layer:a; }
  }

</style>
<script>
  test(() => {
    assert_equals(getComputedStyle(child).getPropertyValue('--layer'), 'b');
  }, '@layer order respected regardless of evaluation');
</script>


<style>
  @container (width: 100px) {
    @font-face {
      font-family: Font1;
      font-stretch: 50% 200%;
      src: url(/fonts/Ahem.ttf);
    }
  }

  @container (width: 200px) {
    @font-face {
      font-family: Font2;
      font-stretch: 40% 190%;
      src: url(/fonts/Ahem.ttf);
    }
  }

</style>
<script>
  promise_test(async (t) => {
    const fonts1 = await document.fonts.load("20px Font1");
    assert_not_equals(fonts1[0], undefined);
    assert_equals(fonts1[0].stretch, "50% 200%");

    const fonts2 = await document.fonts.load("20px Font2");
    assert_not_equals(fonts2[0], undefined);
    assert_equals(fonts2[0].stretch, "40% 190%");
  }, '@font-face is defined regardless of evaluation');
</script>


<style>
  @container (width: 100px) {
    /* Assumed to be false */
    @media (width: 0px) {
      #child { --media1:true; }
    }
    /* Assumed to be true */
    @media (min-width: 0px) {
      #child { --media2:true; }
    }
  }

  /* Same again, but with failing container query. */
  @container (width: 200px) {
    @media (width: 0px) {
      #child { --media3:true; }
    }
    @media (min-width: 0px) {
      #child { --media4:true; }
    }
  }

</style>
<script>
  test(() => {
    assert_equals(getComputedStyle(child).getPropertyValue('--media1'), '');
    assert_equals(getComputedStyle(child).getPropertyValue('--media2'), 'true');
    assert_equals(getComputedStyle(child).getPropertyValue('--media3'), '');
    assert_equals(getComputedStyle(child).getPropertyValue('--media4'), '');
  }, '@media works inside @container');
</script>


<style>
  @container (width: 100px) {
    @supports (width: 500kg) {
      #child { --supports1:true; }
    }
    @supports (width: 500px) {
      #child { --supports2:true; }
    }
  }

  /* Same again, but with failing container query. */
  @container (width: 200px) {
    @supports (width: 500kg) {
      #child { --supports3:true; }
    }
    @supports (width: 500px) {
      #child { --supports4:true; }
    }
  }

</style>
<script>
  test(() => {
    assert_equals(getComputedStyle(child).getPropertyValue('--supports1'), '');
    assert_equals(getComputedStyle(child).getPropertyValue('--supports2'), 'true');
    assert_equals(getComputedStyle(child).getPropertyValue('--supports3'), '');
    assert_equals(getComputedStyle(child).getPropertyValue('--supports4'), '');
  }, '@supports works inside @container');
</script>