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
197
|
<!DOCTYPE html>
<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api-1/#cssom">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
@property --valid {
syntax: "<color> | none";
inherits: false;
initial-value: red;
}
@property --valid-reverse {
initial-value: 0px;
inherits: true;
syntax: "<length>";
}
@property --valid-universal {
syntax: "*";
inherits: false;
}
@property --valid-whitespace {
syntax: " <color>+ ";
inherits: false;
initial-value: red, blue;
}
@property --vALId {
syntax: "<color> | none";
inherits: false;
initial-value: red;
}
@property --no-descriptors {
}
@property --no-syntax {
inherits: false;
initial-value: red;
}
@property --no-inherits {
syntax: "<color> | none";
initial-value: red;
}
@property --no-initial-value {
syntax: "<color> | none";
inherits: false;
}
@property --syntax-only {
syntax: "<color> | none";
}
@property --inherits-only {
inherits: true;
}
@property --initial-value-only {
initial-value: red;
}
/* U+0009 CHARACTER TABULATION */
@property --tab\9 tab { }
</style>
<script>
function find_at_property_rule(name) {
for (let rule of document.styleSheets[0].cssRules) {
if (rule.constructor.name != "CSSPropertyRule")
continue;
if (rule.name == name)
return rule;
}
return null;
}
function test_css_text(name, expected) {
test(() => {
let rule = find_at_property_rule(name);
assert_true(!!rule);
assert_equals(rule.cssText, expected);
}, `Rule for ${name} has expected cssText`);
}
function test_name(name) {
test(() => {
let rule = find_at_property_rule(name);
assert_true(!!rule);
assert_equals(rule.name, name);
}, `Rule for ${name} returns expected value for CSSPropertyRule.name`);
}
function test_syntax(name, expected) {
test(() => {
let rule = find_at_property_rule(name);
assert_true(!!rule);
assert_equals(rule.syntax, expected);
}, `Rule for ${name} returns expected value for CSSPropertyRule.syntax`);
}
function test_inherits(name, expected) {
test(() => {
let rule = find_at_property_rule(name);
assert_true(!!rule);
assert_equals(rule.inherits, expected);
}, `Rule for ${name} returns expected value for CSSPropertyRule.inherits`);
}
function test_initial_value(name, expected) {
test(() => {
let rule = find_at_property_rule(name);
assert_true(!!rule);
assert_equals(rule.initialValue, expected);
}, `Rule for ${name} returns expected value for CSSPropertyRule.initialValue`);
}
// CSSPropertyRule.cssText
test_css_text('--valid', '@property --valid { syntax: "<color> | none"; inherits: false; initial-value: red; }');
test_css_text('--valid-reverse', '@property --valid-reverse { syntax: "<length>"; inherits: true; initial-value: 0px; }');
test_css_text('--valid-universal', '@property --valid-universal { syntax: "*"; inherits: false; }');
test_css_text('--valid-whitespace', '@property --valid-whitespace { syntax: " <color>+ "; inherits: false; initial-value: red, blue; }');
test_css_text('--vALId', '@property --vALId { syntax: "<color> | none"; inherits: false; initial-value: red; }');
test_css_text('--no-descriptors', '@property --no-descriptors { }');
test_css_text('--no-syntax', '@property --no-syntax { inherits: false; initial-value: red; }');
test_css_text('--no-inherits', '@property --no-inherits { syntax: "<color> | none"; initial-value: red; }');
test_css_text('--no-initial-value', '@property --no-initial-value { syntax: "<color> | none"; inherits: false; }');
test_css_text('--syntax-only', '@property --syntax-only { syntax: "<color> | none"; }');
test_css_text('--inherits-only', '@property --inherits-only { inherits: true; }');
test_css_text('--initial-value-only', '@property --initial-value-only { initial-value: red; }');
test_css_text('--tab\ttab', '@property --tab\\9 tab { }');
// CSSRule.type
test(() => {
let rule = find_at_property_rule('--valid');
assert_equals(rule.type, 0);
}, 'CSSRule.type returns 0');
// CSSPropertyRule.name
test_name('--valid');
test_name('--valid-reverse');
test_name('--valid-universal');
test_name('--valid-whitespace');
test_name('--vALId');
test_name('--no-descriptors');
test_name('--no-syntax');
test_name('--no-inherits');
test_name('--no-initial-value');
test_name('--syntax-only');
test_name('--inherits-only');
test_name('--initial-value-only');
// CSSPropertyRule.syntax
test_syntax('--valid', '<color> | none');
test_syntax('--valid-reverse', '<length>');
test_syntax('--valid-universal', '*');
test_syntax('--valid-whitespace', ' <color>+ ');
test_syntax('--vALId', '<color> | none');
test_syntax('--no-descriptors', '');
test_syntax('--no-syntax', '');
test_syntax('--no-inherits', '<color> | none');
test_syntax('--no-initial-value', '<color> | none');
test_syntax('--syntax-only', '<color> | none');
test_syntax('--inherits-only', '');
test_syntax('--initial-value-only', '');
// CSSPropertyRule.inherits
test_inherits('--valid', false);
test_inherits('--valid-reverse', true);
test_inherits('--valid-universal', false);
test_inherits('--valid-whitespace', false);
test_inherits('--vALId', false);
test_inherits('--no-descriptors', false);
test_inherits('--no-syntax', false);
test_inherits('--no-inherits', false);
test_inherits('--no-initial-value', false);
test_inherits('--syntax-only', false);
test_inherits('--inherits-only', true);
test_inherits('--initial-value-only', false);
// CSSPropertyRule.initialValue
test_initial_value('--valid', 'red');
test_initial_value('--valid-reverse', '0px');
test_initial_value('--valid-universal', null);
test_initial_value('--valid-whitespace', 'red, blue');
test_initial_value('--vALId', 'red');
test_initial_value('--no-descriptors', null);
test_initial_value('--no-syntax', 'red');
test_initial_value('--no-inherits', 'red');
test_initial_value('--no-initial-value', null);
test_initial_value('--syntax-only', null);
test_initial_value('--inherits-only', null);
test_initial_value('--initial-value-only', 'red');
</script>
|