Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_unforgeable.py
blob0f7d52349a5ab336f66251d838d88260834cf904
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 parser.parse(
6 """
7 interface Child : Parent {
8 };
9 interface Parent {
10 [LegacyUnforgeable] readonly attribute long foo;
12 """
15 results = parser.finish()
16 harness.check(
17 len(results),
19 "Should be able to inherit from an interface with "
20 "[LegacyUnforgeable] properties.",
23 parser = parser.reset()
24 parser.parse(
25 """
26 interface Child : Parent {
27 const short foo = 10;
29 interface Parent {
30 [LegacyUnforgeable] readonly attribute long foo;
32 """
35 results = parser.finish()
36 harness.check(
37 len(results),
39 "Should be able to inherit from an interface with "
40 "[LegacyUnforgeable] properties even if we have a constant with "
41 "the same name.",
44 parser = parser.reset()
45 parser.parse(
46 """
47 interface Child : Parent {
48 static attribute short foo;
50 interface Parent {
51 [LegacyUnforgeable] readonly attribute long foo;
53 """
56 results = parser.finish()
57 harness.check(
58 len(results),
60 "Should be able to inherit from an interface with "
61 "[LegacyUnforgeable] properties even if we have a static attribute "
62 "with the same name.",
65 parser = parser.reset()
66 parser.parse(
67 """
68 interface Child : Parent {
69 static undefined foo();
71 interface Parent {
72 [LegacyUnforgeable] readonly attribute long foo;
74 """
77 results = parser.finish()
78 harness.check(
79 len(results),
81 "Should be able to inherit from an interface with "
82 "[LegacyUnforgeable] properties even if we have a static operation "
83 "with the same name.",
86 parser = parser.reset()
87 threw = False
88 try:
89 parser.parse(
90 """
91 interface Child : Parent {
92 undefined foo();
94 interface Parent {
95 [LegacyUnforgeable] readonly attribute long foo;
97 """
100 results = parser.finish()
101 except WebIDL.WebIDLError:
102 threw = True
103 harness.ok(
104 threw,
105 "Should have thrown when shadowing unforgeable attribute on "
106 "parent with operation.",
109 parser = parser.reset()
110 threw = False
111 try:
112 parser.parse(
114 interface Child : Parent {
115 undefined foo();
117 interface Parent {
118 [LegacyUnforgeable] undefined foo();
123 results = parser.finish()
124 except WebIDL.WebIDLError:
125 threw = True
126 harness.ok(
127 threw,
128 "Should have thrown when shadowing unforgeable operation on "
129 "parent with operation.",
132 parser = parser.reset()
133 threw = False
134 try:
135 parser.parse(
137 interface Child : Parent {
138 attribute short foo;
140 interface Parent {
141 [LegacyUnforgeable] readonly attribute long foo;
146 results = parser.finish()
147 except WebIDL.WebIDLError:
148 threw = True
149 harness.ok(
150 threw,
151 "Should have thrown when shadowing unforgeable attribute on "
152 "parent with attribute.",
155 parser = parser.reset()
156 threw = False
157 try:
158 parser.parse(
160 interface Child : Parent {
161 attribute short foo;
163 interface Parent {
164 [LegacyUnforgeable] undefined foo();
169 results = parser.finish()
170 except WebIDL.WebIDLError:
171 threw = True
172 harness.ok(
173 threw,
174 "Should have thrown when shadowing unforgeable operation on "
175 "parent with attribute.",
178 parser = parser.reset()
179 parser.parse(
181 interface Child : Parent {
183 interface Parent {};
184 interface mixin Mixin {
185 [LegacyUnforgeable] readonly attribute long foo;
187 Parent includes Mixin;
191 results = parser.finish()
192 harness.check(
193 len(results),
195 "Should be able to inherit from an interface with a "
196 "mixin with [LegacyUnforgeable] properties.",
199 parser = parser.reset()
200 threw = False
201 try:
202 parser.parse(
204 interface Child : Parent {
205 undefined foo();
207 interface Parent {};
208 interface mixin Mixin {
209 [LegacyUnforgeable] readonly attribute long foo;
211 Parent includes Mixin;
215 results = parser.finish()
216 except WebIDL.WebIDLError:
217 threw = True
219 harness.ok(
220 threw,
221 "Should have thrown when shadowing unforgeable attribute "
222 "of parent's consequential interface.",
225 parser = parser.reset()
226 threw = False
227 try:
228 parser.parse(
230 interface Child : Parent {
232 interface Parent : GrandParent {};
233 interface GrandParent {};
234 interface mixin Mixin {
235 [LegacyUnforgeable] readonly attribute long foo;
237 GrandParent includes Mixin;
238 interface mixin ChildMixin {
239 undefined foo();
241 Child includes ChildMixin;
245 results = parser.finish()
246 except WebIDL.WebIDLError:
247 threw = True
249 harness.ok(
250 threw,
251 "Should have thrown when our consequential interface shadows unforgeable attribute "
252 "of ancestor's consequential interface.",
255 parser = parser.reset()
256 threw = False
257 try:
258 parser.parse(
260 interface Child : Parent {
262 interface Parent : GrandParent {};
263 interface GrandParent {};
264 interface mixin Mixin {
265 [LegacyUnforgeable] undefined foo();
267 GrandParent includes Mixin;
268 interface mixin ChildMixin {
269 undefined foo();
271 Child includes ChildMixin;
275 results = parser.finish()
276 except WebIDL.WebIDLError:
277 threw = True
279 harness.ok(
280 threw,
281 "Should have thrown when our consequential interface shadows unforgeable operation "
282 "of ancestor's consequential interface.",
285 parser = parser.reset()
286 parser.parse(
288 interface iface {
289 [LegacyUnforgeable] attribute long foo;
294 results = parser.finish()
295 harness.check(
296 len(results), 1, "Should allow writable [LegacyUnforgeable] attribute."
299 parser = parser.reset()
300 threw = False
301 try:
302 parser.parse(
304 interface iface {
305 [LegacyUnforgeable] static readonly attribute long foo;
310 results = parser.finish()
311 except WebIDL.WebIDLError:
312 threw = True
314 harness.ok(threw, "Should have thrown for static [LegacyUnforgeable] attribute.")