4 def WebIDLTest(parser
, harness
):
7 interface TestStringifier {
13 results
= parser
.finish()
16 isinstance(results
[0].members
[0], WebIDL
.IDLMethod
),
17 "Stringifer should be method",
20 parser
= parser
.reset()
26 interface TestStringifier {
32 results
= parser
.finish()
33 except WebIDL
.WebIDLError
:
36 harness
.ok(threw
, "Should not allow two 'stringifier;'")
38 parser
= parser
.reset()
44 interface TestStringifier {
46 stringifier DOMString foo();
50 results
= parser
.finish()
51 except WebIDL
.WebIDLError
:
54 harness
.ok(threw
, "Should not allow a 'stringifier;' and a 'stringifier()'")
56 parser
= parser
.reset()
59 interface TestStringifier {
60 stringifier attribute DOMString foo;
64 results
= parser
.finish()
66 isinstance(results
[0].members
[0], WebIDL
.IDLAttribute
),
67 "Stringifier attribute should be an attribute",
69 stringifier
= results
[0].members
[1]
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()
79 interface TestStringifier {};
80 interface mixin TestStringifierMixin {
81 stringifier attribute DOMString foo;
83 TestStringifier includes TestStringifierMixin;
86 results
= parser
.finish()
88 isinstance(results
[0].members
[0], WebIDL
.IDLAttribute
),
89 "Stringifier attribute should be an attribute",
91 stringifier
= results
[0].members
[1]
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()
101 interface TestStringifier {
102 stringifier attribute USVString foo;
106 results
= parser
.finish()
107 stringifier
= results
[0].members
[1]
109 stringifier
.signatures()[0][0].isUSVString(),
110 "Stringifier attributes should allow USVString",
113 parser
= parser
.reset()
116 interface TestStringifier {
117 [Throws, NeedsSubjectPrincipal]
118 stringifier attribute USVString foo;
122 results
= parser
.finish()
123 stringifier
= results
[0].members
[1]
125 stringifier
.getExtendedAttribute("Throws"),
126 "Stringifier attributes should support [Throws]",
129 stringifier
.getExtendedAttribute("NeedsSubjectPrincipal"),
130 "Stringifier attributes should support [NeedsSubjectPrincipal]",
133 parser
= parser
.reset()
136 interface TestStringifier {
137 stringifier attribute UTF8String foo;
141 results
= parser
.finish()
142 stringifier
= results
[0].members
[1]
144 stringifier
.signatures()[0][0].isUTF8String(),
145 "Stringifier attributes should allow UTF8String",
148 parser
= parser
.reset()
153 interface TestStringifier {
154 stringifier attribute ByteString foo;
158 results
= parser
.finish()
159 except WebIDL
.WebIDLError
:
162 harness
.ok(threw
, "Should not allow ByteString")
164 parser
= parser
.reset()
169 interface TestStringifier {
171 stringifier attribute DOMString foo;
175 results
= parser
.finish()
176 except WebIDL
.WebIDLError
:
179 harness
.ok(threw
, "Should not allow a 'stringifier;' and a stringifier attribute")
181 parser
= parser
.reset()
186 interface TestStringifier {
187 stringifier attribute DOMString foo;
188 stringifier attribute DOMString bar;
192 results
= parser
.finish()
193 except WebIDL
.WebIDLError
:
196 harness
.ok(threw
, "Should not allow multiple stringifier attributes")