summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/cssom/getComputedStyle-resolved-colors.html
blob: da4fddbc24313c1c0c5c629dcee5cfc2f5a65e23 (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
<!doctype html>
<meta charset="utf-8">
<title>CSSOM: resolved values of certain color properties are used values</title>
<link rel="help" href="https://drafts.csswg.org/cssom/#resolved-value">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
  #target {
    background-color: Menu;
    border: 1px solid Menu;
    box-shadow: 1px 1px Menu;
    caret-color: Menu;
    color: Menu;
    outline-color: Menu;
  }
</style>
<div id="target"></div>
<script>
  const properties_to_test = [
    "background-color",
    "border-block-end-color",
    "border-block-start-color",
    "border-bottom-color",
    "border-inline-end-color",
    "border-inline-start-color",
    "border-left-color",
    "border-right-color",
    "border-top-color",
    "box-shadow",
    "caret-color",
    "color",
    "outline-color",
  ];

  for (const property of properties_to_test) {
    test(function() {
      let resolved_value =
        window.getComputedStyle(document.getElementById("target")).getPropertyValue(property);
      assert_regexp_match(resolved_value, /^rgb[a]?\(/);
    }, "The resolved value for '" + property + "' is the used value");
  }
</script>