|
1 import WebIDL |
|
2 |
|
3 def WebIDLTest(parser, harness): |
|
4 parser.parse(""" |
|
5 [TreatNonCallableAsNull] callback Function = any(any... arguments); |
|
6 |
|
7 interface TestTreatNonCallableAsNull1 { |
|
8 attribute Function? onfoo; |
|
9 attribute Function onbar; |
|
10 }; |
|
11 """) |
|
12 |
|
13 results = parser.finish() |
|
14 |
|
15 iface = results[1] |
|
16 attr = iface.members[0] |
|
17 harness.check(attr.type.treatNonCallableAsNull(), True, "Got the expected value") |
|
18 attr = iface.members[1] |
|
19 harness.check(attr.type.treatNonCallableAsNull(), False, "Got the expected value") |
|
20 |
|
21 parser = parser.reset() |
|
22 |
|
23 threw = False |
|
24 try: |
|
25 parser.parse(""" |
|
26 callback Function = any(any... arguments); |
|
27 |
|
28 interface TestTreatNonCallableAsNull2 { |
|
29 [TreatNonCallableAsNull] attribute Function onfoo; |
|
30 }; |
|
31 """) |
|
32 |
|
33 results = parser.finish() |
|
34 except: |
|
35 threw = True |
|
36 |
|
37 harness.ok(threw, "Should have thrown.") |
|
38 |
|
39 parser = parser.reset() |
|
40 |
|
41 threw = False |
|
42 try: |
|
43 parser.parse(""" |
|
44 callback Function = any(any... arguments); |
|
45 |
|
46 [TreatNonCallableAsNull] |
|
47 interface TestTreatNonCallableAsNull3 { |
|
48 attribute Function onfoo; |
|
49 }; |
|
50 """) |
|
51 |
|
52 results = parser.finish() |
|
53 except: |
|
54 threw = True |
|
55 |
|
56 harness.ok(threw, "Should have thrown.") |
|
57 |
|
58 parser = parser.reset() |
|
59 |
|
60 threw = False |
|
61 try: |
|
62 parser.parse(""" |
|
63 [TreatNonCallableAsNull, TreatNonObjectAsNull] |
|
64 callback Function = any(any... arguments); |
|
65 """) |
|
66 |
|
67 results = parser.finish() |
|
68 except: |
|
69 threw = True |
|
70 |
|
71 harness.ok(threw, "Should have thrown.") |