Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_observableArray.py
blob7fe9511e07496644011774bf1f5d55614f2f0c49
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 def WebIDLTest(parser, harness):
7 # Test dictionary as inner type
8 harness.should_throw(
9 parser,
10 """
11 dictionary A {
12 boolean member;
14 interface B {
15 attribute ObservableArray<A> foo;
17 """,
18 "use dictionary as inner type",
21 # Test sequence as inner type
22 harness.should_throw(
23 parser,
24 """
25 interface A {
26 attribute ObservableArray<sequence<boolean>> foo;
28 """,
29 "use sequence as inner type",
32 # Test sequence<dictionary> as inner type
33 harness.should_throw(
34 parser,
35 """
36 dictionary A {
37 boolean member;
39 interface B {
40 attribute ObservableArray<sequence<A>> foo;
42 """,
43 "use sequence<dictionary> as inner type",
46 # Test record as inner type
47 harness.should_throw(
48 parser,
49 """
50 interface A {
51 attribute ObservableArray<record<DOMString, boolean>> foo;
53 """,
54 "use record as inner type",
57 # Test record<dictionary> as inner type
58 harness.should_throw(
59 parser,
60 """
61 dictionary A {
62 boolean member;
64 interface B {
65 attribute ObservableArray<record<DOMString, A>> foo;
67 """,
68 "use record<dictionary> as inner type",
71 # Test observable array as inner type
72 harness.should_throw(
73 parser,
74 """
75 interface A {
76 attribute ObservableArray<ObservableArray<boolean>> foo;
78 """,
79 "use ObservableArray as inner type",
82 # Test nullable attribute
83 harness.should_throw(
84 parser,
85 """
86 interface A {
87 attribute ObservableArray<boolean>? foo;
89 """,
90 "nullable",
93 # Test sequence
94 harness.should_throw(
95 parser,
96 """
97 interface A {
98 undefined foo(sequence<ObservableArray<boolean>> foo);
100 """,
101 "used in sequence",
104 # Test record
105 harness.should_throw(
106 parser,
108 interface A {
109 undefined foo(record<DOMString, ObservableArray<boolean>> foo);
111 """,
112 "used in record",
115 # Test promise
116 harness.should_throw(
117 parser,
119 interface A {
120 Promise<ObservableArray<boolean>> foo();
122 """,
123 "used in promise",
126 # Test union
127 harness.should_throw(
128 parser,
130 interface A {
131 attribute (DOMString or ObservableArray<boolean>>) foo;
133 """,
134 "used in union",
137 # Test dictionary member
138 harness.should_throw(
139 parser,
141 dictionary A {
142 ObservableArray<boolean> foo;
144 """,
145 "used on dictionary member type",
148 # Test argument
149 harness.should_throw(
150 parser,
152 interface A {
153 undefined foo(ObservableArray<boolean> foo);
155 """,
156 "used on argument",
159 # Test static attribute
160 harness.should_throw(
161 parser,
163 interface A {
164 static attribute ObservableArray<boolean> foo;
166 """,
167 "used on static attribute type",
170 # Test iterable
171 harness.should_throw(
172 parser,
174 interface A {
175 iterable<ObservableArray<boolean>>;
177 """,
178 "used in iterable",
181 # Test maplike
182 harness.should_throw(
183 parser,
185 interface A {
186 maplike<long, ObservableArray<boolean>>;
188 """,
189 "used in maplike",
192 # Test setlike
193 harness.should_throw(
194 parser,
196 interface A {
197 setlike<ObservableArray<boolean>>;
199 """,
200 "used in setlike",
203 # Test JS implemented interface
204 harness.should_throw(
205 parser,
207 [JSImplementation="@mozilla.org/dom/test-interface-js;1"]
208 interface A {
209 readonly attribute ObservableArray<boolean> foo;
211 """,
212 "used in JS implemented interface",
215 # Test namespace
216 harness.should_throw(
217 parser,
219 namespace A {
220 readonly attribute ObservableArray<boolean> foo;
222 """,
223 "used in namespaces",
226 # Test [Cached] extended attribute
227 harness.should_throw(
228 parser,
230 interface A {
231 [Cached, Pure]
232 readonly attribute ObservableArray<boolean> foo;
234 """,
235 "have Cached extended attribute",
238 # Test [StoreInSlot] extended attribute
239 harness.should_throw(
240 parser,
242 interface A {
243 [StoreInSlot, Pure]
244 readonly attribute ObservableArray<boolean> foo;
246 """,
247 "have StoreInSlot extended attribute",
250 # Test regular attribute
251 parser = parser.reset()
252 parser.parse(
254 interface A {
255 readonly attribute ObservableArray<boolean> foo;
256 attribute ObservableArray<[Clamp] octet> bar;
257 attribute ObservableArray<long?> baz;
258 attribute ObservableArray<(boolean or long)> qux;
262 results = parser.finish()
263 A = results[0]
264 foo = A.members[0]
265 harness.ok(foo.readonly, "A.foo is readonly attribute")
266 harness.ok(foo.type.isObservableArray(), "A.foo is ObservableArray type")
267 harness.check(
268 foo.slotIndices[A.identifier.name], 0, "A.foo should be stored in slot"
270 bar = A.members[1]
271 harness.ok(bar.type.isObservableArray(), "A.bar is ObservableArray type")
272 harness.check(
273 bar.slotIndices[A.identifier.name], 1, "A.bar should be stored in slot"
275 harness.ok(bar.type.inner.hasClamp(), "A.bar's inner type should be clamped")
276 baz = A.members[2]
277 harness.ok(baz.type.isObservableArray(), "A.baz is ObservableArray type")
278 harness.check(
279 baz.slotIndices[A.identifier.name], 2, "A.baz should be stored in slot"
281 harness.ok(baz.type.inner.nullable(), "A.baz's inner type should be nullable")
282 qux = A.members[3]
283 harness.ok(qux.type.isObservableArray(), "A.qux is ObservableArray type")
284 harness.check(
285 qux.slotIndices[A.identifier.name], 3, "A.qux should be stored in slot"
287 harness.ok(qux.type.inner.isUnion(), "A.qux's inner type should be union")