test_worseAccuracyDoesNotBlockCallback.html (1421B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=494924 5 --> 6 <head> 7 <title>Test for getCurrentPosition </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=494924">Mozilla Bug 494924</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 "use strict"; 22 23 SimpleTest.waitForExplicitFinish(); 24 25 resume_geolocationProvider(function() { 26 force_prompt(true, test1); 27 }); 28 29 // The magic numbers 100 and 42 below are the accuracy results returned from the 30 // mock geolocation service and defined in network_geolocation.sjs. 31 function successCallback2(position) { 32 check_geolocation(position); 33 is(position.coords.accuracy, 100, "worse accuracy"); 34 SimpleTest.finish(); 35 } 36 37 function successCallback1(position) { 38 check_geolocation(position); 39 is(position.coords.accuracy, 42, "high accuracy"); 40 worse_geolocationProvider(function() { 41 navigator.geolocation.getCurrentPosition(successCallback2, null, { maximumAge: 0 }); 42 }); 43 } 44 45 function test1() { 46 navigator.geolocation.getCurrentPosition(successCallback1, null, { maximumAge: 0 }); 47 } 48 </script> 49 </pre> 50 </body> 51 </html>