dom/tests/mochitest/geolocation/test_optional_api_params.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/geolocation/test_optional_api_params.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,102 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=452566
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 452566</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="text/javascript" src="geolocation_common.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=452566">Mozilla Bug 452566</a>
    1.17 +<p id="display"></p>
    1.18 +<div id="content" style="display: none">
    1.19 +  
    1.20 +</div>
    1.21 +<pre id="test">
    1.22 +<script class="testbody" type="text/javascript">
    1.23 +
    1.24 +SimpleTest.waitForExplicitFinish();
    1.25 +
    1.26 +// ensure we are using the right testing provider
    1.27 +resume_geolocationProvider(function() {
    1.28 +  force_prompt(true, test1);
    1.29 +});
    1.30 +
    1.31 +/** Test for Bug 452566 **/
    1.32 +function test1() {
    1.33 +  ok(navigator.geolocation, "Should have geolocation");
    1.34 +
    1.35 +  var exception = null;
    1.36 +  try {
    1.37 +    navigator.geolocation.getCurrentPosition();
    1.38 +  } catch(ex if ex instanceof TypeError) {
    1.39 +    exception = ex;
    1.40 +  }
    1.41 +  ok(exception, "Should have got an exception");
    1.42 +
    1.43 +  exception = null;
    1.44 +  try {
    1.45 +    navigator.geolocation.getCurrentPosition(function() {});
    1.46 +  } catch(ex if ex instanceof TypeError) {
    1.47 +    exception = ex;
    1.48 +  }
    1.49 +  ok(!exception, exception);
    1.50 +
    1.51 +  exception = null;
    1.52 +  try {
    1.53 +    navigator.geolocation.getCurrentPosition(function() {}, function() {});
    1.54 +  } catch(ex if ex instanceof TypeError) {
    1.55 +    exception = ex;
    1.56 +  }
    1.57 +  ok(!exception, exception);
    1.58 +
    1.59 +  exception = null;
    1.60 +  try {
    1.61 +    navigator.geolocation.getCurrentPosition(function() {}, function() {}, {});
    1.62 +  } catch(ex if ex instanceof TypeError) {
    1.63 +    exception = ex;
    1.64 +  }
    1.65 +  ok(!exception, exception);
    1.66 +
    1.67 +  exception = null;
    1.68 +  try {
    1.69 +    navigator.geolocation.watchPosition();
    1.70 +  } catch(ex if ex instanceof TypeError) {
    1.71 +    exception = ex;
    1.72 +  }
    1.73 +  ok(exception, "Should have got an exception");
    1.74 +
    1.75 +  exception = null;
    1.76 +  try {
    1.77 +    navigator.geolocation.watchPosition(function() {});
    1.78 +  } catch(ex if ex instanceof TypeError) {
    1.79 +    exception = ex;
    1.80 +  }
    1.81 +  ok(!exception, exception);
    1.82 +
    1.83 +  exception = null;
    1.84 +  try {
    1.85 +    navigator.geolocation.watchPosition(function() {}, function() {});
    1.86 +  } catch(ex if ex instanceof TypeError) {
    1.87 +    exception = ex;
    1.88 +  }
    1.89 +  ok(!exception, exception);
    1.90 +
    1.91 +  exception = null;
    1.92 +  try {
    1.93 +    navigator.geolocation.watchPosition(function() {}, function() {}, {});
    1.94 +  } catch(ex if ex instanceof TypeError) {
    1.95 +    exception = ex;
    1.96 +  }
    1.97 +  ok(!exception, exception);
    1.98 +
    1.99 +  SimpleTest.finish();
   1.100 +}
   1.101 +
   1.102 +</script>
   1.103 +</pre>
   1.104 +</body>
   1.105 +</html>

mercurial