Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_promise.py
blob1dfb6d4643c389e583fa1e712a3f0b9224bbd3bf
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 threw = False
6 try:
7 parser.parse(
8 """
9 interface A {
10 legacycaller Promise<any> foo();
12 """
14 parser.finish()
16 except WebIDL.WebIDLError:
17 threw = True
18 harness.ok(threw, "Should not allow Promise return values for legacycaller.")
20 parser = parser.reset()
21 threw = False
22 try:
23 parser.parse(
24 """
25 interface A {
26 Promise<any> foo();
27 long foo(long arg);
29 """
31 parser.finish()
32 except WebIDL.WebIDLError:
33 threw = True
34 harness.ok(
35 threw,
36 "Should not allow overloads which have both Promise and "
37 "non-Promise return types.",
40 parser = parser.reset()
41 threw = False
42 try:
43 parser.parse(
44 """
45 interface A {
46 long foo(long arg);
47 Promise<any> foo();
49 """
51 parser.finish()
52 except WebIDL.WebIDLError:
53 threw = True
54 harness.ok(
55 threw,
56 "Should not allow overloads which have both Promise and "
57 "non-Promise return types.",
60 parser = parser.reset()
61 threw = False
62 try:
63 parser.parse(
64 """
65 interface A {
66 Promise<any>? foo();
68 """
70 parser.finish()
71 except WebIDL.WebIDLError:
72 threw = True
73 harness.ok(threw, "Should not allow nullable Promise return values.")
75 parser = parser.reset()
76 threw = False
77 try:
78 parser.parse(
79 """
80 interface A {
81 undefined foo(Promise<any>? arg);
83 """
85 parser.finish()
86 except WebIDL.WebIDLError:
87 threw = True
88 harness.ok(threw, "Should not allow nullable Promise arguments.")
90 parser = parser.reset()
91 parser.parse(
92 """
93 interface A {
94 Promise<any> foo();
95 Promise<any> foo(long arg);
97 """
99 parser.finish()
101 harness.ok(
102 True, "Should allow overloads which only have Promise and return " "types."
105 parser = parser.reset()
106 threw = False
107 try:
108 parser.parse(
110 interface A {
111 attribute Promise<any> attr;
115 parser.finish()
116 except WebIDL.WebIDLError:
117 threw = True
118 harness.ok(threw, "Should not allow writable Promise-typed attributes.")
120 parser = parser.reset()
121 threw = False
122 try:
123 parser.parse(
125 interface A {
126 [LegacyLenientSetter] readonly attribute Promise<any> attr;
130 parser.finish()
131 except WebIDL.WebIDLError:
132 threw = True
133 harness.ok(
134 threw, "Should not allow [LegacyLenientSetter] Promise-typed attributes."
137 parser = parser.reset()
138 threw = False
139 try:
140 parser.parse(
142 interface A {
143 [PutForwards=bar] readonly attribute Promise<any> attr;
147 parser.finish()
148 except WebIDL.WebIDLError:
149 threw = True
150 harness.ok(threw, "Should not allow [PutForwards] Promise-typed attributes.")
152 parser = parser.reset()
153 threw = False
154 try:
155 parser.parse(
157 interface A {
158 [Replaceable] readonly attribute Promise<any> attr;
162 parser.finish()
163 except WebIDL.WebIDLError:
164 threw = True
165 harness.ok(threw, "Should not allow [Replaceable] Promise-typed attributes.")
167 parser = parser.reset()
168 threw = False
169 try:
170 parser.parse(
172 interface A {
173 [SameObject] readonly attribute Promise<any> attr;
177 parser.finish()
178 except WebIDL.WebIDLError:
179 threw = True
180 harness.ok(threw, "Should not allow [SameObject] Promise-typed attributes.")