4 def WebIDLTest(parser
, harness
):
5 parser
.parse("interface mixin Foo { };")
6 results
= parser
.finish()
7 harness
.ok(True, "Empty interface mixin parsed without error.")
8 harness
.check(len(results
), 1, "Should be one production")
10 isinstance(results
[0], WebIDL
.IDLInterfaceMixin
),
11 "Should be an IDLInterfaceMixin",
15 mixin
.identifier
.QName(), "::Foo", "Interface mixin has the right QName"
17 harness
.check(mixin
.identifier
.name
, "Foo", "Interface mixin has the right name")
19 parser
= parser
.reset()
22 interface mixin QNameBase {
27 results
= parser
.finish()
28 harness
.check(len(results
), 1, "Should be one productions")
30 isinstance(results
[0], WebIDL
.IDLInterfaceMixin
),
31 "Should be an IDLInterfaceMixin",
33 harness
.check(len(results
[0].members
), 1, "Expect 1 productions")
36 mixin
.members
[0].identifier
.QName(),
38 "Member has the right QName",
41 parser
= parser
.reset()
45 readonly attribute boolean x;
48 partial interface mixin A {
49 readonly attribute boolean y;
50 undefined foo(long arg);
54 results
= parser
.finish()
56 len(results
), 2, "Should have two results with partial interface mixin"
60 len(mixin
.members
), 3, "Should have three members with partial interface mixin"
63 mixin
.members
[0].identifier
.name
,
65 "First member should be x with partial interface mixin",
68 mixin
.members
[1].identifier
.name
,
70 "Second member should be foo with partial interface mixin",
73 len(mixin
.members
[1].signatures()),
75 "Should have two foo signatures with partial interface mixin",
78 mixin
.members
[2].identifier
.name
,
80 "Third member should be y with partial interface mixin",
83 parser
= parser
.reset()
86 partial interface mixin A {
87 readonly attribute boolean y;
88 undefined foo(long arg);
91 readonly attribute boolean x;
96 results
= parser
.finish()
98 len(results
), 2, "Should have two results with reversed partial interface mixin"
104 "Should have three members with reversed partial interface mixin",
107 mixin
.members
[0].identifier
.name
,
109 "First member should be x with reversed partial interface mixin",
112 mixin
.members
[1].identifier
.name
,
114 "Second member should be foo with reversed partial interface mixin",
117 len(mixin
.members
[1].signatures()),
119 "Should have two foo signatures with reversed partial interface mixin",
122 mixin
.members
[2].identifier
.name
,
124 "Third member should be y with reversed partial interface mixin",
127 parser
= parser
.reset()
130 interface Interface {};
131 interface mixin Mixin {
134 Interface includes Mixin;
137 results
= parser
.finish()
139 harness
.check(len(iface
.members
), 1, "Should merge members from mixins")
141 iface
.members
[0].identifier
.name
, "x", "Should merge members from mixins"
144 parser
= parser
.reset()
150 readonly attribute boolean x;
153 readonly attribute boolean y;
157 results
= parser
.finish()
158 except WebIDL
.WebIDLError
:
161 threw
, "Should not allow two non-partial interface mixins with the same name"
164 parser
= parser
.reset()
169 partial interface mixin A {
170 readonly attribute boolean x;
172 partial interface mixin A {
173 readonly attribute boolean y;
177 results
= parser
.finish()
178 except WebIDL
.WebIDLError
:
180 harness
.ok(threw
, "Must have a non-partial interface mixin for a given name")
182 parser
= parser
.reset()
190 partial interface mixin A {
191 readonly attribute boolean y;
195 results
= parser
.finish()
196 except WebIDL
.WebIDLError
:
200 "Should not allow a name collision between partial interface "
201 "mixin and other object",
204 parser
= parser
.reset()
213 readonly attribute boolean y;
217 results
= parser
.finish()
218 except WebIDL
.WebIDLError
:
222 "Should not allow a name collision between interface mixin " "and other object",
225 parser
= parser
.reset()
231 readonly attribute boolean x;
236 results
= parser
.finish()
237 except WebIDL
.WebIDLError
:
241 "Should not allow a name collision between external interface "
242 "and interface mixin",
245 parser
= parser
.reset()
250 [SomeRandomAnnotation]
252 readonly attribute boolean y;
256 results
= parser
.finish()
257 except WebIDL
.WebIDLError
:
260 threw
, "Should not allow unknown extended attributes on interface mixins"
263 parser
= parser
.reset()
269 getter double (DOMString propertyName);
273 results
= parser
.finish()
274 except WebIDL
.WebIDLError
:
276 harness
.ok(threw
, "Should not allow getters on interface mixins")
278 parser
= parser
.reset()
284 setter undefined (DOMString propertyName, double propertyValue);
288 results
= parser
.finish()
289 except WebIDL
.WebIDLError
:
291 harness
.ok(threw
, "Should not allow setters on interface mixins")
293 parser
= parser
.reset()
299 deleter undefined (DOMString propertyName);
303 results
= parser
.finish()
304 except WebIDL
.WebIDLError
:
306 harness
.ok(threw
, "Should not allow deleters on interface mixins")
308 parser
= parser
.reset()
314 legacycaller double compute(double x);
318 results
= parser
.finish()
319 except WebIDL
.WebIDLError
:
321 harness
.ok(threw
, "Should not allow legacycallers on interface mixins")
323 parser
= parser
.reset()
333 results
= parser
.finish()
334 except WebIDL
.WebIDLError
:
336 harness
.ok(threw
, "Should not allow inherited attribute on interface mixins")
338 parser
= parser
.reset()
343 interface Interface {};
347 Interface includes NotMixin;
350 results
= parser
.finish()
351 except WebIDL
.WebIDLError
:
353 harness
.ok(threw
, "Should fail if the right side does not point an interface mixin")
355 parser
= parser
.reset()
360 interface mixin NotInterface {};
361 interface mixin Mixin {
364 NotInterface includes Mixin;
367 results
= parser
.finish()
368 except WebIDL
.WebIDLError
:
370 harness
.ok(threw
, "Should fail if the left side does not point an interface")
372 parser
= parser
.reset()
377 interface mixin Mixin {
382 results
= parser
.finish()
383 except WebIDL
.WebIDLError
:
385 harness
.ok(threw
, "Should fail if an interface mixin includes iterable")
387 parser
= parser
.reset()
392 interface mixin Mixin {
397 results
= parser
.finish()
398 except WebIDL
.WebIDLError
:
400 harness
.ok(threw
, "Should fail if an interface mixin includes setlike")
402 parser
= parser
.reset()
407 interface mixin Mixin {
408 maplike<DOMString, DOMString>;
412 results
= parser
.finish()
413 except WebIDL
.WebIDLError
:
415 harness
.ok(threw
, "Should fail if an interface mixin includes maplike")
417 parser
= parser
.reset()
422 interface Interface {
423 attribute short attr;
425 interface mixin Mixin {
426 attribute short attr;
428 Interface includes Mixin;
431 results
= parser
.finish()
432 except WebIDL
.WebIDLError
:
435 threw
, "Should fail if the included mixin interface has duplicated member"
438 parser
= parser
.reset()
443 interface Interface {};
444 interface mixin Mixin1 {
445 attribute short attr;
447 interface mixin Mixin2 {
448 attribute short attr;
450 Interface includes Mixin1;
451 Interface includes Mixin2;
454 results
= parser
.finish()
455 except WebIDL
.WebIDLError
:
458 threw
, "Should fail if the included mixin interfaces have duplicated member"
461 parser
= parser
.reset()
464 [Global=Window, Exposed=Window] interface Window {};
465 [Global=Worker, Exposed=Worker] interface Worker {};
468 interface mixin Mixin {
474 results
= parser
.finish()
476 attr
= base
.members
[0]
480 "Should expose on globals where the base interfaces are exposed",
483 parser
= parser
.reset()
486 [Global=Window, Exposed=Window] interface Window {};
487 [Global=Worker, Exposed=Worker] interface Worker {};
491 interface mixin Mixin {
497 results
= parser
.finish()
499 attr
= base
.members
[0]
501 attr
.exposureSet
, set(["Window"]), "Should follow [Exposed] on interface mixin"
504 parser
= parser
.reset()
507 [Global=Window, Exposed=Window] interface Window {};
508 [Global=Worker, Exposed=Worker] interface Worker {};
513 interface mixin Mixin {
516 Base1 includes Mixin;
517 Base2 includes Mixin;
520 results
= parser
.finish()
522 attr
= base
.members
[0]
525 set(["Window", "Worker"]),
526 "Should expose on all globals where including interfaces are " "exposed",
529 attr
= base
.members
[0]
532 set(["Window", "Worker"]),
533 "Should expose on all globals where including interfaces are " "exposed",