Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_undefined.py
blob34d1ac824ec0932234765d02eeba5d96433ac78c
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 try:
6 parser.parse(
7 """
8 dictionary Dict {
9 undefined undefinedMember;
10 double bar;
12 """
14 parser.finish()
15 except WebIDL.WebIDLError:
16 threw = True
18 harness.ok(threw, "undefined must not be used as the type of a dictionary member")
20 parser = parser.reset()
21 threw = False
23 try:
24 parser.parse(
25 """
26 dictionary Dict {
27 (undefined or double) undefinedMemberOfUnionInDict;
29 """
31 parser.finish()
32 except WebIDL.WebIDLError:
33 threw = True
35 harness.ok(
36 threw,
37 "undefined must not be used as the type of a dictionary member, "
38 "whether directly or in a union",
41 parser = parser.reset()
42 threw = False
44 try:
45 parser.parse(
46 """
47 interface Foo {
48 double bar(undefined foo);
50 """
52 parser.finish()
53 except WebIDL.WebIDLError:
54 threw = True
56 harness.ok(
57 threw,
58 "undefined must not be used as the type of an argument in any "
59 "circumstance (so not as the argument of a regular operation)",
62 parser = parser.reset()
63 threw = False
65 try:
66 parser.parse(
67 """
68 interface Foo {
69 getter double(undefined name);
71 """
73 parser.finish()
74 except WebIDL.WebIDLError:
75 threw = True
77 harness.ok(
78 threw,
79 "undefined must not be used as the type of an argument in any "
80 "circumstance (so not as the argument of a getter)",
83 parser = parser.reset()
84 threw = False
86 try:
87 parser.parse(
88 """
89 interface Foo {
90 setter undefined(DOMString name, undefined value);
92 """
94 parser.finish()
95 except WebIDL.WebIDLError:
96 threw = True
98 harness.ok(
99 threw,
100 "undefined must not be used as the type of an argument in any "
101 "circumstance (so not as the argument of a setter)",
104 parser = parser.reset()
105 threw = False
107 try:
108 parser.parse(
110 interface Foo {
111 deleter undefined (undefined name);
115 parser.finish()
116 except WebIDL.WebIDLError:
117 threw = True
119 harness.ok(
120 threw,
121 "undefined must not be used as the type of an argument in any "
122 "circumstance (so not as the argument of a deleter)",
125 parser = parser.reset()
126 threw = False
128 try:
129 parser.parse(
131 interface Foo {
132 constructor (undefined foo);
136 parser.finish()
137 except WebIDL.WebIDLError:
138 threw = True
140 harness.ok(
141 threw,
142 "undefined must not be used as the type of an argument in any "
143 "circumstance (so not as the argument of a constructor)",
146 parser = parser.reset()
147 threw = False
149 try:
150 parser.parse(
152 callback Callback = undefined (undefined foo);
155 parser.finish()
156 except WebIDL.WebIDLError:
157 threw = True
159 harness.ok(
160 threw,
161 "undefined must not be used as the type of an argument in any "
162 "circumstance (so not as the argument of a callback)",
165 parser = parser.reset()
166 threw = False
168 try:
169 parser.parse(
171 interface Foo {
172 async iterable(undefined name);
176 parser.finish()
177 except WebIDL.WebIDLError:
178 threw = True
180 harness.ok(
181 threw,
182 "undefined must not be used as the type of an argument in any "
183 "circumstance (so not as the argument of an async iterable "
184 "iterator)",
187 parser = parser.reset()
188 threw = False
190 try:
191 parser.parse(
193 interface Foo {
194 static double bar(undefined foo);
198 parser.finish()
199 except WebIDL.WebIDLError:
200 threw = True
202 harness.ok(
203 threw,
204 "undefined must not be used as the type of an argument in any "
205 "circumstance (so not as the argument of a static operation)",
208 parser = parser.reset()
209 threw = False
211 try:
212 parser.parse(
214 interface Foo {
215 const undefined FOO = undefined;
219 parser.finish()
220 except WebIDL.WebIDLError:
221 threw = True
223 harness.ok(
224 threw,
225 "undefined is not a valid type for a constant",
228 parser = parser.reset()
229 threw = False
231 try:
232 parser.parse(
234 interface Foo {
235 const any FOO = undefined;
239 parser.finish()
240 except WebIDL.WebIDLError:
241 threw = True
243 harness.ok(
244 threw,
245 "undefined is not a valid value for a constant",