Revision 4307
Added by ben leinfelder over 16 years ago
lib/spatial/mapbuilder/LICENSE | ||
---|---|---|
1 |
Mapbuilder-lib is a browser based Web Mapping client.
|
|
2 |
http://mapbuilder.sourceforge.net
|
|
1 |
MapBuilder is a powerful, standards compliant geographic mapping client
|
|
2 |
which runs in a web browser. More details at http://communitymapbuilder.org
|
|
3 | 3 |
|
4 |
Copyright (C) 2005 Cameron Shorter, Mike Adair, Nedjo Rodgers, |
|
5 |
Tom Kralidis, Matthew Perry. |
|
4 |
Mapbuilder source code is copyright (C) 2008 to the following people: |
|
5 |
Name Login Id |
|
6 |
==== ======== |
|
7 |
Andreas Hocevar ahocevar |
|
8 |
Cameron Shorter camerons |
|
9 |
Christopher Schmit crschmidt |
|
10 |
Dirk van den Elzen dirk |
|
11 |
Gertjan van Oosten gjvoosten |
|
12 |
Jean-sebastien baklouti jseb.baklouti |
|
13 |
John Pulles johnp |
|
14 |
Linda Derezinski derezinski |
|
15 |
Matthew D. Diez mattdiez |
|
16 |
Matthew Perry |
|
17 |
Michael Jenik maiqui |
|
18 |
Mike Adair madair madair1 |
|
19 |
Nedjo Rogers nedjo |
|
20 |
Olivier Terral Oterral |
|
21 |
Pat Cappelaere cappelaere |
|
22 |
Radim Blazek rabla |
|
23 |
Raj Singh rajsingh |
|
24 |
Richard Greenwood rgreenwood |
|
25 |
Roald de Wit rdewit |
|
26 |
Stefano Menegon menegon |
|
27 |
Steven M. Ottens graphrisc steven |
|
28 |
Tom Kralidis tomkralidis |
|
6 | 29 |
|
7 | 30 |
This library is free software; you can redistribute it and/or |
8 | 31 |
modify it under the terms of the GNU Lesser General Public |
... | ... | |
17 | 40 |
You should have received a copy of the GNU Lesser General Public |
18 | 41 |
License along with this library; if not, write to the Free Software |
19 | 42 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
43 |
|
|
44 |
-- |
|
45 |
|
|
46 |
It is the intent of this project that all Mapbuilder developers who |
|
47 |
have been given write access to the Mapbuilder code repository and |
|
48 |
have contributed to source code in mapbuilder/lib/* may become |
|
49 |
copyright owners. |
|
50 |
|
|
51 |
Providing a patch to the mailing list does not give someone the right to |
|
52 |
become a copyright owner (primarily because it is too hard to track). |
|
53 |
|
|
54 |
Once someone becomes a copyright owner, they do not loose this status |
|
55 |
unless they personally request to be removed from the list of copyright |
|
56 |
owners listed in this file. |
lib/spatial/mapbuilder/tests/selenium/tests/TestSuite.html | ||
---|---|---|
1 |
<html> |
|
2 |
<head> |
|
3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
4 |
<title>Test Suite</title> |
|
5 |
</head> |
|
6 |
<body> |
|
7 |
<table> |
|
8 |
<tr> |
|
9 |
<td>Test suite for the whole application</td> |
|
10 |
</tr> |
|
11 |
|
|
12 |
<tr> |
|
13 |
<td><a target="testFrame" href="examples/simple/load_page.html">Load Simple example</a></td> |
|
14 |
</tr> |
|
15 |
|
|
16 |
<tr> |
|
17 |
<td><a target="testFrame" href="examples/interactive/load_page.html">Load Basic example</a></td> |
|
18 |
</tr> |
|
19 |
<tr> |
|
20 |
<td><a target="testFrame" href="examples/interactive/no_history.html">Check empty history</a></td> |
|
21 |
</tr> |
|
22 |
<tr> |
|
23 |
<td><a target="testFrame" href="examples/interactive/drag_map.html">Drag map</a></td> |
|
24 |
</tr> |
|
25 |
<tr> |
|
26 |
<td><a target="testFrame" href="examples/interactive/zoom_map.html">Zoom map</a></td> |
|
27 |
</tr> |
|
28 |
|
|
29 |
<tr> |
|
30 |
<td><a target="testFrame" href="examples/i18n/load_page.html">Load I18n example</a></td> |
|
31 |
</tr> |
|
32 |
<tr> |
|
33 |
<td><a target="testFrame" href="examples/i18n/switch_language_nl.html">Switch language from EN to NL and back</a></td> |
|
34 |
</tr> |
|
35 |
<tr> |
|
36 |
<td><a target="testFrame" href="examples/i18n/switch_language_nonesuch.html">Switch language from EN to NL and then to unsupported language</a></td> |
|
37 |
</tr> |
|
38 |
</table> |
lib/spatial/mapbuilder/tests/selenium/tests/examples/i18n/switch_language_nl.html | ||
---|---|---|
1 |
<html> |
|
2 |
<head> |
|
3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
4 |
<title>switch_language_nl</title> |
|
5 |
</head> |
|
6 |
<body> |
|
7 |
<table cellpadding="1" cellspacing="1" border="1"> |
|
8 |
<thead> |
|
9 |
<tr><td rowspan="1" colspan="3">switch_language_nl</td></tr> |
|
10 |
</thead><tbody> |
|
11 |
<!-- Store English text, so we can use them after we switch back to english --> |
|
12 |
<tr> |
|
13 |
<td>storeAttribute</td> |
|
14 |
<td>//div[@class='mbControlBackItemInactive']@title</td> |
|
15 |
<td>mbControlBackItemInactive</td> |
|
16 |
</tr> |
|
17 |
<!-- Switch to dutch --> |
|
18 |
<tr> |
|
19 |
<td>clickAndWait</td> |
|
20 |
<td>//img[@title='Nederlands']</td> |
|
21 |
<td></td> |
|
22 |
</tr> |
|
23 |
<tr> |
|
24 |
<td>waitForElementPresent</td> |
|
25 |
<td>//div[@class='mbControlBackItemInactive']</td> |
|
26 |
<td></td> |
|
27 |
</tr> |
|
28 |
<tr> |
|
29 |
<td>storeAttribute</td> |
|
30 |
<td>//div[@class='mbControlBackItemInactive']@title</td> |
|
31 |
<td>mbControlBackItemInactiveNL</td> |
|
32 |
</tr> |
|
33 |
<!-- Switch back to english --> |
|
34 |
<tr> |
|
35 |
<td>clickAndWait</td> |
|
36 |
<td>//img[@title='English']</td> |
|
37 |
<td></td> |
|
38 |
</tr> |
|
39 |
<tr> |
|
40 |
<td>waitForElementPresent</td> |
|
41 |
<td>//div[@class='mbControlBackItemInactive']</td> |
|
42 |
<td></td> |
|
43 |
</tr> |
|
44 |
<tr> |
|
45 |
<td>assertAttribute</td> |
|
46 |
<td>//div[@class='mbControlBackItemInactive']@title</td> |
|
47 |
<td>${mbControlBackItemInactive}</td> |
|
48 |
</tr> |
|
49 |
<tr> |
|
50 |
<td>assertNotAttribute</td> |
|
51 |
<td>//div[@class='mbControlBackItemInactive']@title</td> |
|
52 |
<td>${mbControlBackItemInactiveNL}</td> |
|
53 |
</tr> |
|
54 |
|
|
55 |
</tbody></table> |
|
56 |
</body> |
|
57 |
</html> |
lib/spatial/mapbuilder/tests/selenium/tests/examples/i18n/switch_language_nonesuch.html | ||
---|---|---|
1 |
<html> |
|
2 |
<head> |
|
3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
4 |
<title>switch_language_nonesuch</title> |
|
5 |
</head> |
|
6 |
<body> |
|
7 |
<table cellpadding="1" cellspacing="1" border="1"> |
|
8 |
<thead> |
|
9 |
<tr><td rowspan="1" colspan="3">switch_language_nonesuch</td></tr> |
|
10 |
</thead><tbody> |
|
11 |
<!-- Store English text, so we can use them after we switch to unsupported language --> |
|
12 |
<tr> |
|
13 |
<td>storeAttribute</td> |
|
14 |
<td>//div[@class='mbControlBackItemInactive']@title</td> |
|
15 |
<td>mbControlBackItemInactive</td> |
|
16 |
</tr> |
|
17 |
<!-- Switch to Dutch --> |
|
18 |
<tr> |
|
19 |
<td>clickAndWait</td> |
|
20 |
<td>//img[@title='Nederlands']</td> |
|
21 |
<td></td> |
|
22 |
</tr> |
|
23 |
<tr> |
|
24 |
<td>waitForElementPresent</td> |
|
25 |
<td>//div[@class='mbControlBackItemInactive']</td> |
|
26 |
<td></td> |
|
27 |
</tr> |
|
28 |
<tr> |
|
29 |
<td>storeAttribute</td> |
|
30 |
<td>//div[@class='mbControlBackItemInactive']@title</td> |
|
31 |
<td>mbControlBackItemInactiveNL</td> |
|
32 |
</tr> |
|
33 |
<!-- Switch to unsuppported language --> |
|
34 |
<tr> |
|
35 |
<td>clickAndWait</td> |
|
36 |
<td>//img[@title='unsupported language']</td> |
|
37 |
<td></td> |
|
38 |
</tr> |
|
39 |
<tr> |
|
40 |
<td>waitForElementPresent</td> |
|
41 |
<td>//div[@class='mbControlBackItemInactive']</td> |
|
42 |
<td></td> |
|
43 |
</tr> |
|
44 |
<tr> |
|
45 |
<td>assertAttribute</td> |
|
46 |
<td>//div[@class='mbControlBackItemInactive']@title</td> |
|
47 |
<td>${mbControlBackItemInactive}</td> |
|
48 |
</tr> |
|
49 |
<tr> |
|
50 |
<td>assertNotAttribute</td> |
|
51 |
<td>//div[@class='mbControlBackItemInactive']@title</td> |
|
52 |
<td>${mbControlBackItemInactiveNL}</td> |
|
53 |
</tr> |
|
54 |
|
|
55 |
</tbody></table> |
|
56 |
</body> |
|
57 |
</html> |
lib/spatial/mapbuilder/tests/selenium/tests/examples/i18n/load_page.html | ||
---|---|---|
1 |
<html> |
|
2 |
<head> |
|
3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
4 |
<title>load_page</title> |
|
5 |
</head> |
|
6 |
<body> |
|
7 |
<table cellpadding="1" cellspacing="1" border="1"> |
|
8 |
<thead> |
|
9 |
<tr><td rowspan="1" colspan="3">load_page</td></tr> |
|
10 |
</thead><tbody> |
|
11 |
<tr> |
|
12 |
<td>open</td> |
|
13 |
<td>../../../examples/i18n/index.html</td> |
|
14 |
<td></td> |
|
15 |
</tr> |
|
16 |
<tr> |
|
17 |
<td>waitForPageToLoad</td> |
|
18 |
<td>60000</td> |
|
19 |
<td></td> |
|
20 |
</tr> |
|
21 |
<tr> |
|
22 |
<td>setTimeout</td> |
|
23 |
<td>10000</td> |
|
24 |
<td></td> |
|
25 |
</tr> |
|
26 |
<tr> |
|
27 |
<td>waitForElementPresent</td> |
|
28 |
<td>mainMapPane_OpenLayers_Container</td> |
|
29 |
<td></td> |
|
30 |
</tr> |
|
31 |
<tr> |
|
32 |
<td>pause</td> |
|
33 |
<td>1000</td> |
|
34 |
<td></td> |
|
35 |
</tr> |
|
36 |
|
|
37 |
</tbody></table> |
|
38 |
</body> |
|
39 |
</html> |
lib/spatial/mapbuilder/tests/selenium/tests/examples/simple/load_page.html | ||
---|---|---|
1 |
<html> |
|
2 |
<head> |
|
3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
4 |
<title>load_page</title> |
|
5 |
</head> |
|
6 |
<body> |
|
7 |
<table cellpadding="1" cellspacing="1" border="1"> |
|
8 |
<thead> |
|
9 |
<tr><td rowspan="1" colspan="3">load_page</td></tr> |
|
10 |
</thead><tbody> |
|
11 |
<tr> |
|
12 |
<td>open</td> |
|
13 |
<td>../../../examples/simple/index.html</td> |
|
14 |
<td></td> |
|
15 |
</tr> |
|
16 |
<tr> |
|
17 |
<td>waitForPageToLoad</td> |
|
18 |
<td>60000</td> |
|
19 |
<td></td> |
|
20 |
</tr> |
|
21 |
<tr> |
|
22 |
<td>setTimeout</td> |
|
23 |
<td>10000</td> |
|
24 |
<td></td> |
|
25 |
</tr> |
|
26 |
<tr> |
|
27 |
<td>waitForElementPresent</td> |
|
28 |
<td>mainMapPane_OpenLayers_Container</td> |
|
29 |
<td></td> |
|
30 |
</tr> |
|
31 |
<tr> |
|
32 |
<td>pause</td> |
|
33 |
<td>1000</td> |
|
34 |
<td></td> |
|
35 |
</tr> |
|
36 |
|
|
37 |
</tbody></table> |
|
38 |
</body> |
|
39 |
</html> |
lib/spatial/mapbuilder/tests/selenium/tests/examples/interactive/no_history.html | ||
---|---|---|
1 |
<html> |
|
2 |
<head> |
|
3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
4 |
<title>no_history</title> |
|
5 |
</head> |
|
6 |
<body> |
|
7 |
<table cellpadding="1" cellspacing="1" border="1"> |
|
8 |
<thead> |
|
9 |
<tr><td rowspan="1" colspan="3">no_history</td></tr> |
|
10 |
</thead><tbody> |
|
11 |
<!--Asserts that you can't go back in history before first entry--> |
|
12 |
<tr> |
|
13 |
<td>click</td> |
|
14 |
<td>//div[@class='mbControlBackItemInactive']</td> |
|
15 |
<td></td> |
|
16 |
</tr> |
|
17 |
<tr> |
|
18 |
<td>assertAlert</td> |
|
19 |
<td>You can't go further back</td> |
|
20 |
<td></td> |
|
21 |
</tr> |
|
22 |
<!--Asserts that you can't go forward in history beyond last entry--> |
|
23 |
<tr> |
|
24 |
<td>click</td> |
|
25 |
<td>//div[@class='mbControlForwardItemInactive']</td> |
|
26 |
<td></td> |
|
27 |
</tr> |
|
28 |
<tr> |
|
29 |
<td>assertAlert</td> |
|
30 |
<td>You can't go further forward</td> |
|
31 |
<td></td> |
|
32 |
</tr> |
|
33 |
|
|
34 |
</tbody></table> |
|
35 |
</body> |
|
36 |
</html> |
lib/spatial/mapbuilder/tests/selenium/tests/examples/interactive/zoom_map.html | ||
---|---|---|
1 |
<html> |
|
2 |
<head> |
|
3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
4 |
<title>zoom_map</title> |
|
5 |
</head> |
|
6 |
<body> |
|
7 |
<table cellpadding="1" cellspacing="1" border="1"> |
|
8 |
<thead> |
|
9 |
<tr><td rowspan="1" colspan="3">zoom_map</td></tr> |
|
10 |
</thead><tbody> |
|
11 |
<!-- Reset the world before we start --> |
|
12 |
<tr> |
|
13 |
<td>click</td> |
|
14 |
<td>//div[@class='olControlZoomToMaxExtentItemInactive']</td> |
|
15 |
<td></td> |
|
16 |
</tr> |
|
17 |
<!-- Store the values to assert the scale and position in each step --> |
|
18 |
<tr> |
|
19 |
<td>storeValue</td> |
|
20 |
<td>//input[@name='mapScale']</td> |
|
21 |
<td>startScale</td> |
|
22 |
</tr> |
|
23 |
<tr> |
|
24 |
<td>store</td> |
|
25 |
<td>300,150</td> |
|
26 |
<td>mouseZoomInDownPos</td> |
|
27 |
</tr> |
|
28 |
<tr> |
|
29 |
<td>store</td> |
|
30 |
<td>400,50</td> |
|
31 |
<td>mouseZoomInUpPos</td> |
|
32 |
</tr> |
|
33 |
<tr> |
|
34 |
<td>store</td> |
|
35 |
<td>200,250</td> |
|
36 |
<td>mouseZoomOutPos</td> |
|
37 |
</tr> |
|
38 |
<tr> |
|
39 |
<td>store</td> |
|
40 |
<td>0.00000</td> |
|
41 |
<td>startLongitude</td> |
|
42 |
</tr> |
|
43 |
<tr> |
|
44 |
<td>store</td> |
|
45 |
<td>0.00000</td> |
|
46 |
<td>startLatitude</td> |
|
47 |
</tr> |
|
48 |
<tr> |
|
49 |
<td>store</td> |
|
50 |
<td>30.00000</td> |
|
51 |
<td>stopLongitude</td> |
|
52 |
</tr> |
|
53 |
<tr> |
|
54 |
<td>store</td> |
|
55 |
<td>30.00000</td> |
|
56 |
<td>stopLatitude</td> |
|
57 |
</tr> |
|
58 |
<tr> |
|
59 |
<td>store</td> |
|
60 |
<td>10.00000</td> |
|
61 |
<td>finalLongitude</td> |
|
62 |
</tr> |
|
63 |
<tr> |
|
64 |
<td>store</td> |
|
65 |
<td>10.00000</td> |
|
66 |
<td>finalLatitude</td> |
|
67 |
</tr> |
|
68 |
<!-- Activate mousemove so we can get the value's after the mouse(down/up) actions --> |
|
69 |
<tr> |
|
70 |
<td>mouseMoveAt</td> |
|
71 |
<td>//div[@id='mainMapPane']</td> |
|
72 |
<td>${mouseZoomInDownPos}</td> |
|
73 |
</tr> |
|
74 |
<tr> |
|
75 |
<td>waitForValue</td> |
|
76 |
<td>//input[@name='longitude']</td> |
|
77 |
<td>regexp:^.+$</td> |
|
78 |
</tr> |
|
79 |
<tr> |
|
80 |
<td>assertValue</td> |
|
81 |
<td>//input[@name='longitude']</td> |
|
82 |
<td>${startLongitude}</td> |
|
83 |
</tr> |
|
84 |
<tr> |
|
85 |
<td>assertValue</td> |
|
86 |
<td>//input[@name='latitude']</td> |
|
87 |
<td>${startLatitude}</td> |
|
88 |
</tr> |
|
89 |
<!-- Select zoom in and zoom in on the map --> |
|
90 |
<tr> |
|
91 |
<td>waitForElementPresent</td> |
|
92 |
<td>//div[@id='mainMapPane_OpenLayers_Container']</td> |
|
93 |
<td></td> |
|
94 |
</tr> |
|
95 |
<tr> |
|
96 |
<td>click</td> |
|
97 |
<td>//div[@class='olControlZoomBoxItemInactive']</td> |
|
98 |
<td></td> |
|
99 |
</tr> |
|
100 |
<tr> |
|
101 |
<td>mouseDownAt</td> |
|
102 |
<td>//div[@id='mainMapPane']</td> |
|
103 |
<td>${mouseZoomInDownPos}</td> |
|
104 |
</tr> |
|
105 |
<tr> |
|
106 |
<td>mouseUpAt</td> |
|
107 |
<td>//div[@id='mainMapPane']</td> |
|
108 |
<td>${mouseZoomInUpPos}</td> |
|
109 |
</tr> |
|
110 |
<tr> |
|
111 |
<td>mouseMoveAt</td> |
|
112 |
<td>//div[@id='mainMapPane']</td> |
|
113 |
<td>${mouseZoomInDownPos}</td> |
|
114 |
</tr> |
|
115 |
<tr> |
|
116 |
<td>waitForValue</td> |
|
117 |
<td>//input[@name='longitude']</td> |
|
118 |
<td>regexp:^.+$</td> |
|
119 |
</tr> |
|
120 |
<tr> |
|
121 |
<td>assertValue</td> |
|
122 |
<td>//input[@name='longitude']</td> |
|
123 |
<td>${stopLongitude}</td> |
|
124 |
</tr> |
|
125 |
<tr> |
|
126 |
<td>assertValue</td> |
|
127 |
<td>//input[@name='latitude']</td> |
|
128 |
<td>${stopLatitude}</td> |
|
129 |
</tr> |
|
130 |
<tr> |
|
131 |
<td>waitForElementPresent</td> |
|
132 |
<td>//div[@id='mainMapPane_OpenLayers_Container']</td> |
|
133 |
<td></td> |
|
134 |
</tr> |
|
135 |
<tr> |
|
136 |
<td>assertNotValue</td> |
|
137 |
<td>//input[@name='mapScale']</td> |
|
138 |
<td>${startScale}</td> |
|
139 |
</tr> |
|
140 |
<!-- Select zoom out and zoom out on the map --> |
|
141 |
<tr> |
|
142 |
<td>waitForElementPresent</td> |
|
143 |
<td>//div[@id='mainMapPane_OpenLayers_Container']</td> |
|
144 |
<td></td> |
|
145 |
</tr> |
|
146 |
<tr> |
|
147 |
<td>click</td> |
|
148 |
<td>//div[@class='mbControlZoomOutItemInactive']</td> |
|
149 |
<td></td> |
|
150 |
</tr> |
|
151 |
<tr> |
|
152 |
<td>mouseDownAt</td> |
|
153 |
<td>//div[@id='mainMapPane']</td> |
|
154 |
<td>${mouseZoomOutPos}</td> |
|
155 |
</tr> |
|
156 |
<tr> |
|
157 |
<td>mouseUpAt</td> |
|
158 |
<td>//div[@id='mainMapPane']</td> |
|
159 |
<td>${mouseZoomOutPos}</td> |
|
160 |
</tr> |
|
161 |
<tr> |
|
162 |
<td>mouseMoveAt</td> |
|
163 |
<td>//div[@id='mainMapPane']</td> |
|
164 |
<td>${mouseZoomInDownPos}</td> |
|
165 |
</tr> |
|
166 |
<tr> |
|
167 |
<td>waitForValue</td> |
|
168 |
<td>//input[@name='longitude']</td> |
|
169 |
<td>regexp:^.+$</td> |
|
170 |
</tr> |
|
171 |
<tr> |
|
172 |
<td>assertValue</td> |
|
173 |
<td>//input[@name='longitude']</td> |
|
174 |
<td>${finalLongitude}</td> |
|
175 |
</tr> |
|
176 |
<tr> |
|
177 |
<td>assertValue</td> |
|
178 |
<td>//input[@name='latitude']</td> |
|
179 |
<td>${finalLatitude}</td> |
|
180 |
</tr> |
|
181 |
<tr> |
|
182 |
<td>waitForElementPresent</td> |
|
183 |
<td>//div[@id='mainMapPane_OpenLayers_Container']</td> |
|
184 |
<td></td> |
|
185 |
</tr> |
|
186 |
|
|
187 |
</tbody></table> |
|
188 |
</body> |
|
189 |
</html> |
lib/spatial/mapbuilder/tests/selenium/tests/examples/interactive/drag_map.html | ||
---|---|---|
1 |
<html> |
|
2 |
<head> |
|
3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
4 |
<title>drag_map</title> |
|
5 |
</head> |
|
6 |
<body> |
|
7 |
<table cellpadding="1" cellspacing="1" border="1"> |
|
8 |
<thead> |
|
9 |
<tr><td rowspan="1" colspan="3">drag_map</td></tr> |
|
10 |
</thead><tbody> |
|
11 |
<!-- Reset the world before we start --> |
|
12 |
<tr> |
|
13 |
<td>click</td> |
|
14 |
<td>//div[@class='olControlZoomToMaxExtentItemInactive']</td> |
|
15 |
<td></td> |
|
16 |
</tr> |
|
17 |
<!-- Store the values to assert the scale and position in each step --> |
|
18 |
<tr> |
|
19 |
<td>storeValue</td> |
|
20 |
<td>//input[@name='mapScale']</td> |
|
21 |
<td>startScale</td> |
|
22 |
</tr> |
|
23 |
<tr> |
|
24 |
<td>store</td> |
|
25 |
<td>300,150</td> |
|
26 |
<td>mouseDownPos</td> |
|
27 |
</tr> |
|
28 |
<tr> |
|
29 |
<td>store</td> |
|
30 |
<td>400,50</td> |
|
31 |
<td>mouseUpPos</td> |
|
32 |
</tr> |
|
33 |
<tr> |
|
34 |
<td>store</td> |
|
35 |
<td>0.00000</td> |
|
36 |
<td>startLongitude</td> |
|
37 |
</tr> |
|
38 |
<tr> |
|
39 |
<td>store</td> |
|
40 |
<td>0.00000</td> |
|
41 |
<td>startLatitude</td> |
|
42 |
</tr> |
|
43 |
<tr> |
|
44 |
<td>store</td> |
|
45 |
<td>0.00000</td> |
|
46 |
<td>stopLongitude</td> |
|
47 |
</tr> |
|
48 |
<tr> |
|
49 |
<td>store</td> |
|
50 |
<td>0.00000</td> |
|
51 |
<td>stopLatitude</td> |
|
52 |
</tr> |
|
53 |
<!-- Activate mousemove so we can get the value's after the mouse(down/up) actions --> |
|
54 |
<tr> |
|
55 |
<td>mouseMoveAt</td> |
|
56 |
<td>//div[@id='mainMapPane']</td> |
|
57 |
<td>${mouseDownPos}</td> |
|
58 |
</tr> |
|
59 |
<tr> |
|
60 |
<td>waitForValue</td> |
|
61 |
<td>//input[@name='longitude']</td> |
|
62 |
<td>regexp:^.+$</td> |
|
63 |
</tr> |
|
64 |
<tr> |
|
65 |
<td>assertValue</td> |
|
66 |
<td>//input[@name='longitude']</td> |
|
67 |
<td>${startLongitude}</td> |
|
68 |
</tr> |
|
69 |
<tr> |
|
70 |
<td>assertValue</td> |
|
71 |
<td>//input[@name='latitude']</td> |
|
72 |
<td>${startLatitude}</td> |
|
73 |
</tr> |
|
74 |
<!-- Select drag and pan and drag the map --> |
|
75 |
<tr> |
|
76 |
<td>waitForElementPresent</td> |
|
77 |
<td>//div[@id='mainMapPane_OpenLayers_Container']</td> |
|
78 |
<td></td> |
|
79 |
</tr> |
|
80 |
<tr> |
|
81 |
<td>click</td> |
|
82 |
<td>//div[@class='olControlDragPanItemInactive']</td> |
|
83 |
<td></td> |
|
84 |
</tr> |
|
85 |
<tr> |
|
86 |
<td>mouseDownAt</td> |
|
87 |
<td>//div[@id='mainMapPane']</td> |
|
88 |
<td>${mouseDownPos}</td> |
|
89 |
</tr> |
|
90 |
<tr> |
|
91 |
<td>mouseUpAt</td> |
|
92 |
<td>//div[@id='mainMapPane']</td> |
|
93 |
<td>${mouseUpPos}</td> |
|
94 |
</tr> |
|
95 |
<tr> |
|
96 |
<td>mouseMoveAt</td> |
|
97 |
<td>//div[@id='mainMapPane']</td> |
|
98 |
<td>${mouseDownPos}</td> |
|
99 |
</tr> |
|
100 |
<tr> |
|
101 |
<td>waitForValue</td> |
|
102 |
<td>//input[@name='longitude']</td> |
|
103 |
<td>regexp:^.+$</td> |
|
104 |
</tr> |
|
105 |
<tr> |
|
106 |
<td>assertValue</td> |
|
107 |
<td>//input[@name='longitude']</td> |
|
108 |
<td>${stopLongitude}</td> |
|
109 |
</tr> |
|
110 |
<tr> |
|
111 |
<td>assertValue</td> |
|
112 |
<td>//input[@name='latitude']</td> |
|
113 |
<td>${stopLatitude}</td> |
|
114 |
</tr> |
|
115 |
<tr> |
|
116 |
<td>waitForElementPresent</td> |
|
117 |
<td>//div[@id='mainMapPane_OpenLayers_Container']</td> |
|
118 |
<td></td> |
|
119 |
</tr> |
|
120 |
<tr> |
|
121 |
<td>assertValue</td> |
|
122 |
<td>//input[@name='mapScale']</td> |
|
123 |
<td>${startScale}</td> |
|
124 |
</tr> |
|
125 |
|
|
126 |
</tbody></table> |
|
127 |
</body> |
|
128 |
</html> |
lib/spatial/mapbuilder/tests/selenium/selenium-core-0.8.2/scripts/se2html.js | ||
---|---|---|
1 |
/* |
|
2 |
|
|
3 |
This is an experiment in creating a "selenese" parser that drastically |
|
4 |
cuts down on the line noise associated with writing tests in HTML. |
|
5 |
|
|
6 |
The 'parse' function will accept the follow sample commands. |
|
7 |
|
|
8 |
test-cases: |
|
9 |
//comment |
|
10 |
command "param" |
|
11 |
command "param" // comment |
|
12 |
command "param" "param2" |
|
13 |
command "param" "param2" // this is a comment |
|
14 |
|
|
15 |
TODO: |
|
16 |
1) Deal with multiline parameters |
|
17 |
2) Escape quotes properly |
|
18 |
3) Determine whether this should/will become the "preferred" syntax |
|
19 |
for delivered Selenium self-test scripts |
|
20 |
*/ |
|
21 |
|
|
22 |
|
|
23 |
function separse(doc) { |
|
24 |
// Get object |
|
25 |
script = doc.getElementById('testcase') |
|
26 |
// Split into lines |
|
27 |
lines = script.text.split('\n'); |
|
28 |
|
|
29 |
|
|
30 |
var command_pattern = / *(\w+) *"([^"]*)" *(?:"([^"]*)"){0,1}(?: *(\/\/ *.+))*/i; |
|
31 |
var comment_pattern = /^ *(\/\/ *.+)/ |
|
32 |
|
|
33 |
// Regex each line into selenium command and convert into table row. |
|
34 |
// eg. "<command> <quote> <quote> <comment>" |
|
35 |
var new_test_source = ''; |
|
36 |
var new_line = ''; |
|
37 |
for (var x=0; x < lines.length; x++) { |
|
38 |
result = lines[x].match(command_pattern); |
|
39 |
if (result != null) { |
|
40 |
new_line = "<tr><td>" + (result[1] || ' ') + "</td>" + |
|
41 |
"<td>" + (result[2] || ' ') + "</td>" + |
|
42 |
"<td>" + (result[3] || ' ') + "</td>" + |
|
43 |
"<td>" + (result[4] || ' ') + "</td></tr>\n"; |
|
44 |
new_test_source += new_line; |
|
45 |
} |
|
46 |
result = lines[x].match(comment_pattern); |
|
47 |
if (result != null) { |
|
48 |
new_line = '<tr><td rowspan="1" colspan="4">' + |
|
49 |
(result[1] || ' ') + |
|
50 |
'</td></tr>'; |
|
51 |
new_test_source += new_line; |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
55 |
// Create HTML Table |
|
56 |
body = doc.body |
|
57 |
body.innerHTML += "<table class='selenium' id='testtable'>"+ |
|
58 |
new_test_source + |
|
59 |
"</table>"; |
|
60 |
|
|
61 |
} |
|
62 |
|
|
63 |
|
lib/spatial/mapbuilder/tests/selenium/selenium-core-0.8.2/scripts/selenium-browserdetect.js | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright 2004 ThoughtWorks, Inc |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
* |
|
16 |
*/ |
|
17 |
|
|
18 |
// Although it's generally better web development practice not to use |
|
19 |
// browser-detection (feature detection is better), the subtle browser |
|
20 |
// differences that Selenium has to work around seem to make it |
|
21 |
// necessary. Maybe as we learn more about what we need, we can do this in |
|
22 |
// a more "feature-centric" rather than "browser-centric" way. |
|
23 |
|
|
24 |
var BrowserVersion = function() { |
|
25 |
this.name = navigator.appName; |
|
26 |
|
|
27 |
if (window.opera != null) { |
|
28 |
this.browser = BrowserVersion.OPERA; |
|
29 |
this.isOpera = true; |
|
30 |
return; |
|
31 |
} |
|
32 |
|
|
33 |
var _getQueryParameter = function(searchKey) { |
|
34 |
var str = location.search.substr(1); |
|
35 |
if (str == null) return null; |
|
36 |
var clauses = str.split('&'); |
|
37 |
for (var i = 0; i < clauses.length; i++) { |
|
38 |
var keyValuePair = clauses[i].split('=', 2); |
|
39 |
var key = unescape(keyValuePair[0]); |
|
40 |
if (key == searchKey) { |
|
41 |
return unescape(keyValuePair[1]); |
|
42 |
} |
|
43 |
} |
|
44 |
return null; |
|
45 |
}; |
|
46 |
|
|
47 |
var self = this; |
|
48 |
|
|
49 |
var checkChrome = function() { |
|
50 |
var loc = window.document.location.href; |
|
51 |
try { |
|
52 |
loc = window.top.document.location.href; |
|
53 |
if (/^chrome:\/\//.test(loc)) { |
|
54 |
self.isChrome = true; |
|
55 |
} else { |
|
56 |
self.isChrome = false; |
|
57 |
} |
|
58 |
} catch (e) { |
|
59 |
// can't see the top (that means we might be chrome, but it's impossible to be sure) |
|
60 |
self.isChromeDetectable = "no, top location couldn't be read in this window"; |
|
61 |
if (_getQueryParameter('thisIsChrome')) { |
|
62 |
self.isChrome = true; |
|
63 |
} else { |
|
64 |
self.isChrome = false; |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
|
|
69 |
} |
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
if (this.name == "Microsoft Internet Explorer") { |
|
74 |
this.browser = BrowserVersion.IE; |
|
75 |
this.isIE = true; |
|
76 |
try { |
|
77 |
if (window.top.SeleniumHTARunner && window.top.document.location.pathname.match(/.hta$/i)) { |
|
78 |
this.isHTA = true; |
|
79 |
} |
|
80 |
} catch (e) { |
|
81 |
this.isHTADetectable = "no, top location couldn't be read in this window"; |
|
82 |
if (_getQueryParameter('thisIsHTA')) { |
|
83 |
self.isHTA = true; |
|
84 |
} else { |
|
85 |
self.isHTA = false; |
|
86 |
} |
|
87 |
} |
|
88 |
if ("0" == navigator.appMinorVersion) { |
|
89 |
this.preSV1 = true; |
|
90 |
if (navigator.appVersion.match(/MSIE 6.0/)) { |
|
91 |
this.appearsToBeBrokenInitialIE6 = true; |
|
92 |
} |
|
93 |
} |
|
94 |
return; |
|
95 |
} |
|
96 |
|
|
97 |
if (navigator.userAgent.indexOf('Safari') != -1) { |
|
98 |
this.browser = BrowserVersion.SAFARI; |
|
99 |
this.isSafari = true; |
|
100 |
this.khtml = true; |
|
101 |
return; |
|
102 |
} |
|
103 |
|
|
104 |
if (navigator.userAgent.indexOf('Konqueror') != -1) { |
|
105 |
this.browser = BrowserVersion.KONQUEROR; |
|
106 |
this.isKonqueror = true; |
|
107 |
this.khtml = true; |
|
108 |
return; |
|
109 |
} |
|
110 |
|
|
111 |
if (navigator.userAgent.indexOf('Firefox') != -1) { |
|
112 |
this.browser = BrowserVersion.FIREFOX; |
|
113 |
this.isFirefox = true; |
|
114 |
this.isGecko = true; |
|
115 |
var result = /.*Firefox\/([\d\.]+).*/.exec(navigator.userAgent); |
|
116 |
if (result) { |
|
117 |
this.firefoxVersion = result[1]; |
|
118 |
} |
|
119 |
checkChrome(); |
|
120 |
return; |
|
121 |
} |
|
122 |
|
|
123 |
if (navigator.userAgent.indexOf('Gecko') != -1) { |
|
124 |
this.browser = BrowserVersion.MOZILLA; |
|
125 |
this.isMozilla = true; |
|
126 |
this.isGecko = true; |
|
127 |
checkChrome(); |
|
128 |
return; |
|
129 |
} |
|
130 |
|
|
131 |
this.browser = BrowserVersion.UNKNOWN; |
|
132 |
} |
|
133 |
|
|
134 |
BrowserVersion.OPERA = "Opera"; |
|
135 |
BrowserVersion.IE = "IE"; |
|
136 |
BrowserVersion.KONQUEROR = "Konqueror"; |
|
137 |
BrowserVersion.SAFARI = "Safari"; |
|
138 |
BrowserVersion.FIREFOX = "Firefox"; |
|
139 |
BrowserVersion.MOZILLA = "Mozilla"; |
|
140 |
BrowserVersion.UNKNOWN = "Unknown"; |
|
141 |
|
|
142 |
var browserVersion = new BrowserVersion(); |
lib/spatial/mapbuilder/tests/selenium/selenium-core-0.8.2/scripts/injection_iframe.html | ||
---|---|---|
1 |
<script language="JavaScript"> |
|
2 |
// Ideally I would avoid polluting the namespace by enclosing this snippet with |
|
3 |
// curly braces, but I want to make it easy to look at what URL I used for anyone |
|
4 |
// who is interested in looking into http://jira.openqa.org/browse/SRC-101: |
|
5 |
var _sel_url_ = "http://" + location.host + "/selenium-server/core/scripts/injection.html"; |
|
6 |
document.write('<iframe name="selenium" width=0 height=0 id="selenium" src="' + _sel_url_ + '"></iframe>'); |
|
7 |
</script> |
lib/spatial/mapbuilder/tests/selenium/selenium-core-0.8.2/Blank.html | ||
---|---|---|
1 |
<html> |
|
2 |
<head> |
|
3 |
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> |
|
4 |
</head> |
|
5 |
<body> |
|
6 |
<h3>selenium-rc initial page</h3> |
|
7 |
</body> |
|
8 |
</html> |
lib/spatial/mapbuilder/tests/selenium/selenium-core-0.8.2/scripts/narcissus-parse.js | ||
---|---|---|
1 |
/* ***** BEGIN LICENSE BLOCK ***** |
|
2 |
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
|
3 |
* |
|
4 |
* The contents of this file are subject to the Mozilla Public License Version |
|
5 |
* 1.1 (the "License"); you may not use this file except in compliance with |
|
6 |
* the License. You may obtain a copy of the License at |
|
7 |
* http://www.mozilla.org/MPL/ |
|
8 |
* |
|
9 |
* Software distributed under the License is distributed on an "AS IS" basis, |
|
10 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
|
11 |
* for the specific language governing rights and limitations under the |
|
12 |
* License. |
|
13 |
* |
|
14 |
* The Original Code is the Narcissus JavaScript engine. |
|
15 |
* |
|
16 |
* The Initial Developer of the Original Code is |
|
17 |
* Brendan Eich <brendan@mozilla.org>. |
|
18 |
* Portions created by the Initial Developer are Copyright (C) 2004 |
|
19 |
* the Initial Developer. All Rights Reserved. |
|
20 |
* |
|
21 |
* Contributor(s): Richard Hundt <www.plextk.org> |
|
22 |
* |
|
23 |
* Alternatively, the contents of this file may be used under the terms of |
|
24 |
* either the GNU General Public License Version 2 or later (the "GPL"), or |
|
25 |
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
|
26 |
* in which case the provisions of the GPL or the LGPL are applicable instead |
|
27 |
* of those above. If you wish to allow use of your version of this file only |
|
28 |
* under the terms of either the GPL or the LGPL, and not to allow others to |
|
29 |
* use your version of this file under the terms of the MPL, indicate your |
|
30 |
* decision by deleting the provisions above and replace them with the notice |
|
31 |
* and other provisions required by the GPL or the LGPL. If you do not delete |
|
32 |
* the provisions above, a recipient may use your version of this file under |
|
33 |
* the terms of any one of the MPL, the GPL or the LGPL. |
|
34 |
* |
|
35 |
* ***** END LICENSE BLOCK ***** */ |
|
36 |
|
|
37 |
/* |
|
38 |
* Narcissus - JS implemented in JS. |
|
39 |
* |
|
40 |
* Lexical scanner and parser. |
|
41 |
*/ |
|
42 |
|
|
43 |
// jrh |
|
44 |
//module('JS.Parse'); |
|
45 |
|
|
46 |
// Build a regexp that recognizes operators and punctuators (except newline). |
|
47 |
var opRegExp = |
|
48 |
/^;|^,|^\?|^:|^\|\||^\&\&|^\||^\^|^\&|^===|^==|^=|^!==|^!=|^<<|^<=|^<|^>>>|^>>|^>=|^>|^\+\+|^\-\-|^\+|^\-|^\*|^\/|^%|^!|^~|^\.|^\[|^\]|^\{|^\}|^\(|^\)/; |
|
49 |
|
|
50 |
// A regexp to match floating point literals (but not integer literals). |
|
51 |
var fpRegExp = /^\d+\.\d*(?:[eE][-+]?\d+)?|^\d+(?:\.\d*)?[eE][-+]?\d+|^\.\d+(?:[eE][-+]?\d+)?/; |
|
52 |
|
|
53 |
function Tokenizer(s, f, l) { |
|
54 |
this.cursor = 0; |
|
55 |
this.source = String(s); |
|
56 |
this.tokens = []; |
|
57 |
this.tokenIndex = 0; |
|
58 |
this.lookahead = 0; |
|
59 |
this.scanNewlines = false; |
|
60 |
this.scanOperand = true; |
|
61 |
this.filename = f || ""; |
|
62 |
this.lineno = l || 1; |
|
63 |
} |
|
64 |
|
|
65 |
Tokenizer.prototype = { |
|
66 |
input : function() { |
|
67 |
return this.source.substring(this.cursor); |
|
68 |
}, |
|
69 |
|
|
70 |
done : function() { |
|
71 |
return this.peek() == END; |
|
72 |
}, |
|
73 |
|
|
74 |
token : function() { |
|
75 |
return this.tokens[this.tokenIndex]; |
|
76 |
}, |
|
77 |
|
|
78 |
match: function (tt) { |
|
79 |
return this.get() == tt || this.unget(); |
|
80 |
}, |
|
81 |
|
|
82 |
mustMatch: function (tt) { |
|
83 |
if (!this.match(tt)) |
|
84 |
throw this.newSyntaxError("Missing " + this.tokens[tt].toLowerCase()); |
|
85 |
return this.token(); |
|
86 |
}, |
|
87 |
|
|
88 |
peek: function () { |
|
89 |
var tt; |
|
90 |
if (this.lookahead) { |
|
91 |
tt = this.tokens[(this.tokenIndex + this.lookahead) & 3].type; |
|
92 |
} else { |
|
93 |
tt = this.get(); |
|
94 |
this.unget(); |
|
95 |
} |
|
96 |
return tt; |
|
97 |
}, |
|
98 |
|
|
99 |
peekOnSameLine: function () { |
|
100 |
this.scanNewlines = true; |
|
101 |
var tt = this.peek(); |
|
102 |
this.scanNewlines = false; |
|
103 |
return tt; |
|
104 |
}, |
|
105 |
|
|
106 |
get: function () { |
|
107 |
var token; |
|
108 |
while (this.lookahead) { |
|
109 |
--this.lookahead; |
|
110 |
this.tokenIndex = (this.tokenIndex + 1) & 3; |
|
111 |
token = this.tokens[this.tokenIndex]; |
|
112 |
if (token.type != NEWLINE || this.scanNewlines) |
|
113 |
return token.type; |
|
114 |
} |
|
115 |
|
|
116 |
for (;;) { |
|
117 |
var input = this.input(); |
|
118 |
var rx = this.scanNewlines ? /^[ \t]+/ : /^\s+/; |
|
119 |
var match = input.match(rx); |
|
120 |
if (match) { |
|
121 |
var spaces = match[0]; |
|
122 |
this.cursor += spaces.length; |
|
123 |
var newlines = spaces.match(/\n/g); |
|
124 |
if (newlines) |
|
125 |
this.lineno += newlines.length; |
|
126 |
input = this.input(); |
|
127 |
} |
|
128 |
|
|
129 |
if (!(match = input.match(/^\/(?:\*(?:.|\n)*?\*\/|\/.*)/))) |
|
130 |
break; |
|
131 |
var comment = match[0]; |
|
132 |
this.cursor += comment.length; |
|
133 |
newlines = comment.match(/\n/g); |
|
134 |
if (newlines) |
|
135 |
this.lineno += newlines.length |
|
136 |
} |
|
137 |
|
|
138 |
this.tokenIndex = (this.tokenIndex + 1) & 3; |
|
139 |
token = this.tokens[this.tokenIndex]; |
|
140 |
if (!token) |
|
141 |
this.tokens[this.tokenIndex] = token = {}; |
|
142 |
if (!input) |
|
143 |
return token.type = END; |
|
144 |
if ((match = input.match(fpRegExp))) { |
|
145 |
token.type = NUMBER; |
|
146 |
token.value = parseFloat(match[0]); |
|
147 |
} else if ((match = input.match(/^0[xX][\da-fA-F]+|^0[0-7]*|^\d+/))) { |
|
148 |
token.type = NUMBER; |
|
149 |
token.value = parseInt(match[0]); |
|
150 |
} else if ((match = input.match(/^((\$\w*)|(\w+))/))) { |
|
151 |
var id = match[0]; |
|
152 |
token.type = keywords[id] || IDENTIFIER; |
|
153 |
token.value = id; |
|
154 |
} else if ((match = input.match(/^"(?:\\.|[^"])*"|^'(?:[^']|\\.)*'/))) { |
|
155 |
token.type = STRING; |
|
156 |
token.value = eval(match[0]); |
|
157 |
} else if (this.scanOperand && |
|
158 |
(match = input.match(/^\/((?:\\.|[^\/])+)\/([gi]*)/))) { |
|
159 |
token.type = REGEXP; |
|
160 |
token.value = new RegExp(match[1], match[2]); |
|
161 |
} else if ((match = input.match(opRegExp))) { |
|
162 |
var op = match[0]; |
|
163 |
if (assignOps[op] && input[op.length] == '=') { |
|
164 |
token.type = ASSIGN; |
|
165 |
token.assignOp = GLOBAL[opTypeNames[op]]; |
|
166 |
match[0] += '='; |
|
167 |
} else { |
|
168 |
token.type = GLOBAL[opTypeNames[op]]; |
|
169 |
if (this.scanOperand && |
|
170 |
(token.type == PLUS || token.type == MINUS)) { |
|
171 |
token.type += UNARY_PLUS - PLUS; |
|
172 |
} |
|
173 |
token.assignOp = null; |
|
174 |
} |
|
175 |
//debug('token.value => '+op+', token.type => '+token.type); |
|
176 |
token.value = op; |
|
177 |
} else { |
|
178 |
throw this.newSyntaxError("Illegal token"); |
|
179 |
} |
|
180 |
|
|
181 |
token.start = this.cursor; |
|
182 |
this.cursor += match[0].length; |
|
183 |
token.end = this.cursor; |
|
184 |
token.lineno = this.lineno; |
|
185 |
return token.type; |
|
186 |
}, |
|
187 |
|
|
188 |
unget: function () { |
|
189 |
if (++this.lookahead == 4) throw "PANIC: too much lookahead!"; |
|
190 |
this.tokenIndex = (this.tokenIndex - 1) & 3; |
|
191 |
}, |
|
192 |
|
|
193 |
newSyntaxError: function (m) { |
|
194 |
var e = new SyntaxError(m, this.filename, this.lineno); |
|
195 |
e.source = this.source; |
|
196 |
e.cursor = this.cursor; |
|
197 |
return e; |
|
198 |
} |
|
199 |
}; |
|
200 |
|
|
201 |
function CompilerContext(inFunction) { |
|
202 |
this.inFunction = inFunction; |
|
203 |
this.stmtStack = []; |
|
204 |
this.funDecls = []; |
|
205 |
this.varDecls = []; |
|
206 |
} |
|
207 |
|
|
208 |
var CCp = CompilerContext.prototype; |
|
209 |
CCp.bracketLevel = CCp.curlyLevel = CCp.parenLevel = CCp.hookLevel = 0; |
|
210 |
CCp.ecmaStrictMode = CCp.inForLoopInit = false; |
|
211 |
|
|
212 |
function Script(t, x) { |
|
213 |
var n = Statements(t, x); |
|
214 |
n.type = SCRIPT; |
|
215 |
n.funDecls = x.funDecls; |
|
216 |
n.varDecls = x.varDecls; |
|
217 |
return n; |
|
218 |
} |
|
219 |
|
|
220 |
// Node extends Array, which we extend slightly with a top-of-stack method. |
|
221 |
Array.prototype.top = function() { |
|
222 |
return this.length && this[this.length-1]; |
|
223 |
} |
|
224 |
|
|
225 |
function NarcNode(t, type) { |
|
226 |
var token = t.token(); |
|
227 |
if (token) { |
|
228 |
this.type = type || token.type; |
|
229 |
this.value = token.value; |
|
230 |
this.lineno = token.lineno; |
|
231 |
this.start = token.start; |
|
232 |
this.end = token.end; |
|
233 |
} else { |
|
234 |
this.type = type; |
|
235 |
this.lineno = t.lineno; |
|
236 |
} |
|
237 |
this.tokenizer = t; |
|
238 |
for (var i = 2; i < arguments.length; i++) |
|
239 |
this.push(arguments[i]); |
|
240 |
} |
|
241 |
|
|
242 |
var Np = NarcNode.prototype = new Array(); |
|
243 |
Np.constructor = NarcNode; |
|
244 |
Np.$length = 0; |
|
245 |
Np.toSource = Object.prototype.toSource; |
|
246 |
|
|
247 |
// Always use push to add operands to an expression, to update start and end. |
|
248 |
Np.push = function (kid) { |
|
249 |
if (kid.start < this.start) |
|
250 |
this.start = kid.start; |
|
251 |
if (this.end < kid.end) |
|
252 |
this.end = kid.end; |
|
253 |
//debug('length before => '+this.$length); |
|
254 |
this[this.$length] = kid; |
|
255 |
this.$length++; |
|
256 |
//debug('length after => '+this.$length); |
|
257 |
} |
|
258 |
|
|
259 |
NarcNode.indentLevel = 0; |
|
260 |
|
|
261 |
function tokenstr(tt) { |
|
262 |
var t = tokens[tt]; |
|
263 |
return /^\W/.test(t) ? opTypeNames[t] : t.toUpperCase(); |
|
264 |
} |
|
265 |
|
|
266 |
Np.toString = function () { |
|
267 |
var a = []; |
|
268 |
for (var i in this) { |
|
269 |
if (this.hasOwnProperty(i) && i != 'type') |
|
270 |
a.push({id: i, value: this[i]}); |
|
271 |
} |
|
272 |
a.sort(function (a,b) { return (a.id < b.id) ? -1 : 1; }); |
|
273 |
INDENTATION = " "; |
|
274 |
var n = ++NarcNode.indentLevel; |
|
275 |
var s = "{\n" + INDENTATION.repeat(n) + "type: " + tokenstr(this.type); |
|
276 |
for (i = 0; i < a.length; i++) |
|
277 |
s += ",\n" + INDENTATION.repeat(n) + a[i].id + ": " + a[i].value; |
|
278 |
n = --NarcNode.indentLevel; |
|
279 |
s += "\n" + INDENTATION.repeat(n) + "}"; |
|
280 |
return s; |
|
281 |
} |
|
282 |
|
|
283 |
Np.getSource = function () { |
|
284 |
return this.tokenizer.source.slice(this.start, this.end); |
|
285 |
}; |
|
286 |
|
|
287 |
Np.filename = function () { return this.tokenizer.filename; }; |
|
288 |
|
|
289 |
String.prototype.repeat = function (n) { |
|
290 |
var s = "", t = this + s; |
|
291 |
while (--n >= 0) |
|
292 |
s += t; |
|
293 |
return s; |
|
294 |
} |
|
295 |
|
|
296 |
// Statement stack and nested statement handler. |
|
297 |
function nest(t, x, node, func, end) { |
|
298 |
x.stmtStack.push(node); |
|
299 |
var n = func(t, x); |
|
300 |
x.stmtStack.pop(); |
|
301 |
end && t.mustMatch(end); |
|
302 |
return n; |
|
303 |
} |
|
304 |
|
|
305 |
function Statements(t, x) { |
|
306 |
var n = new NarcNode(t, BLOCK); |
|
307 |
x.stmtStack.push(n); |
|
308 |
while (!t.done() && t.peek() != RIGHT_CURLY) |
|
309 |
n.push(Statement(t, x)); |
|
310 |
x.stmtStack.pop(); |
|
311 |
return n; |
|
312 |
} |
|
313 |
|
|
314 |
function Block(t, x) { |
|
315 |
t.mustMatch(LEFT_CURLY); |
|
316 |
var n = Statements(t, x); |
|
317 |
t.mustMatch(RIGHT_CURLY); |
|
318 |
return n; |
|
319 |
} |
|
320 |
|
|
321 |
DECLARED_FORM = 0; EXPRESSED_FORM = 1; STATEMENT_FORM = 2; |
|
322 |
|
|
323 |
function Statement(t, x) { |
|
324 |
var i, label, n, n2, ss, tt = t.get(); |
|
325 |
|
|
326 |
// Cases for statements ending in a right curly return early, avoiding the |
|
327 |
// common semicolon insertion magic after this switch. |
|
328 |
switch (tt) { |
|
329 |
case FUNCTION: |
|
330 |
return FunctionDefinition(t, x, true, |
|
331 |
(x.stmtStack.length > 1) |
|
332 |
? STATEMENT_FORM |
|
333 |
: DECLARED_FORM); |
|
334 |
|
|
335 |
case LEFT_CURLY: |
|
336 |
n = Statements(t, x); |
|
337 |
t.mustMatch(RIGHT_CURLY); |
|
338 |
return n; |
|
339 |
|
|
340 |
case IF: |
|
341 |
n = new NarcNode(t); |
|
342 |
n.condition = ParenExpression(t, x); |
|
343 |
x.stmtStack.push(n); |
|
344 |
n.thenPart = Statement(t, x); |
|
345 |
n.elsePart = t.match(ELSE) ? Statement(t, x) : null; |
|
346 |
x.stmtStack.pop(); |
|
347 |
return n; |
|
348 |
|
|
349 |
case SWITCH: |
|
350 |
n = new NarcNode(t); |
|
351 |
t.mustMatch(LEFT_PAREN); |
|
352 |
n.discriminant = Expression(t, x); |
|
353 |
t.mustMatch(RIGHT_PAREN); |
|
354 |
n.cases = []; |
|
355 |
n.defaultIndex = -1; |
|
356 |
x.stmtStack.push(n); |
|
357 |
t.mustMatch(LEFT_CURLY); |
|
358 |
while ((tt = t.get()) != RIGHT_CURLY) { |
|
359 |
switch (tt) { |
|
360 |
case DEFAULT: |
|
361 |
if (n.defaultIndex >= 0) |
|
362 |
throw t.newSyntaxError("More than one switch default"); |
|
363 |
// FALL THROUGH |
|
364 |
case CASE: |
|
365 |
n2 = new NarcNode(t); |
|
366 |
if (tt == DEFAULT) |
|
367 |
n.defaultIndex = n.cases.length; |
|
368 |
else |
|
369 |
n2.caseLabel = Expression(t, x, COLON); |
|
370 |
break; |
|
371 |
default: |
|
372 |
throw t.newSyntaxError("Invalid switch case"); |
|
373 |
} |
|
374 |
t.mustMatch(COLON); |
|
375 |
n2.statements = new NarcNode(t, BLOCK); |
|
376 |
while ((tt=t.peek()) != CASE && tt != DEFAULT && tt != RIGHT_CURLY) |
|
377 |
n2.statements.push(Statement(t, x)); |
|
378 |
n.cases.push(n2); |
|
379 |
} |
|
380 |
x.stmtStack.pop(); |
|
381 |
return n; |
|
382 |
|
|
383 |
case FOR: |
|
384 |
n = new NarcNode(t); |
|
385 |
n.isLoop = true; |
|
386 |
t.mustMatch(LEFT_PAREN); |
|
387 |
if ((tt = t.peek()) != SEMICOLON) { |
|
388 |
x.inForLoopInit = true; |
|
389 |
if (tt == VAR || tt == CONST) { |
|
390 |
t.get(); |
|
391 |
n2 = Variables(t, x); |
|
392 |
} else { |
|
393 |
n2 = Expression(t, x); |
|
394 |
} |
|
395 |
x.inForLoopInit = false; |
|
396 |
} |
|
397 |
if (n2 && t.match(IN)) { |
|
398 |
n.type = FOR_IN; |
|
399 |
if (n2.type == VAR) { |
|
400 |
if (n2.$length != 1) { |
|
401 |
throw new SyntaxError("Invalid for..in left-hand side", |
|
402 |
t.filename, n2.lineno); |
|
403 |
} |
|
404 |
|
|
405 |
// NB: n2[0].type == IDENTIFIER and n2[0].value == n2[0].name. |
|
406 |
n.iterator = n2[0]; |
|
407 |
n.varDecl = n2; |
|
408 |
} else { |
|
409 |
n.iterator = n2; |
|
410 |
n.varDecl = null; |
|
411 |
} |
|
412 |
n.object = Expression(t, x); |
|
413 |
} else { |
|
414 |
n.setup = n2 || null; |
|
415 |
t.mustMatch(SEMICOLON); |
|
416 |
n.condition = (t.peek() == SEMICOLON) ? null : Expression(t, x); |
|
417 |
t.mustMatch(SEMICOLON); |
|
418 |
n.update = (t.peek() == RIGHT_PAREN) ? null : Expression(t, x); |
|
419 |
} |
|
420 |
t.mustMatch(RIGHT_PAREN); |
|
421 |
n.body = nest(t, x, n, Statement); |
|
422 |
return n; |
|
423 |
|
|
424 |
case WHILE: |
|
425 |
n = new NarcNode(t); |
|
426 |
n.isLoop = true; |
|
427 |
n.condition = ParenExpression(t, x); |
|
428 |
n.body = nest(t, x, n, Statement); |
|
429 |
return n; |
|
430 |
|
|
431 |
case DO: |
|
432 |
n = new NarcNode(t); |
|
433 |
n.isLoop = true; |
|
434 |
n.body = nest(t, x, n, Statement, WHILE); |
|
435 |
n.condition = ParenExpression(t, x); |
|
436 |
if (!x.ecmaStrictMode) { |
|
437 |
// <script language="JavaScript"> (without version hints) may need |
|
438 |
// automatic semicolon insertion without a newline after do-while. |
|
439 |
// See http://bugzilla.mozilla.org/show_bug.cgi?id=238945. |
|
440 |
t.match(SEMICOLON); |
|
441 |
return n; |
|
442 |
} |
|
443 |
break; |
|
444 |
|
|
445 |
case BREAK: |
|
446 |
case CONTINUE: |
|
447 |
n = new NarcNode(t); |
|
448 |
if (t.peekOnSameLine() == IDENTIFIER) { |
|
449 |
t.get(); |
|
450 |
n.label = t.token().value; |
|
451 |
} |
|
452 |
ss = x.stmtStack; |
|
453 |
i = ss.length; |
|
454 |
label = n.label; |
|
455 |
if (label) { |
|
456 |
do { |
|
457 |
if (--i < 0) |
|
458 |
throw t.newSyntaxError("Label not found"); |
|
459 |
} while (ss[i].label != label); |
|
460 |
} else { |
|
461 |
do { |
|
462 |
if (--i < 0) { |
|
463 |
throw t.newSyntaxError("Invalid " + ((tt == BREAK) |
|
464 |
? "break" |
|
465 |
: "continue")); |
|
466 |
} |
|
467 |
} while (!ss[i].isLoop && (tt != BREAK || ss[i].type != SWITCH)); |
|
468 |
} |
|
469 |
n.target = ss[i]; |
|
470 |
break; |
|
471 |
|
|
472 |
case TRY: |
|
473 |
n = new NarcNode(t); |
|
474 |
n.tryBlock = Block(t, x); |
|
475 |
n.catchClauses = []; |
|
476 |
while (t.match(CATCH)) { |
|
477 |
n2 = new NarcNode(t); |
|
478 |
t.mustMatch(LEFT_PAREN); |
|
479 |
n2.varName = t.mustMatch(IDENTIFIER).value; |
|
480 |
if (t.match(IF)) { |
|
481 |
if (x.ecmaStrictMode) |
|
482 |
throw t.newSyntaxError("Illegal catch guard"); |
|
483 |
if (n.catchClauses.length && !n.catchClauses.top().guard) |
|
484 |
throw t.newSyntaxError("Guarded catch after unguarded"); |
|
485 |
n2.guard = Expression(t, x); |
|
486 |
} else { |
|
487 |
n2.guard = null; |
|
488 |
} |
|
489 |
t.mustMatch(RIGHT_PAREN); |
|
490 |
n2.block = Block(t, x); |
|
491 |
n.catchClauses.push(n2); |
|
492 |
} |
|
493 |
if (t.match(FINALLY)) |
|
494 |
n.finallyBlock = Block(t, x); |
|
495 |
if (!n.catchClauses.length && !n.finallyBlock) |
|
496 |
throw t.newSyntaxError("Invalid try statement"); |
|
497 |
return n; |
|
498 |
|
|
499 |
case CATCH: |
|
500 |
case FINALLY: |
|
501 |
throw t.newSyntaxError(tokens[tt] + " without preceding try"); |
|
502 |
|
|
503 |
case THROW: |
|
504 |
n = new NarcNode(t); |
|
505 |
n.exception = Expression(t, x); |
|
506 |
break; |
|
507 |
|
|
508 |
case RETURN: |
|
509 |
if (!x.inFunction) |
|
510 |
throw t.newSyntaxError("Invalid return"); |
|
511 |
n = new NarcNode(t); |
|
512 |
tt = t.peekOnSameLine(); |
|
513 |
if (tt != END && tt != NEWLINE && tt != SEMICOLON && tt != RIGHT_CURLY) |
|
514 |
n.value = Expression(t, x); |
|
515 |
break; |
|
516 |
|
|
517 |
case WITH: |
|
518 |
n = new NarcNode(t); |
|
519 |
n.object = ParenExpression(t, x); |
|
520 |
n.body = nest(t, x, n, Statement); |
|
521 |
return n; |
|
522 |
|
|
523 |
case VAR: |
|
524 |
case CONST: |
|
525 |
n = Variables(t, x); |
|
526 |
break; |
|
527 |
|
|
528 |
case DEBUGGER: |
|
529 |
n = new NarcNode(t); |
|
530 |
break; |
|
531 |
|
|
532 |
case REQUIRE: |
|
533 |
n = new NarcNode(t); |
|
534 |
n.classPath = ParenExpression(t, x); |
|
535 |
break; |
|
536 |
|
|
537 |
case NEWLINE: |
|
538 |
case SEMICOLON: |
|
539 |
n = new NarcNode(t, SEMICOLON); |
|
540 |
n.expression = null; |
|
541 |
return n; |
|
542 |
|
|
543 |
default: |
|
544 |
if (tt == IDENTIFIER && t.peek() == COLON) { |
|
545 |
label = t.token().value; |
|
546 |
ss = x.stmtStack; |
|
547 |
for (i = ss.length-1; i >= 0; --i) { |
|
548 |
if (ss[i].label == label) |
|
549 |
throw t.newSyntaxError("Duplicate label"); |
|
550 |
} |
|
551 |
t.get(); |
|
552 |
n = new NarcNode(t, LABEL); |
|
553 |
n.label = label; |
|
554 |
n.statement = nest(t, x, n, Statement); |
|
555 |
return n; |
|
556 |
} |
|
557 |
|
|
558 |
n = new NarcNode(t, SEMICOLON); |
|
559 |
t.unget(); |
|
560 |
n.expression = Expression(t, x); |
|
561 |
n.end = n.expression.end; |
|
562 |
break; |
|
563 |
} |
|
564 |
|
Also available in: Unified diff
upgrade to MapBuilder 1.5rc2 - includes support for Firefox 3 compatibility (yes, it is also EOLed)