Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_stringifier.py
blobc2052c44e57d36a70af5cd0b044e8dc39372831b
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 parser.parse(
6 """
7 interface TestStringifier {
8 stringifier;
9 };
10 """
13 results = parser.finish()
15 harness.ok(
16 isinstance(results[0].members[0], WebIDL.IDLMethod),
17 "Stringifer should be method",
20 parser = parser.reset()
22 threw = False
23 try:
24 parser.parse(
25 """
26 interface TestStringifier {
27 stringifier;
28 stringifier;
30 """
32 results = parser.finish()
33 except WebIDL.WebIDLError:
34 threw = True
36 harness.ok(threw, "Should not allow two 'stringifier;'")
38 parser = parser.reset()
40 threw = False
41 try:
42 parser.parse(
43 """
44 interface TestStringifier {
45 stringifier;
46 stringifier DOMString foo();
48 """
50 results = parser.finish()
51 except WebIDL.WebIDLError:
52 threw = True
54 harness.ok(threw, "Should not allow a 'stringifier;' and a 'stringifier()'")
56 parser = parser.reset()
57 parser.parse(
58 """
59 interface TestStringifier {
60 stringifier attribute DOMString foo;
62 """
64 results = parser.finish()
65 harness.ok(
66 isinstance(results[0].members[0], WebIDL.IDLAttribute),
67 "Stringifier attribute should be an attribute",
69 stringifier = results[0].members[1]
70 harness.ok(
71 isinstance(stringifier, WebIDL.IDLMethod),
72 "Stringifier attribute should insert a method",
74 harness.ok(stringifier.isStringifier(), "Inserted method should be a stringifier")
76 parser = parser.reset()
77 parser.parse(
78 """
79 interface TestStringifier {};
80 interface mixin TestStringifierMixin {
81 stringifier attribute DOMString foo;
83 TestStringifier includes TestStringifierMixin;
84 """
86 results = parser.finish()
87 harness.ok(
88 isinstance(results[0].members[0], WebIDL.IDLAttribute),
89 "Stringifier attribute should be an attribute",
91 stringifier = results[0].members[1]
92 harness.ok(
93 isinstance(stringifier, WebIDL.IDLMethod),
94 "Stringifier attribute should insert a method",
96 harness.ok(stringifier.isStringifier(), "Inserted method should be a stringifier")
98 parser = parser.reset()
99 parser.parse(
101 interface TestStringifier {
102 stringifier attribute USVString foo;
106 results = parser.finish()
107 stringifier = results[0].members[1]
108 harness.ok(
109 stringifier.signatures()[0][0].isUSVString(),
110 "Stringifier attributes should allow USVString",
113 parser = parser.reset()
114 parser.parse(
116 interface TestStringifier {
117 [Throws, NeedsSubjectPrincipal]
118 stringifier attribute USVString foo;
122 results = parser.finish()
123 stringifier = results[0].members[1]
124 harness.ok(
125 stringifier.getExtendedAttribute("Throws"),
126 "Stringifier attributes should support [Throws]",
128 harness.ok(
129 stringifier.getExtendedAttribute("NeedsSubjectPrincipal"),
130 "Stringifier attributes should support [NeedsSubjectPrincipal]",
133 parser = parser.reset()
134 parser.parse(
136 interface TestStringifier {
137 stringifier attribute UTF8String foo;
141 results = parser.finish()
142 stringifier = results[0].members[1]
143 harness.ok(
144 stringifier.signatures()[0][0].isUTF8String(),
145 "Stringifier attributes should allow UTF8String",
148 parser = parser.reset()
149 threw = False
150 try:
151 parser.parse(
153 interface TestStringifier {
154 stringifier attribute ByteString foo;
158 results = parser.finish()
159 except WebIDL.WebIDLError:
160 threw = True
162 harness.ok(threw, "Should not allow ByteString")
164 parser = parser.reset()
165 threw = False
166 try:
167 parser.parse(
169 interface TestStringifier {
170 stringifier;
171 stringifier attribute DOMString foo;
175 results = parser.finish()
176 except WebIDL.WebIDLError:
177 threw = True
179 harness.ok(threw, "Should not allow a 'stringifier;' and a stringifier attribute")
181 parser = parser.reset()
182 threw = False
183 try:
184 parser.parse(
186 interface TestStringifier {
187 stringifier attribute DOMString foo;
188 stringifier attribute DOMString bar;
192 results = parser.finish()
193 except WebIDL.WebIDLError:
194 threw = True
196 harness.ok(threw, "Should not allow multiple stringifier attributes")