4 def WebIDLTest(parser
, harness
):
7 [Global=Foo, Exposed=Foo] interface Foo {};
8 [Global=(Bar, Bar1,Bar2), Exposed=Bar] interface Bar {};
9 [Global=(Baz, Baz2), Exposed=Baz] interface Baz {};
16 readonly attribute any attr;
20 partial interface Iface {
26 results
= parser
.finish()
28 harness
.check(len(results
), 5, "Should know about five things")
30 harness
.ok(isinstance(iface
, WebIDL
.IDLInterface
), "Should have an interface here")
31 members
= iface
.members
32 harness
.check(len(members
), 3, "Should have three members")
35 members
[0].exposureSet
== set(["Foo", "Bar"]),
36 "method1 should have the right exposure set",
39 members
[0]._exposureGlobalNames
== set(["Foo", "Bar1"]),
40 "method1 should have the right exposure global names",
44 members
[1].exposureSet
== set(["Bar"]),
45 "attr should have the right exposure set",
48 members
[1]._exposureGlobalNames
== set(["Bar1"]),
49 "attr should have the right exposure global names",
53 members
[2].exposureSet
== set(["Foo"]),
54 "method2 should have the right exposure set",
57 members
[2]._exposureGlobalNames
== set(["Foo"]),
58 "method2 should have the right exposure global names",
62 iface
.exposureSet
== set(["Foo", "Bar"]),
63 "Iface should have the right exposure set",
66 iface
._exposureGlobalNames
== set(["Foo", "Bar1"]),
67 "Iface should have the right exposure global names",
70 parser
= parser
.reset()
73 [Global=Foo, Exposed=Foo] interface Foo {};
74 [Global=(Bar, Bar1, Bar2), Exposed=Bar] interface Bar {};
75 [Global=(Baz, Baz2), Exposed=Baz] interface Baz {};
83 results
= parser
.finish()
85 harness
.check(len(results
), 4, "Should know about four things")
87 harness
.ok(isinstance(iface
, WebIDL
.IDLInterface
), "Should have an interface here")
88 members
= iface
.members
89 harness
.check(len(members
), 1, "Should have one member")
92 members
[0].exposureSet
== set(["Foo"]),
93 "method3 should have the right exposure set",
96 members
[0]._exposureGlobalNames
== set(["Foo"]),
97 "method3 should have the right exposure global names",
101 iface
.exposureSet
== set(["Foo"]), "Iface2 should have the right exposure set"
104 iface
._exposureGlobalNames
== set(["Foo"]),
105 "Iface2 should have the right exposure global names",
108 parser
= parser
.reset()
111 [Global=Foo, Exposed=Foo] interface Foo {};
112 [Global=(Bar, Bar1, Bar2), Exposed=Bar] interface Bar {};
113 [Global=(Baz, Baz2), Exposed=Baz] interface Baz {};
121 interface mixin Mixin {
125 Iface3 includes Mixin;
128 results
= parser
.finish()
129 harness
.check(len(results
), 6, "Should know about six things")
131 harness
.ok(isinstance(iface
, WebIDL
.IDLInterface
), "Should have an interface here")
132 members
= iface
.members
133 harness
.check(len(members
), 2, "Should have two members")
136 members
[0].exposureSet
== set(["Foo"]),
137 "method4 should have the right exposure set",
140 members
[0]._exposureGlobalNames
== set(["Foo"]),
141 "method4 should have the right exposure global names",
145 members
[1].exposureSet
== set(["Foo", "Bar"]),
146 "method5 should have the right exposure set",
149 members
[1]._exposureGlobalNames
== set(["Foo", "Bar1"]),
150 "method5 should have the right exposure global names",
153 parser
= parser
.reset()
164 results
= parser
.finish()
165 except WebIDL
.WebIDLError
:
168 harness
.ok(threw
, "Should have thrown on invalid Exposed value on interface.")
170 parser
= parser
.reset()
177 readonly attribute bool attr;
182 results
= parser
.finish()
183 except WebIDL
.WebIDLError
:
186 harness
.ok(threw
, "Should have thrown on invalid Exposed value on attribute.")
188 parser
= parser
.reset()
195 undefined operation();
200 results
= parser
.finish()
201 except WebIDL
.WebIDLError
:
204 harness
.ok(threw
, "Should have thrown on invalid Exposed value on operation.")
206 parser
= parser
.reset()
213 const long constant = 5;
218 results
= parser
.finish()
219 except WebIDL
.WebIDLError
:
222 harness
.ok(threw
, "Should have thrown on invalid Exposed value on constant.")
224 parser
= parser
.reset()
229 [Global=Foo, Exposed=Foo] interface Foo {};
230 [Global=Bar, Exposed=Bar] interface Bar {};
240 results
= parser
.finish()
241 except WebIDL
.WebIDLError
:
245 threw
, "Should have thrown on member exposed where its interface is not."
248 parser
= parser
.reset()
251 [Global=Foo, Exposed=Foo] interface Foo {};
252 [Global=Bar, Exposed=Bar] interface Bar {};
260 interface mixin Mixin {
261 undefined otherMethod();
268 results
= parser
.finish()
270 harness
.check(len(results
), 5, "Should know about five things")
272 harness
.ok(isinstance(iface
, WebIDL
.IDLInterface
), "Should have an interface here")
273 members
= iface
.members
274 harness
.check(len(members
), 2, "Should have two members")
277 members
[0].exposureSet
== set(["Foo"]),
278 "method should have the right exposure set",
281 members
[0]._exposureGlobalNames
== set(["Foo"]),
282 "method should have the right exposure global names",
286 members
[1].exposureSet
== set(["Bar"]),
287 "otherMethod should have the right exposure set",
290 members
[1]._exposureGlobalNames
== set(["Bar"]),
291 "otherMethod should have the right exposure global names",
294 parser
= parser
.reset()
297 [Global=Foo, Exposed=Foo] interface Foo {};
298 [Global=Bar, Exposed=Bar] interface Bar {};
302 undefined methodWild();
306 interface mixin Mixin {
307 undefined methodNotWild();
314 results
= parser
.finish()
316 harness
.check(len(results
), 5, "Should know about five things")
318 harness
.ok(isinstance(iface
, WebIDL
.IDLInterface
), "Should have an interface here")
319 members
= iface
.members
320 harness
.check(len(members
), 2, "Should have two members")
323 members
[0].exposureSet
== set(["Foo", "Bar"]),
324 "methodWild should have the right exposure set",
327 members
[0]._exposureGlobalNames
== set(["Foo", "Bar"]),
328 "methodWild should have the right exposure global names",
332 members
[1].exposureSet
== set(["Bar"]),
333 "methodNotWild should have the right exposure set",
336 members
[1]._exposureGlobalNames
== set(["Bar"]),
337 "methodNotWild should have the right exposure global names",
340 parser
= parser
.reset()
345 [Global=Foo, Exposed=Foo] interface Foo {};
346 [Global=Bar, Exposed=Bar] interface Bar {};
356 results
= parser
.finish()
357 except WebIDL
.WebIDLError
:
361 threw
, "Should have thrown on member exposed where its interface is not."
364 parser
= parser
.reset()
369 [Global=Foo, Exposed=Foo] interface Foo {};
370 [Global=Bar, Exposed=Bar] interface Bar {};
379 results
= parser
.finish()
380 except WebIDL
.WebIDLError
:
383 harness
.ok(threw
, "Should have thrown on a wildcard in an identifier list.")