summaryrefslogtreecommitdiffstats
path: root/layout/inspector/tests/test_isinheritableproperty.html
blob: 9f9340535cd68600edba1f4865807943368bcd59 (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
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=699592
-->
<head>
  <title>Test for InspectorUtils::isInheritedProperty</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <style>
    @property --css-registered-inherits {
      syntax: "*";
      inherits: true;
    }
    @property --css-registered-no-inherits {
      syntax: "*";
      inherits: false;
    }
  </style>
  <script>
    CSS.registerProperty({
      name: "--js-registered-inherits",
      syntax: "*",
      inherits: true,
    });
    CSS.registerProperty({
      name: "--js-registered-no-inherits",
      syntax: "*",
      inherits: false,
    });
  </script>
</head>
<body>
<pre id="test">
<script type="application/javascript">

function do_test() {
  const isInherited = (name) =>
    SpecialPowers.InspectorUtils.isInheritedProperty(document, name);

  is(isInherited("font-size"), true, "font-size is inherited.");
  is(isInherited("min-width"), false, "min-width is not inherited.");

  is(isInherited("font"), true, "shorthand font property is inherited.");

  is(isInherited("border"), false, "shorthand border property not inherited.");
  is(isInherited("garbage"), false, "Unknown property isn't inherited.");

  info("Checking isInheritedProperty result on custom properties");
  is(isInherited("--unregistered-var"),true,
    "Unregistered custom property is inherited."
  );
  is(
    isInherited("--css-registered-inherits"),
    true,
    "Returns true for @property that inherits"
  );
  is(
    isInherited("--css-registered-no-inherits"),
    false,
    "Returns false for @property that does not inherits"
  );
  is(
    isInherited("--js-registered-inherits"),
    true,
    "Returns true for property registered in JS that inherits"
  );
  is(
    isInherited("--js-registered-no-inherits"),
    false,
    "Returns false for property registered in JS that does not inherits"
  );

  SimpleTest.finish();
}

SimpleTest.waitForExplicitFinish();
addLoadEvent(do_test);


</script>
</pre>
</body>
</html>