Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_reflected_attribute.py
blob33028d8d7d19989cd256b4b6929e6e4c9f14e3a6
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 def parseWithNode(test):
6 parser.parse(
7 """
8 interface Node {};
9 interface Document : Node {};
10 interface Element : Node {};
11 interface HTMLElement : Element {};
12 """
13 + test
16 def parseFrozenArrayAttribute(innerType):
17 parseWithNode(
18 """
19 interface ReflectedAttribute {
20 [Frozen, ReflectedHTMLAttributeReturningFrozenArray]
21 attribute sequence<%s>? reflectedHTMLAttribute;
23 """
24 % innerType
27 results = parser.finish()
29 harness.check(len(results), 5, "Should know about one thing")
30 harness.ok(
31 isinstance(results[4], WebIDL.IDLInterface), "Should have an interface here"
33 members = results[4].members
34 harness.check(len(members), 1, "Should have one member")
35 harness.ok(members[0].isAttr(), "Should have attribute")
36 harness.ok(
37 members[0].getExtendedAttribute(
38 "ReflectedHTMLAttributeReturningFrozenArray"
40 is not None,
41 "Should have extended attribute",
44 parseFrozenArrayAttribute("Element")
46 parser = parser.reset()
47 parseFrozenArrayAttribute("HTMLElement")
49 parser = parser.reset()
50 threw = False
51 try:
52 parseWithNode(
53 """
54 interface ReflectedAttribute {
55 [ReflectedHTMLAttributeReturningFrozenArray]
56 attribute Element? reflectedHTMLAttribute;
58 """
61 parser.finish()
62 except WebIDL.WebIDLError:
63 threw = True
64 harness.ok(
65 threw,
66 "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
67 "should only be used on attributes with a sequence<*Element> type.",
70 parser = parser.reset()
71 threw = False
72 try:
73 parseWithNode(
74 """
75 interface ReflectedAttribute {
76 [Frozen, ReflectedHTMLAttributeReturningFrozenArray]
77 attribute sequence<long> reflectedHTMLAttribute;
79 """
82 parser.finish()
83 except WebIDL.WebIDLError:
84 threw = True
85 harness.ok(
86 threw,
87 "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
88 "should only be used on attributes with a sequence<*Element> type.",
91 parser = parser.reset()
92 threw = False
93 try:
94 parseWithNode(
95 """
96 interface ReflectedAttribute {
97 [Frozen, ReflectedHTMLAttributeReturningFrozenArray]
98 attribute sequence<Document> reflectedHTMLAttribute;
103 parser.finish()
104 except WebIDL.WebIDLError:
105 threw = True
106 harness.ok(
107 threw,
108 "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
109 "should only be used on attributes with a sequence<*Element> type.",
112 parser = parser.reset()
113 threw = False
114 try:
115 parseWithNode(
117 interface ReflectedAttribute {
118 [ReflectedHTMLAttributeReturningFrozenArray]
119 sequence<Element>? reflectedHTMLAttribute();
124 parser.finish()
125 except WebIDL.WebIDLError:
126 threw = True
127 harness.ok(
128 threw,
129 "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
130 "should only be used on attributes with a sequence<*Element> type.",
133 parser = parser.reset()
134 threw = False
135 try:
136 parseWithNode(
138 interface ReflectedAttribute {
139 [Frozen, ReflectedHTMLAttributeReturningFrozenArray, Cached, Pure]
140 attribute sequence<Element>? reflectedHTMLAttribute;
145 parser.finish()
146 except WebIDL.WebIDLError:
147 threw = True
148 harness.ok(
149 threw,
150 "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
151 "should not be used together with [Cached].",
154 parser = parser.reset()
155 threw = False
156 try:
157 parseWithNode(
159 interface ReflectedAttribute {
160 [Frozen, ReflectedHTMLAttributeReturningFrozenArray, StoreInSlot, Pure]
161 attribute sequence<Element>? reflectedHTMLAttribute;
166 parser.finish()
167 except WebIDL.WebIDLError:
168 threw = True
169 harness.ok(
170 threw,
171 "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
172 "should not be used together with [Cached].",
175 parser = parser.reset()
176 threw = False
177 try:
178 parseWithNode(
180 interface ReflectedAttributeBase {
181 [Frozen, ReflectedHTMLAttributeReturningFrozenArray]
182 attribute sequence<Element>? reflectedHTMLAttributeBase;
184 interface ReflectedAttribute : ReflectedAttributeBase {
185 [Frozen, ReflectedHTMLAttributeReturningFrozenArray]
186 attribute sequence<Element>? reflectedHTMLAttribute;
191 parser.finish()
192 except WebIDL.WebIDLError:
193 threw = True
194 harness.ok(
195 threw,
196 "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
197 "should not be used on the attribute of an interface that inherits from "
198 "an interface that also has an attribute with "
199 "[ReflectedHTMLAttributeReturningFrozenArray].",