4 def WebIDLTest(parser
, harness
):
5 parser
= parser
.reset()
13 [LegacyTreatNonObjectAsNull] callback TestCallback = undefined ();
14 typedef (TestCallback or TestDict) TestUnionCallbackDict;
17 results
= parser
.finish()
18 except WebIDL
.WebIDLError
:
22 "Should not allow Dict/Callback union where callback is [LegacyTreatNonObjectAsNull]",
25 parser
= parser
.reset()
34 [LegacyTreatNonObjectAsNull] callback TestCallback = undefined ();
35 typedef (TestDict or TestCallback) TestUnionCallbackDict;
38 results
= parser
.finish()
39 except WebIDL
.WebIDLError
:
43 "Should not allow Dict/Callback union where callback is [LegacyTreatNonObjectAsNull]",
46 parser
= parser
.reset()
53 callback TestCallback = undefined ();
54 typedef (TestCallback or TestDict) TestUnionCallbackDict;
57 results
= parser
.finish()
59 harness
.ok(True, "TestUnionCallbackDict interface parsed without error")
60 harness
.check(len(results
), 3, "Document should have 3 types")
63 harness
.ok(isinstance(myDict
, WebIDL
.IDLDictionary
), "Expect an IDLDictionary")
65 myCallback
= results
[1]
66 harness
.ok(isinstance(myCallback
, WebIDL
.IDLCallback
), "Expect an IDLCallback")
69 harness
.ok(isinstance(myUnion
, WebIDL
.IDLTypedef
), "Expect a IDLTypedef")
71 isinstance(myUnion
.innerType
, WebIDL
.IDLUnionType
), "Expect a IDLUnionType"
74 isinstance(myUnion
.innerType
.memberTypes
[0], WebIDL
.IDLCallbackType
),
75 "Expect a IDLCallbackType",
78 isinstance(myUnion
.innerType
.memberTypes
[1], WebIDL
.IDLWrapperType
),
79 "Expect a IDLDictionary",
82 (myUnion
.innerType
.memberTypes
[0].callback
== myCallback
),
83 "Expect left Union member to be MyCallback",
86 (myUnion
.innerType
.memberTypes
[1].inner
== myDict
),
87 "Expect right Union member to be MyDict",
90 parser
= parser
.reset()
97 callback TestCallback = undefined ();
98 typedef (TestDict or TestCallback) TestUnionCallbackDict;
101 results
= parser
.finish()
103 harness
.ok(True, "TestUnionCallbackDict interface parsed without error")
104 harness
.check(len(results
), 3, "Document should have 3 types")
107 harness
.ok(isinstance(myDict
, WebIDL
.IDLDictionary
), "Expect an IDLDictionary")
109 myCallback
= results
[1]
110 harness
.ok(isinstance(myCallback
, WebIDL
.IDLCallback
), "Expect an IDLCallback")
113 harness
.ok(isinstance(myUnion
, WebIDL
.IDLTypedef
), "Expect a IDLTypedef")
115 isinstance(myUnion
.innerType
, WebIDL
.IDLUnionType
), "Expect a IDLUnionType"
118 isinstance(myUnion
.innerType
.memberTypes
[0], WebIDL
.IDLWrapperType
),
119 "Expect a IDLDictionary",
122 isinstance(myUnion
.innerType
.memberTypes
[1], WebIDL
.IDLCallbackType
),
123 "Expect a IDLCallbackType",
126 (myUnion
.innerType
.memberTypes
[0].inner
== myDict
),
127 "Expect right Union member to be MyDict",
130 (myUnion
.innerType
.memberTypes
[1].callback
== myCallback
),
131 "Expect left Union member to be MyCallback",