tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_allowWatch.html (1261B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=478911
      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=478911">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 
     22 SimpleTest.waitForExplicitFinish();
     23 
     24 resume_geolocationProvider(function() {
     25  force_prompt(true, test1);
     26 });
     27 
     28 var watchID;
     29 var timestamp;
     30 
     31 /** @param {GeolocationPosition} position */
     32 function successCallback(position) {
     33  check_geolocation(position);
     34 
     35  const delay = position.timestamp - timestamp;
     36  info(`watchPosition took ${delay} ms`);
     37  ok(delay < 2000, "watchPosition should respond fast");
     38  navigator.geolocation.clearWatch(watchID);
     39  SimpleTest.finish();
     40 }
     41 
     42 function test1() {
     43  timestamp = Date.now();
     44  watchID = navigator.geolocation.watchPosition(successCallback, null, null);
     45  is(watchID, 1, "initially returns 1");
     46 }
     47 </script>
     48 </pre>
     49 </body>
     50 </html>