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
15 attribute ObservableArray<A> foo;
18 "use dictionary as inner type",
21 # Test sequence as inner type
26 attribute ObservableArray<sequence<boolean>> foo;
29 "use sequence as inner type",
32 # Test sequence<dictionary> as inner type
40 attribute ObservableArray<sequence<A>> foo;
43 "use sequence<dictionary> as inner type",
46 # Test record as inner type
51 attribute ObservableArray<record<DOMString, boolean>> foo;
54 "use record as inner type",
57 # Test record<dictionary> as inner type
65 attribute ObservableArray<record<DOMString, A>> foo;
68 "use record<dictionary> as inner type",
71 # Test observable array as inner type
76 attribute ObservableArray<ObservableArray<boolean>> foo;
79 "use ObservableArray as inner type",
82 # Test nullable attribute
87 attribute ObservableArray<boolean>? foo;
98 undefined foo(sequence<ObservableArray<boolean>> foo);
105 harness
.should_throw(
109 undefined foo(record<DOMString, ObservableArray<boolean>> foo);
116 harness
.should_throw(
120 Promise<ObservableArray<boolean>> foo();
127 harness
.should_throw(
131 attribute (DOMString or ObservableArray<boolean>>) foo;
137 # Test dictionary member
138 harness
.should_throw(
142 ObservableArray<boolean> foo;
145 "used on dictionary member type",
149 harness
.should_throw(
153 undefined foo(ObservableArray<boolean> foo);
159 # Test static attribute
160 harness
.should_throw(
164 static attribute ObservableArray<boolean> foo;
167 "used on static attribute type",
171 harness
.should_throw(
175 iterable<ObservableArray<boolean>>;
182 harness
.should_throw(
186 maplike<long, ObservableArray<boolean>>;
193 harness
.should_throw(
197 setlike<ObservableArray<boolean>>;
203 # Test JS implemented interface
204 harness
.should_throw(
207 [JSImplementation="@mozilla.org/dom/test-interface-js;1"]
209 readonly attribute ObservableArray<boolean> foo;
212 "used in JS implemented interface",
216 harness
.should_throw(
220 readonly attribute ObservableArray<boolean> foo;
223 "used in namespaces",
226 # Test [Cached] extended attribute
227 harness
.should_throw(
232 readonly attribute ObservableArray<boolean> foo;
235 "have Cached extended attribute",
238 # Test [StoreInSlot] extended attribute
239 harness
.should_throw(
244 readonly attribute ObservableArray<boolean> foo;
247 "have StoreInSlot extended attribute",
250 # Test regular attribute
251 parser
= parser
.reset()
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()
265 harness
.ok(foo
.readonly
, "A.foo is readonly attribute")
266 harness
.ok(foo
.type.isObservableArray(), "A.foo is ObservableArray type")
268 foo
.slotIndices
[A
.identifier
.name
], 0, "A.foo should be stored in slot"
271 harness
.ok(bar
.type.isObservableArray(), "A.bar is ObservableArray type")
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")
277 harness
.ok(baz
.type.isObservableArray(), "A.baz is ObservableArray type")
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")
283 harness
.ok(qux
.type.isObservableArray(), "A.qux is ObservableArray type")
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")