Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / chrome / test / data / geolocation / two_watches.html
blob47caf5eb856ba9df8361eadc22af114b59ce5afa
1 <html>
2 <head>
3 <script>
4 var position_1 = 0;
5 var position_2 = 0;
6 var watch_1_id = 0;
7 var watch_2_id = 0;
8 var last_error = 0;
9 var final_position_latitude = 0;
10 var final_position_longitude = 0;
11 var initial_navigation_sent = false;
12 var iteration = 0;
13 function geoNavigate(msg) {
14 ++iteration;
15 document.location.hash = '#' + iteration + ':' + msg;
17 function geoSendInitialAlertIfNeeded() {
18 if (position_1 != 0 && position_2 != 0 && !initial_navigation_sent) {
19 if (position_1.coords.latitude != position_2.coords.latitude ||
20 position_1.coords.longitude != position_2.coords.longitude) {
21 last_error = "TEST FAIL: watches received different locations. " +
22 " Watch 1 (" + watch_1_id + ") got " + position_1 +
23 " Watch 2 (" + watch_2_id + ") got " + position_2;
25 initial_navigation_sent = true;
26 geoNavigate("Both watches received initial position");
29 function geoSuccessCallback1(position) {
30 position_1 = position;
31 geoSendInitialAlertIfNeeded();
32 if (position.coords.latitude == final_position_latitude &&
33 position.coords.longitude == final_position_longitude) {
34 geoNavigate("Watch ID " + watch_1_id + " got final position.");
37 function geoSuccessCallback2(position) {
38 navigator.geolocation.clearWatch(watch_2_id);
39 position_2 = position;
40 geoSendInitialAlertIfNeeded();
41 if (position.coords.latitude == final_position_latitude ||
42 position.coords.longitude == final_position_longitude) {
43 last_error = "TEST FAIL: watch 2 received the final position";
44 geoNavigate(last_error);
47 function geoErrorCallback(error) {
48 last_error = error;
49 geoNavigate("Got error: " + error);
51 function geoStart() {
52 watch_1_id = navigator.geolocation.watchPosition(
53 geoSuccessCallback1, geoErrorCallback,
54 {maximumAge:600000, timeout:100000, enableHighAccuracy:false});
55 if (watch_1_id == 0)
56 return "Bad watch 1 ID";
57 watch_2_id = navigator.geolocation.watchPosition(
58 geoSuccessCallback2, geoErrorCallback,
59 {maximumAge:600000, timeout:100000, enableHighAccuracy:true});
60 if (watch_2_id == 0)
61 return "Bad watch 2 ID";
62 if (watch_1_id == watch_2_id)
63 return "Watch 1 & 2 share ID " + watch_1_id;
65 function geoGetLastPositionLatitude() {
66 return "" + position_1.coords.latitude;
68 function geoGetLastPositionLongitude() {
69 return "" + position_1.coords.longitude;
71 function geoGetLastError() {
72 return "" + (last_error ? last_error : 0);
74 function geoSetFinalPosition(latitude, longitude) {
75 final_position_latitude = latitude;
76 final_position_longitude = longitude;
77 return "ok";
79 </script>
80 </head>
81 <body>
82 <input type="button" value="manual" onclick="geoStart()"/>
83 </body>
84 </html>