File: test_getRegisteredCustomProperty.html

package info (click to toggle)
firefox 147.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,484 kB
  • sloc: cpp: 7,607,246; javascript: 6,533,185; ansic: 3,775,227; python: 1,415,393; xml: 634,561; asm: 438,951; java: 186,241; sh: 62,752; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (133 lines) | stat: -rw-r--r-- 3,607 bytes parent folder | download
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
<!DOCTYPE HTML>
<html>

<head>
  <title>Test InspectorUtils.getCSSRegisteredProperty</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  <style>
    @property --color-1 {
      syntax: "<color>";
      inherits: true;
      initial-value: blue;
    }

    @property --color-2 {
      syntax: "*";
      inherits: false;
    }
  </style>
</head>

<body>
  <code>InspectorUtils.getCSSRegisteredProperty</code>

  <script>
    "use strict";

    /** Test for InspectorUtils.getCSSRegisteredProperty */

    const { Assert } = SpecialPowers.ChromeUtils.importESModule(
      "resource://testing-common/Assert.sys.mjs"
    );
    const InspectorUtils = SpecialPowers.InspectorUtils;

    CSS.registerProperty({
      name: "--length-1",
      syntax: "<length>",
      initialValue: "10px",
      inherits: true,
    });
    CSS.registerProperty({
      name: "--length-2",
      syntax: "foo | <integer>+ | <percentage> | <length># | auto",
      initialValue: "100vw",
      inherits: true
    });
    CSS.registerProperty({
      name: "--length-3",
      syntax: "*",
      inherits: false
    });
    CSS.registerProperty({
      name: "--length-4",
      syntax: "*",
      initialValue: "",
      inherits: false
    });

    is(
      InspectorUtils.getCSSRegisteredProperty(document, "--unknown"),
      null,
      "Returns null when the name does not match a registered property"
    );
    is(
      InspectorUtils.getCSSRegisteredProperty(document, ""),
      null,
      "Returns null when passed an empty string"
    );
    is(
      InspectorUtils.getCSSRegisteredProperty(document, "color-1"),
      null,
      "Returns null when passed a property name without leading --"
    );

    Assert.deepEqual(
      InspectorUtils.getCSSRegisteredProperty(document, "--color-1"), {
      name: "--color-1",
      syntax: "<color>",
      inherits: true,
      initialValue: "blue",
      fromJS: false,
    }, `Got expected registered property definition for "${"--color-1"}"`);

    Assert.deepEqual(
      InspectorUtils.getCSSRegisteredProperty(document, "--color-2"), {
      name: "--color-2",
      syntax: "*",
      inherits: false,
      initialValue: null,
      fromJS: false,
    }, `Got expected registered property definition for "${"--color-2"}"`);

    Assert.deepEqual(
      InspectorUtils.getCSSRegisteredProperty(document, "--length-1"), {
      name: "--length-1",
      syntax: "<length>",
      inherits: true,
      initialValue: "10px",
      fromJS: true,
    }, `Got expected registered property definition for "${"--length-1"}"`);

    Assert.deepEqual(
      InspectorUtils.getCSSRegisteredProperty(document, "--length-2"), {
      name: "--length-2",
      syntax: "foo | <integer>+ | <percentage> | <length># | auto",
      inherits: true,
      initialValue: "100vw",
      fromJS: true,
    }, `Got expected registered property definition for "${"--length-2"}"`);

    Assert.deepEqual(
      InspectorUtils.getCSSRegisteredProperty(document, "--length-3"), {
      name: "--length-3",
      syntax: "*",
      inherits: false,
      initialValue: null,
      fromJS: true,
    }, `Got expected registered property definition for "${"--length-3"}"`);

    Assert.deepEqual(
      InspectorUtils.getCSSRegisteredProperty(document, "--length-4"), {
      name: "--length-4",
      syntax: "*",
      inherits: false,
      initialValue: "",
      fromJS: true,
    }, `Got expected registered property definition for "${"--length-4"}"`);

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

</html>