Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_treatNonCallableAsNull.py
blob8ad7f942b1264eaf6f0786d10901c7e80021d2ed
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 parser.parse(
6 """
7 [TreatNonCallableAsNull] callback Function = any(any... arguments);
9 interface TestTreatNonCallableAsNull1 {
10 attribute Function? onfoo;
11 attribute Function onbar;
13 """
16 results = parser.finish()
18 iface = results[1]
19 attr = iface.members[0]
20 harness.check(attr.type.treatNonCallableAsNull(), True, "Got the expected value")
21 attr = iface.members[1]
22 harness.check(attr.type.treatNonCallableAsNull(), False, "Got the expected value")
24 parser = parser.reset()
26 threw = False
27 try:
28 parser.parse(
29 """
30 callback Function = any(any... arguments);
32 interface TestTreatNonCallableAsNull2 {
33 [TreatNonCallableAsNull] attribute Function onfoo;
35 """
38 results = parser.finish()
39 except WebIDL.WebIDLError:
40 threw = True
42 harness.ok(threw, "Should have thrown.")
44 parser = parser.reset()
46 threw = False
47 try:
48 parser.parse(
49 """
50 callback Function = any(any... arguments);
52 [TreatNonCallableAsNull]
53 interface TestTreatNonCallableAsNull3 {
54 attribute Function onfoo;
56 """
59 results = parser.finish()
60 except WebIDL.WebIDLError:
61 threw = True
63 harness.ok(threw, "Should have thrown.")
65 parser = parser.reset()
67 threw = False
68 try:
69 parser.parse(
70 """
71 [TreatNonCallableAsNull, LegacyTreatNonObjectAsNull]
72 callback Function = any(any... arguments);
73 """
76 results = parser.finish()
77 except WebIDL.WebIDLError:
78 threw = True
80 harness.ok(threw, "Should have thrown.")