|
1 def WebIDLTest(parser, harness): |
|
2 parser.parse(""" |
|
3 interface Child : Parent { |
|
4 }; |
|
5 interface Parent { |
|
6 [Unforgeable] readonly attribute long foo; |
|
7 }; |
|
8 """) |
|
9 |
|
10 results = parser.finish() |
|
11 harness.check(len(results), 2, |
|
12 "Should be able to inherit from an interface with " |
|
13 "[Unforgeable] properties.") |
|
14 |
|
15 parser = parser.reset(); |
|
16 parser.parse(""" |
|
17 interface Child : Parent { |
|
18 const short foo = 10; |
|
19 }; |
|
20 interface Parent { |
|
21 [Unforgeable] readonly attribute long foo; |
|
22 }; |
|
23 """) |
|
24 |
|
25 results = parser.finish() |
|
26 harness.check(len(results), 2, |
|
27 "Should be able to inherit from an interface with " |
|
28 "[Unforgeable] properties even if we have a constant with " |
|
29 "the same name.") |
|
30 |
|
31 parser = parser.reset(); |
|
32 parser.parse(""" |
|
33 interface Child : Parent { |
|
34 static attribute short foo; |
|
35 }; |
|
36 interface Parent { |
|
37 [Unforgeable] readonly attribute long foo; |
|
38 }; |
|
39 """) |
|
40 |
|
41 results = parser.finish() |
|
42 harness.check(len(results), 2, |
|
43 "Should be able to inherit from an interface with " |
|
44 "[Unforgeable] properties even if we have a static attribute " |
|
45 "with the same name.") |
|
46 |
|
47 parser = parser.reset(); |
|
48 parser.parse(""" |
|
49 interface Child : Parent { |
|
50 static void foo(); |
|
51 }; |
|
52 interface Parent { |
|
53 [Unforgeable] readonly attribute long foo; |
|
54 }; |
|
55 """) |
|
56 |
|
57 results = parser.finish() |
|
58 harness.check(len(results), 2, |
|
59 "Should be able to inherit from an interface with " |
|
60 "[Unforgeable] properties even if we have a static operation " |
|
61 "with the same name.") |
|
62 |
|
63 parser = parser.reset(); |
|
64 threw = False |
|
65 try: |
|
66 parser.parse(""" |
|
67 interface Child : Parent { |
|
68 void foo(); |
|
69 }; |
|
70 interface Parent { |
|
71 [Unforgeable] readonly attribute long foo; |
|
72 }; |
|
73 """) |
|
74 |
|
75 results = parser.finish() |
|
76 except: |
|
77 threw = True |
|
78 harness.ok(threw, |
|
79 "Should have thrown when shadowing unforgeable attribute on " |
|
80 "parent with operation.") |
|
81 |
|
82 parser = parser.reset(); |
|
83 threw = False |
|
84 try: |
|
85 parser.parse(""" |
|
86 interface Child : Parent { |
|
87 attribute short foo; |
|
88 }; |
|
89 interface Parent { |
|
90 [Unforgeable] readonly attribute long foo; |
|
91 }; |
|
92 """) |
|
93 |
|
94 results = parser.finish() |
|
95 except Exception,x: |
|
96 threw = True |
|
97 harness.ok(threw, |
|
98 "Should have thrown when shadowing unforgeable attribute on " |
|
99 "parent with attribute.") |
|
100 |
|
101 parser = parser.reset(); |
|
102 parser.parse(""" |
|
103 interface Child : Parent { |
|
104 }; |
|
105 interface Parent {}; |
|
106 interface Consequential { |
|
107 [Unforgeable] readonly attribute long foo; |
|
108 }; |
|
109 Parent implements Consequential; |
|
110 """) |
|
111 |
|
112 results = parser.finish() |
|
113 harness.check(len(results), 4, |
|
114 "Should be able to inherit from an interface with a " |
|
115 "consequential interface with [Unforgeable] properties.") |
|
116 |
|
117 parser = parser.reset(); |
|
118 threw = False |
|
119 try: |
|
120 parser.parse(""" |
|
121 interface Child : Parent { |
|
122 void foo(); |
|
123 }; |
|
124 interface Parent {}; |
|
125 interface Consequential { |
|
126 [Unforgeable] readonly attribute long foo; |
|
127 }; |
|
128 Parent implements Consequential; |
|
129 """) |
|
130 |
|
131 results = parser.finish() |
|
132 except: |
|
133 threw = True |
|
134 |
|
135 harness.ok(threw, |
|
136 "Should have thrown when shadowing unforgeable attribute " |
|
137 "of parent's consequential interface.") |
|
138 |
|
139 parser = parser.reset(); |
|
140 threw = False |
|
141 try: |
|
142 parser.parse(""" |
|
143 interface Child : Parent { |
|
144 }; |
|
145 interface Parent : GrandParent {}; |
|
146 interface GrandParent {}; |
|
147 interface Consequential { |
|
148 [Unforgeable] readonly attribute long foo; |
|
149 }; |
|
150 GrandParent implements Consequential; |
|
151 interface ChildConsequential { |
|
152 void foo(); |
|
153 }; |
|
154 Child implements ChildConsequential; |
|
155 """) |
|
156 |
|
157 results = parser.finish() |
|
158 except: |
|
159 threw = True |
|
160 |
|
161 harness.ok(threw, |
|
162 "Should have thrown when our consequential interface shadows unforgeable attribute " |
|
163 "of ancestor's consequential interface.") |
|
164 |
|
165 parser = parser.reset(); |
|
166 threw = False |
|
167 try: |
|
168 parser.parse(""" |
|
169 interface iface { |
|
170 [Unforgeable] attribute long foo; |
|
171 }; |
|
172 """) |
|
173 |
|
174 results = parser.finish() |
|
175 except: |
|
176 threw = True |
|
177 |
|
178 harness.ok(threw, "Should have thrown for writable [Unforgeable] attribute.") |
|
179 |
|
180 parser = parser.reset(); |
|
181 threw = False |
|
182 try: |
|
183 parser.parse(""" |
|
184 interface iface { |
|
185 [Unforgeable] static readonly attribute long foo; |
|
186 }; |
|
187 """) |
|
188 |
|
189 results = parser.finish() |
|
190 except: |
|
191 threw = True |
|
192 |
|
193 harness.ok(threw, "Should have thrown for static [Unforgeable] attribute.") |