test_manyWatchConcurrent.html (1458B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=482260 5 --> 6 <head> 7 <title>Test for watchPosition </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=482260">Mozilla Bug 482260</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 var successCallbackCalled = 0; 30 var failureCallbackCalled = 0; 31 const totalResults = 100; 32 33 function test1() { 34 for (var x = 0; x < totalResults; x++) { 35 let watchID = navigator.geolocation.watchPosition( 36 position => { 37 check_geolocation(position); 38 successCallbackCalled++; 39 watchCallback(watchID); 40 }, 41 _error => { 42 failureCallbackCalled++; 43 watchCallback(watchID); 44 } 45 ); 46 } 47 } 48 49 function watchCallback(watchID) { 50 navigator.geolocation.clearWatch(watchID); 51 if (successCallbackCalled + failureCallbackCalled != totalResults) 52 return; 53 is(failureCallbackCalled, 0, "no failure callbacks should have been received"); 54 SimpleTest.finish(); 55 } 56 57 </script> 58 </pre> 59 </body> 60 </html>