Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_exposed_extended_attribute.py
blob015b495be280f6417a853d9ce831ede9c17be9a4
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 parser.parse(
6 """
7 [Global=Foo, Exposed=Foo] interface Foo {};
8 [Global=(Bar, Bar1,Bar2), Exposed=Bar] interface Bar {};
9 [Global=(Baz, Baz2), Exposed=Baz] interface Baz {};
11 [Exposed=(Foo,Bar1)]
12 interface Iface {
13 undefined method1();
15 [Exposed=Bar1]
16 readonly attribute any attr;
19 [Exposed=Foo]
20 partial interface Iface {
21 undefined method2();
23 """
26 results = parser.finish()
28 harness.check(len(results), 5, "Should know about five things")
29 iface = results[3]
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")
34 harness.ok(
35 members[0].exposureSet == set(["Foo", "Bar"]),
36 "method1 should have the right exposure set",
38 harness.ok(
39 members[0]._exposureGlobalNames == set(["Foo", "Bar1"]),
40 "method1 should have the right exposure global names",
43 harness.ok(
44 members[1].exposureSet == set(["Bar"]),
45 "attr should have the right exposure set",
47 harness.ok(
48 members[1]._exposureGlobalNames == set(["Bar1"]),
49 "attr should have the right exposure global names",
52 harness.ok(
53 members[2].exposureSet == set(["Foo"]),
54 "method2 should have the right exposure set",
56 harness.ok(
57 members[2]._exposureGlobalNames == set(["Foo"]),
58 "method2 should have the right exposure global names",
61 harness.ok(
62 iface.exposureSet == set(["Foo", "Bar"]),
63 "Iface should have the right exposure set",
65 harness.ok(
66 iface._exposureGlobalNames == set(["Foo", "Bar1"]),
67 "Iface should have the right exposure global names",
70 parser = parser.reset()
71 parser.parse(
72 """
73 [Global=Foo, Exposed=Foo] interface Foo {};
74 [Global=(Bar, Bar1, Bar2), Exposed=Bar] interface Bar {};
75 [Global=(Baz, Baz2), Exposed=Baz] interface Baz {};
77 [Exposed=Foo]
78 interface Iface2 {
79 undefined method3();
81 """
83 results = parser.finish()
85 harness.check(len(results), 4, "Should know about four things")
86 iface = results[3]
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")
91 harness.ok(
92 members[0].exposureSet == set(["Foo"]),
93 "method3 should have the right exposure set",
95 harness.ok(
96 members[0]._exposureGlobalNames == set(["Foo"]),
97 "method3 should have the right exposure global names",
100 harness.ok(
101 iface.exposureSet == set(["Foo"]), "Iface2 should have the right exposure set"
103 harness.ok(
104 iface._exposureGlobalNames == set(["Foo"]),
105 "Iface2 should have the right exposure global names",
108 parser = parser.reset()
109 parser.parse(
111 [Global=Foo, Exposed=Foo] interface Foo {};
112 [Global=(Bar, Bar1, Bar2), Exposed=Bar] interface Bar {};
113 [Global=(Baz, Baz2), Exposed=Baz] interface Baz {};
115 [Exposed=Foo]
116 interface Iface3 {
117 undefined method4();
120 [Exposed=(Foo,Bar1)]
121 interface mixin Mixin {
122 undefined method5();
125 Iface3 includes Mixin;
128 results = parser.finish()
129 harness.check(len(results), 6, "Should know about six things")
130 iface = results[3]
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")
135 harness.ok(
136 members[0].exposureSet == set(["Foo"]),
137 "method4 should have the right exposure set",
139 harness.ok(
140 members[0]._exposureGlobalNames == set(["Foo"]),
141 "method4 should have the right exposure global names",
144 harness.ok(
145 members[1].exposureSet == set(["Foo", "Bar"]),
146 "method5 should have the right exposure set",
148 harness.ok(
149 members[1]._exposureGlobalNames == set(["Foo", "Bar1"]),
150 "method5 should have the right exposure global names",
153 parser = parser.reset()
154 threw = False
155 try:
156 parser.parse(
158 [Exposed=Foo]
159 interface Bar {
164 results = parser.finish()
165 except WebIDL.WebIDLError:
166 threw = True
168 harness.ok(threw, "Should have thrown on invalid Exposed value on interface.")
170 parser = parser.reset()
171 threw = False
172 try:
173 parser.parse(
175 interface Bar {
176 [Exposed=Foo]
177 readonly attribute bool attr;
182 results = parser.finish()
183 except WebIDL.WebIDLError:
184 threw = True
186 harness.ok(threw, "Should have thrown on invalid Exposed value on attribute.")
188 parser = parser.reset()
189 threw = False
190 try:
191 parser.parse(
193 interface Bar {
194 [Exposed=Foo]
195 undefined operation();
200 results = parser.finish()
201 except WebIDL.WebIDLError:
202 threw = True
204 harness.ok(threw, "Should have thrown on invalid Exposed value on operation.")
206 parser = parser.reset()
207 threw = False
208 try:
209 parser.parse(
211 interface Bar {
212 [Exposed=Foo]
213 const long constant = 5;
218 results = parser.finish()
219 except WebIDL.WebIDLError:
220 threw = True
222 harness.ok(threw, "Should have thrown on invalid Exposed value on constant.")
224 parser = parser.reset()
225 threw = False
226 try:
227 parser.parse(
229 [Global=Foo, Exposed=Foo] interface Foo {};
230 [Global=Bar, Exposed=Bar] interface Bar {};
232 [Exposed=Foo]
233 interface Baz {
234 [Exposed=Bar]
235 undefined method();
240 results = parser.finish()
241 except WebIDL.WebIDLError:
242 threw = True
244 harness.ok(
245 threw, "Should have thrown on member exposed where its interface is not."
248 parser = parser.reset()
249 parser.parse(
251 [Global=Foo, Exposed=Foo] interface Foo {};
252 [Global=Bar, Exposed=Bar] interface Bar {};
254 [Exposed=Foo]
255 interface Baz {
256 undefined method();
259 [Exposed=Bar]
260 interface mixin Mixin {
261 undefined otherMethod();
264 Baz includes Mixin;
268 results = parser.finish()
270 harness.check(len(results), 5, "Should know about five things")
271 iface = results[2]
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")
276 harness.ok(
277 members[0].exposureSet == set(["Foo"]),
278 "method should have the right exposure set",
280 harness.ok(
281 members[0]._exposureGlobalNames == set(["Foo"]),
282 "method should have the right exposure global names",
285 harness.ok(
286 members[1].exposureSet == set(["Bar"]),
287 "otherMethod should have the right exposure set",
289 harness.ok(
290 members[1]._exposureGlobalNames == set(["Bar"]),
291 "otherMethod should have the right exposure global names",
294 parser = parser.reset()
295 parser.parse(
297 [Global=Foo, Exposed=Foo] interface Foo {};
298 [Global=Bar, Exposed=Bar] interface Bar {};
300 [Exposed=*]
301 interface Baz {
302 undefined methodWild();
305 [Exposed=Bar]
306 interface mixin Mixin {
307 undefined methodNotWild();
310 Baz includes Mixin;
314 results = parser.finish()
316 harness.check(len(results), 5, "Should know about five things")
317 iface = results[2]
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")
322 harness.ok(
323 members[0].exposureSet == set(["Foo", "Bar"]),
324 "methodWild should have the right exposure set",
326 harness.ok(
327 members[0]._exposureGlobalNames == set(["Foo", "Bar"]),
328 "methodWild should have the right exposure global names",
331 harness.ok(
332 members[1].exposureSet == set(["Bar"]),
333 "methodNotWild should have the right exposure set",
335 harness.ok(
336 members[1]._exposureGlobalNames == set(["Bar"]),
337 "methodNotWild should have the right exposure global names",
340 parser = parser.reset()
341 threw = False
342 try:
343 parser.parse(
345 [Global=Foo, Exposed=Foo] interface Foo {};
346 [Global=Bar, Exposed=Bar] interface Bar {};
348 [Exposed=Foo]
349 interface Baz {
350 [Exposed=*]
351 undefined method();
356 results = parser.finish()
357 except WebIDL.WebIDLError:
358 threw = True
360 harness.ok(
361 threw, "Should have thrown on member exposed where its interface is not."
364 parser = parser.reset()
365 threw = False
366 try:
367 parser.parse(
369 [Global=Foo, Exposed=Foo] interface Foo {};
370 [Global=Bar, Exposed=Bar] interface Bar {};
372 [Exposed=(Foo,*)]
373 interface Baz {
374 undefined method();
379 results = parser.finish()
380 except WebIDL.WebIDLError:
381 threw = True
383 harness.ok(threw, "Should have thrown on a wildcard in an identifier list.")