|
1 def WebIDLTest(parser, harness): |
|
2 parser.parse(""" |
|
3 [Global] |
|
4 interface Foo : Bar { |
|
5 getter any(DOMString name); |
|
6 }; |
|
7 interface Bar {}; |
|
8 """) |
|
9 |
|
10 results = parser.finish() |
|
11 |
|
12 harness.ok(results[0].isOnGlobalProtoChain(), |
|
13 "[Global] interface should be on global's proto chain") |
|
14 harness.ok(results[1].isOnGlobalProtoChain(), |
|
15 "[Global] interface should be on global's proto chain") |
|
16 |
|
17 parser = parser.reset() |
|
18 threw = False |
|
19 try: |
|
20 parser.parse(""" |
|
21 [Global] |
|
22 interface Foo { |
|
23 getter any(DOMString name); |
|
24 setter void(DOMString name, any arg); |
|
25 }; |
|
26 """) |
|
27 results = parser.finish() |
|
28 except: |
|
29 threw = True |
|
30 |
|
31 harness.ok(threw, |
|
32 "Should have thrown for [Global] used on an interface with a " |
|
33 "named setter") |
|
34 |
|
35 parser = parser.reset() |
|
36 threw = False |
|
37 try: |
|
38 parser.parse(""" |
|
39 [Global] |
|
40 interface Foo { |
|
41 getter any(DOMString name); |
|
42 creator void(DOMString name, any arg); |
|
43 }; |
|
44 """) |
|
45 results = parser.finish() |
|
46 except: |
|
47 threw = True |
|
48 |
|
49 harness.ok(threw, |
|
50 "Should have thrown for [Global] used on an interface with a " |
|
51 "named creator") |
|
52 |
|
53 parser = parser.reset() |
|
54 threw = False |
|
55 try: |
|
56 parser.parse(""" |
|
57 [Global] |
|
58 interface Foo { |
|
59 getter any(DOMString name); |
|
60 deleter void(DOMString name); |
|
61 }; |
|
62 """) |
|
63 results = parser.finish() |
|
64 except: |
|
65 threw = True |
|
66 |
|
67 harness.ok(threw, |
|
68 "Should have thrown for [Global] used on an interface with a " |
|
69 "named deleter") |
|
70 |
|
71 parser = parser.reset() |
|
72 threw = False |
|
73 try: |
|
74 parser.parse(""" |
|
75 [Global, OverrideBuiltins] |
|
76 interface Foo { |
|
77 }; |
|
78 """) |
|
79 results = parser.finish() |
|
80 except: |
|
81 threw = True |
|
82 |
|
83 harness.ok(threw, |
|
84 "Should have thrown for [Global] used on an interface with a " |
|
85 "[OverrideBuiltins]") |
|
86 |
|
87 parser = parser.reset() |
|
88 threw = False |
|
89 try: |
|
90 parser.parse(""" |
|
91 [Global] |
|
92 interface Foo : Bar { |
|
93 }; |
|
94 [OverrideBuiltins] |
|
95 interface Bar { |
|
96 }; |
|
97 """) |
|
98 results = parser.finish() |
|
99 except: |
|
100 threw = True |
|
101 |
|
102 harness.ok(threw, |
|
103 "Should have thrown for [Global] used on an interface with an " |
|
104 "[OverrideBuiltins] ancestor") |
|
105 |
|
106 parser = parser.reset() |
|
107 threw = False |
|
108 try: |
|
109 parser.parse(""" |
|
110 [Global] |
|
111 interface Foo { |
|
112 }; |
|
113 interface Bar : Foo { |
|
114 }; |
|
115 """) |
|
116 results = parser.finish() |
|
117 except: |
|
118 threw = True |
|
119 |
|
120 harness.ok(threw, |
|
121 "Should have thrown for [Global] used on an interface with a " |
|
122 "descendant") |