summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-contain/container-queries/registered-color-style-queries.html
blob: 6e2bfb896bbaa67bcb6933bebf13829c0f0a74e8 (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
<!DOCTYPE html>
<title>CSS Container Queries Test: registered color syntax style queries</title>
<link rel="help" href="https://drafts.csswg.org/css-contain-3/#style-container">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/cq-testcommon.js"></script>
<style>
  @property --reg-color {
    syntax: "<color>";
    inherits: false;
    initial-value: red;
  }

  #light { color-scheme: light; }
  #dark { color-scheme: dark; }
  .container { --reg-color: light-dark(white, black); }

  @container style(--reg-color: white) {
    #t1 { color: green; }
  }
  @container style(--reg-color: black) {
    #t2 { color: green; }
  }
</style>
<div id="light" class="container">
  <div id="t1"></div>
</div>
<div id="dark" class="container">
  <div id="t2"></div>
</div>
<script>
  const green = "rgb(0, 128, 0)";

  test(() => {
    assert_equals(getComputedStyle(t1).color, green);
  }, "Registered color with light color-scheme and light-dark()");

  test(() => {
    assert_equals(getComputedStyle(t2).color, green);
  }, "Registered color with dark color-scheme and light-dark()");
</script>