tor-browser

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

test_optional_api_params.html (2736B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=452566
      5 -->
      6 <head>
      7  <title>Test for Bug 452566</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script type="text/javascript" src="geolocation_common.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=452566">Mozilla Bug 452566</a>
     14 <p id="display"></p>
     15 <div id="content" style="display: none">
     16 
     17 </div>
     18 <pre id="test">
     19 <script class="testbody" type="text/javascript">
     20 
     21 SimpleTest.waitForExplicitFinish();
     22 
     23 // ensure we are using the right testing provider
     24 resume_geolocationProvider(function() {
     25  force_prompt(true, test1);
     26 });
     27 
     28 /** Test for Bug 452566 */
     29 function test1() {
     30  ok(navigator.geolocation, "Should have geolocation");
     31 
     32  var exception = null;
     33  try {
     34    navigator.geolocation.getCurrentPosition();
     35  } catch (ex) {
     36    if (!(ex instanceof TypeError)) {
     37      throw ex;
     38    }
     39    exception = ex;
     40  }
     41  ok(exception, "Should have got an exception");
     42 
     43  exception = null;
     44  try {
     45    navigator.geolocation.getCurrentPosition(function() {});
     46  } catch (ex) {
     47    if (!(ex instanceof TypeError)) {
     48      throw ex;
     49    }
     50    exception = ex;
     51  }
     52  ok(!exception, exception);
     53 
     54  exception = null;
     55  try {
     56    navigator.geolocation.getCurrentPosition(function() {}, function() {});
     57  } catch (ex) {
     58    if (!(ex instanceof TypeError)) {
     59      throw ex;
     60    }
     61    exception = ex;
     62  }
     63  ok(!exception, exception);
     64 
     65  exception = null;
     66  try {
     67    navigator.geolocation.getCurrentPosition(function() {}, function() {}, {});
     68  } catch (ex) {
     69    if (!(ex instanceof TypeError)) {
     70      throw ex;
     71    }
     72    exception = ex;
     73  }
     74  ok(!exception, exception);
     75 
     76  exception = null;
     77  try {
     78    navigator.geolocation.watchPosition();
     79  } catch (ex) {
     80    if (!(ex instanceof TypeError)) {
     81      throw ex;
     82    }
     83    exception = ex;
     84  }
     85  ok(exception, "Should have got an exception");
     86 
     87  exception = null;
     88  try {
     89    navigator.geolocation.watchPosition(function() {});
     90  } catch (ex) {
     91    if (!(ex instanceof TypeError)) {
     92      throw ex;
     93    }
     94    exception = ex;
     95  }
     96  ok(!exception, exception);
     97 
     98  exception = null;
     99  try {
    100    navigator.geolocation.watchPosition(function() {}, function() {});
    101  } catch (ex) {
    102    if (!(ex instanceof TypeError)) {
    103      throw ex;
    104    }
    105    exception = ex;
    106  }
    107  ok(!exception, exception);
    108 
    109  exception = null;
    110  try {
    111    navigator.geolocation.watchPosition(function() {}, function() {}, {});
    112  } catch (ex) {
    113    if (!(ex instanceof TypeError)) {
    114      throw ex;
    115    }
    116    exception = ex;
    117  }
    118  ok(!exception, exception);
    119 
    120  SimpleTest.finish();
    121 }
    122 
    123 </script>
    124 </pre>
    125 </body>
    126 </html>