Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_special_methods.py
blob911bb8ec0dab3e102e451a0b8c949a47ba39908e
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 parser.parse(
6 """
7 interface SpecialMethods {
8 getter long long (unsigned long index);
9 setter long long (unsigned long index, long long value);
10 getter boolean (DOMString name);
11 setter boolean (DOMString name, boolean value);
12 deleter boolean (DOMString name);
13 readonly attribute unsigned long length;
16 interface SpecialMethodsCombination {
17 getter deleter boolean (DOMString name);
19 """
22 results = parser.finish()
24 def checkMethod(
25 method,
26 QName,
27 name,
28 static=False,
29 getter=False,
30 setter=False,
31 deleter=False,
32 legacycaller=False,
33 stringifier=False,
35 harness.ok(isinstance(method, WebIDL.IDLMethod), "Should be an IDLMethod")
36 harness.check(method.identifier.QName(), QName, "Method has the right QName")
37 harness.check(method.identifier.name, name, "Method has the right name")
38 harness.check(method.isStatic(), static, "Method has the correct static value")
39 harness.check(method.isGetter(), getter, "Method has the correct getter value")
40 harness.check(method.isSetter(), setter, "Method has the correct setter value")
41 harness.check(
42 method.isDeleter(), deleter, "Method has the correct deleter value"
44 harness.check(
45 method.isLegacycaller(),
46 legacycaller,
47 "Method has the correct legacycaller value",
49 harness.check(
50 method.isStringifier(),
51 stringifier,
52 "Method has the correct stringifier value",
55 harness.check(len(results), 2, "Expect 2 interfaces")
57 iface = results[0]
58 harness.check(len(iface.members), 6, "Expect 6 members")
60 checkMethod(
61 iface.members[0],
62 "::SpecialMethods::__indexedgetter",
63 "__indexedgetter",
64 getter=True,
66 checkMethod(
67 iface.members[1],
68 "::SpecialMethods::__indexedsetter",
69 "__indexedsetter",
70 setter=True,
72 checkMethod(
73 iface.members[2],
74 "::SpecialMethods::__namedgetter",
75 "__namedgetter",
76 getter=True,
78 checkMethod(
79 iface.members[3],
80 "::SpecialMethods::__namedsetter",
81 "__namedsetter",
82 setter=True,
84 checkMethod(
85 iface.members[4],
86 "::SpecialMethods::__nameddeleter",
87 "__nameddeleter",
88 deleter=True,
91 iface = results[1]
92 harness.check(len(iface.members), 1, "Expect 1 member")
94 checkMethod(
95 iface.members[0],
96 "::SpecialMethodsCombination::__namedgetterdeleter",
97 "__namedgetterdeleter",
98 getter=True,
99 deleter=True,
102 parser = parser.reset()
104 threw = False
105 try:
106 parser.parse(
108 interface IndexedDeleter {
109 deleter undefined(unsigned long index);
113 parser.finish()
114 except WebIDL.WebIDLError:
115 threw = True
117 harness.ok(threw, "There are no indexed deleters")