Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_union_callback_dict.py
blob3e87e16ad471edc4f4d2875bda7a0162acefee40
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 parser = parser.reset()
6 threw = False
7 try:
8 parser.parse(
9 """
10 dictionary TestDict {
11 DOMString member;
13 [LegacyTreatNonObjectAsNull] callback TestCallback = undefined ();
14 typedef (TestCallback or TestDict) TestUnionCallbackDict;
15 """
17 results = parser.finish()
18 except WebIDL.WebIDLError:
19 threw = True
20 harness.ok(
21 threw,
22 "Should not allow Dict/Callback union where callback is [LegacyTreatNonObjectAsNull]",
25 parser = parser.reset()
27 threw = False
28 try:
29 parser.parse(
30 """
31 dictionary TestDict {
32 DOMString member;
34 [LegacyTreatNonObjectAsNull] callback TestCallback = undefined ();
35 typedef (TestDict or TestCallback) TestUnionCallbackDict;
36 """
38 results = parser.finish()
39 except WebIDL.WebIDLError:
40 threw = True
41 harness.ok(
42 threw,
43 "Should not allow Dict/Callback union where callback is [LegacyTreatNonObjectAsNull]",
46 parser = parser.reset()
48 parser.parse(
49 """
50 dictionary TestDict {
51 DOMString member;
53 callback TestCallback = undefined ();
54 typedef (TestCallback or TestDict) TestUnionCallbackDict;
55 """
57 results = parser.finish()
59 harness.ok(True, "TestUnionCallbackDict interface parsed without error")
60 harness.check(len(results), 3, "Document should have 3 types")
62 myDict = results[0]
63 harness.ok(isinstance(myDict, WebIDL.IDLDictionary), "Expect an IDLDictionary")
65 myCallback = results[1]
66 harness.ok(isinstance(myCallback, WebIDL.IDLCallback), "Expect an IDLCallback")
68 myUnion = results[2]
69 harness.ok(isinstance(myUnion, WebIDL.IDLTypedef), "Expect a IDLTypedef")
70 harness.ok(
71 isinstance(myUnion.innerType, WebIDL.IDLUnionType), "Expect a IDLUnionType"
73 harness.ok(
74 isinstance(myUnion.innerType.memberTypes[0], WebIDL.IDLCallbackType),
75 "Expect a IDLCallbackType",
77 harness.ok(
78 isinstance(myUnion.innerType.memberTypes[1], WebIDL.IDLWrapperType),
79 "Expect a IDLDictionary",
81 harness.ok(
82 (myUnion.innerType.memberTypes[0].callback == myCallback),
83 "Expect left Union member to be MyCallback",
85 harness.ok(
86 (myUnion.innerType.memberTypes[1].inner == myDict),
87 "Expect right Union member to be MyDict",
90 parser = parser.reset()
92 parser.parse(
93 """
94 dictionary TestDict {
95 DOMString member;
97 callback TestCallback = undefined ();
98 typedef (TestDict or TestCallback) TestUnionCallbackDict;
99 """
101 results = parser.finish()
103 harness.ok(True, "TestUnionCallbackDict interface parsed without error")
104 harness.check(len(results), 3, "Document should have 3 types")
106 myDict = results[0]
107 harness.ok(isinstance(myDict, WebIDL.IDLDictionary), "Expect an IDLDictionary")
109 myCallback = results[1]
110 harness.ok(isinstance(myCallback, WebIDL.IDLCallback), "Expect an IDLCallback")
112 myUnion = results[2]
113 harness.ok(isinstance(myUnion, WebIDL.IDLTypedef), "Expect a IDLTypedef")
114 harness.ok(
115 isinstance(myUnion.innerType, WebIDL.IDLUnionType), "Expect a IDLUnionType"
117 harness.ok(
118 isinstance(myUnion.innerType.memberTypes[0], WebIDL.IDLWrapperType),
119 "Expect a IDLDictionary",
121 harness.ok(
122 isinstance(myUnion.innerType.memberTypes[1], WebIDL.IDLCallbackType),
123 "Expect a IDLCallbackType",
125 harness.ok(
126 (myUnion.innerType.memberTypes[0].inner == myDict),
127 "Expect right Union member to be MyDict",
129 harness.ok(
130 (myUnion.innerType.memberTypes[1].callback == myCallback),
131 "Expect left Union member to be MyCallback",