|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=526326 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for watchPosition </title> |
|
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="text/javascript" src="geolocation_common.js"></script> |
|
10 |
|
11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
12 </head> |
|
13 <body> |
|
14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=526326">Mozilla Bug 526326</a> |
|
15 <p id="display"></p> |
|
16 <div id="content" style="display: none"> |
|
17 |
|
18 </div> |
|
19 <pre id="test"> |
|
20 <script class="testbody" type="text/javascript"> |
|
21 |
|
22 SimpleTest.waitForExplicitFinish(); |
|
23 |
|
24 // ensure we are using the right testing provider |
|
25 resume_geolocationProvider(function() { |
|
26 force_prompt(true, test1); |
|
27 }); |
|
28 |
|
29 var watchID; |
|
30 var times = 0; |
|
31 |
|
32 function errorCallback(err) { |
|
33 ok(err.code == err.TIMEOUT, "ensure error is a timeout."); |
|
34 times++; |
|
35 |
|
36 // make sure we got at least 3 times errorCallback |
|
37 if (times >= 3) { |
|
38 navigator.geolocation.clearWatch(watchID); |
|
39 resume_geolocationProvider(function() { |
|
40 set_network_request_cache_enabled(true, |
|
41 function() { SimpleTest.finish(); } ); |
|
42 }); |
|
43 } |
|
44 } |
|
45 |
|
46 function successCallback(position) { |
|
47 ok(1, "on success"); |
|
48 // Now that we got a success callback, lets try to ensure |
|
49 // that we get a timeout error. |
|
50 // The network cache is already off, now stop the sjs from reponding to requests |
|
51 stop_geolocationProvider(function(){}); |
|
52 } |
|
53 |
|
54 var options = { |
|
55 maximumAge: 0, |
|
56 timeout: 1000 |
|
57 }; |
|
58 |
|
59 function test1() { |
|
60 set_network_request_cache_enabled(false, |
|
61 function() { |
|
62 watchID = navigator.geolocation.watchPosition(successCallback, errorCallback, options); |
|
63 }); |
|
64 } |
|
65 </script> |
|
66 </pre> |
|
67 </body> |
|
68 </html> |
|
69 |