|
1 import WebIDL |
|
2 |
|
3 def WebIDLTest(parser, harness): |
|
4 parser.parse(""" |
|
5 [NoInterfaceObject] |
|
6 interface TestExtendedAttr { |
|
7 [Unforgeable] readonly attribute byte b; |
|
8 }; |
|
9 """) |
|
10 |
|
11 results = parser.finish() |
|
12 |
|
13 parser = parser.reset() |
|
14 parser.parse(""" |
|
15 [Pref="foo.bar",Pref=flop] |
|
16 interface TestExtendedAttr { |
|
17 [Pref="foo.bar"] attribute byte b; |
|
18 }; |
|
19 """) |
|
20 |
|
21 results = parser.finish() |
|
22 |
|
23 parser = parser.reset() |
|
24 parser.parse(""" |
|
25 interface TestLenientThis { |
|
26 [LenientThis] attribute byte b; |
|
27 }; |
|
28 """) |
|
29 |
|
30 results = parser.finish() |
|
31 harness.ok(results[0].members[0].hasLenientThis(), |
|
32 "Should have a lenient this") |
|
33 |
|
34 parser = parser.reset() |
|
35 threw = False |
|
36 try: |
|
37 parser.parse(""" |
|
38 interface TestLenientThis2 { |
|
39 [LenientThis=something] attribute byte b; |
|
40 }; |
|
41 """) |
|
42 results = parser.finish() |
|
43 except: |
|
44 threw = True |
|
45 |
|
46 harness.ok(threw, "[LenientThis] must take no arguments") |
|
47 |
|
48 parser = parser.reset() |
|
49 parser.parse(""" |
|
50 interface TestClamp { |
|
51 void testClamp([Clamp] long foo); |
|
52 void testNotClamp(long foo); |
|
53 }; |
|
54 """) |
|
55 |
|
56 results = parser.finish() |
|
57 # Pull out the first argument out of the arglist of the first (and |
|
58 # only) signature. |
|
59 harness.ok(results[0].members[0].signatures()[0][1][0].clamp, |
|
60 "Should be clamped") |
|
61 harness.ok(not results[0].members[1].signatures()[0][1][0].clamp, |
|
62 "Should not be clamped") |
|
63 |
|
64 parser = parser.reset() |
|
65 threw = False |
|
66 try: |
|
67 parser.parse(""" |
|
68 interface TestClamp2 { |
|
69 void testClamp([Clamp=something] long foo); |
|
70 }; |
|
71 """) |
|
72 results = parser.finish() |
|
73 except: |
|
74 threw = True |
|
75 |
|
76 harness.ok(threw, "[Clamp] must take no arguments") |
|
77 |
|
78 parser = parser.reset() |
|
79 parser.parse(""" |
|
80 interface TestEnforceRange { |
|
81 void testEnforceRange([EnforceRange] long foo); |
|
82 void testNotEnforceRange(long foo); |
|
83 }; |
|
84 """) |
|
85 |
|
86 results = parser.finish() |
|
87 # Pull out the first argument out of the arglist of the first (and |
|
88 # only) signature. |
|
89 harness.ok(results[0].members[0].signatures()[0][1][0].enforceRange, |
|
90 "Should be enforceRange") |
|
91 harness.ok(not results[0].members[1].signatures()[0][1][0].enforceRange, |
|
92 "Should not be enforceRange") |
|
93 |
|
94 parser = parser.reset() |
|
95 threw = False |
|
96 try: |
|
97 parser.parse(""" |
|
98 interface TestEnforceRange2 { |
|
99 void testEnforceRange([EnforceRange=something] long foo); |
|
100 }; |
|
101 """) |
|
102 results = parser.finish() |
|
103 except: |
|
104 threw = True |
|
105 |
|
106 harness.ok(threw, "[EnforceRange] must take no arguments") |
|
107 |