test_timeoutWatch.html (1535B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=455327 5 --> 6 <head> 7 <title>Test for timeout option </title> 8 <script 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=455327">Mozilla Bug 478911</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 /** Test for Bug */ 22 23 // ensure we are using the right testing provider 24 resume_geolocationProvider(function() { 25 force_prompt(true, test1); 26 }); 27 28 SimpleTest.waitForExplicitFinish(); 29 30 function test1() { 31 stop_geolocationProvider(test2); 32 } 33 34 function successCallback(_pos){ 35 ok(false, "success should have never been called."); 36 resume_geolocationProvider(function() { 37 SimpleTest.finish(); 38 }); 39 } 40 41 function errorCallback(err) { 42 if (err.code == err.POSITION_UNAVAILABLE) 43 ok(false, "nothing is hooked up to test against."); 44 else 45 ok(err.code == err.TIMEOUT, "ensure error is a timeout."); 46 resume_geolocationProvider(function() { 47 SimpleTest.finish(); 48 }); 49 } 50 51 52 var options = { 53 maximumAge: 0, 54 timeout: 10 55 }; 56 57 function test2() { 58 navigator.geolocation.watchPosition(successCallback, 59 errorCallback, 60 options); 61 } 62 </script> 63 </pre> 64 </body> 65 </html>