summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/geolocation-API
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/geolocation-API
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/geolocation-API')
-rw-r--r--testing/web-platform/tests/geolocation-API/OWNERS2
-rw-r--r--testing/web-platform/tests/geolocation-API/PositionOptions.html113
-rw-r--r--testing/web-platform/tests/geolocation-API/clearWatch_TypeError.html23
-rw-r--r--testing/web-platform/tests/geolocation-API/getCurrentPosition_IDL.html152
-rw-r--r--testing/web-platform/tests/geolocation-API/getCurrentPosition_TypeError.html55
-rw-r--r--testing/web-platform/tests/geolocation-API/getCurrentPosition_permission-manual.html21
-rw-r--r--testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_allow-manual.html32
-rw-r--r--testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_allow.html44
-rw-r--r--testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_deny-manual.html34
-rw-r--r--testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_deny.html34
-rw-r--r--testing/web-platform/tests/geolocation-API/interfaces.html95
-rw-r--r--testing/web-platform/tests/geolocation-API/support.js30
-rw-r--r--testing/web-platform/tests/geolocation-API/watchPosition_TypeError.html55
-rw-r--r--testing/web-platform/tests/geolocation-API/watchPosition_permission-manual.html21
-rw-r--r--testing/web-platform/tests/geolocation-API/watchPosition_permission_deny.html36
15 files changed, 747 insertions, 0 deletions
diff --git a/testing/web-platform/tests/geolocation-API/OWNERS b/testing/web-platform/tests/geolocation-API/OWNERS
new file mode 100644
index 000000000..64e2488b4
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/OWNERS
@@ -0,0 +1,2 @@
+@zqzhang
+@jdm
diff --git a/testing/web-platform/tests/geolocation-API/PositionOptions.html b/testing/web-platform/tests/geolocation-API/PositionOptions.html
new file mode 100644
index 000000000..9d4985eb7
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/PositionOptions.html
@@ -0,0 +1,113 @@
+<!DOCTYPE HTML>
+<meta charset="utf-8">
+<title>Geolocation Test: PositionOptions tests</title>
+<link rel="help" href="http://www.w3.org/TR/geolocation-API/#position_options_interface">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src='support.js'></script>
+
+<p>Clear all Geolocation permissions before running this test. If prompted for permission, please allow.</p>
+<div id="log"></div>
+
+<script>
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00123
+test(function() {
+ try {
+ geo.getCurrentPosition(dummyFunction, null, {enableHighAccuracy: "boom"});
+ geo.getCurrentPosition(dummyFunction, null, {enableHighAccuracy: 321});
+ geo.getCurrentPosition(dummyFunction, null, {enableHighAccuracy: -Infinity});
+ geo.getCurrentPosition(dummyFunction, null, {enableHighAccuracy: {foo: 5}});
+ } catch(e) {
+ assert_unreached('An exception was thrown unexpectedly: ' + e.message);
+ }
+}, 'Call getCurrentPosition with wrong type for enableHighAccuracy. No exception expected.');
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00124
+test(function() {
+ try {
+ geo.watchPosition(dummyFunction, null, {enableHighAccuracy: "boom"});
+ geo.watchPosition(dummyFunction, null, {enableHighAccuracy: 321});
+ geo.watchPosition(dummyFunction, null, {enableHighAccuracy: -Infinity});
+ geo.watchPosition(dummyFunction, null, {enableHighAccuracy: {foo: 5}});
+ } catch(e) {
+ assert_unreached('An exception was thrown unexpectedly: ' + e.message);
+ }
+}, 'Call watchPosition with wrong type for enableHighAccuracy. No exception expected.');
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00086, 00088, 00091 and 00092
+test(function() {
+ var t86 = async_test('Set timeout and maximumAge to 0, check that timeout error raised (getCurrentPosition)'),
+ t88 = async_test('Set timeout and maximumAge to 0, check that timeout error raised (watchPosition)'),
+ t91 = async_test('Check that a negative timeout value is equivalent to a 0 timeout value (getCurrentLocation)'),
+ t92 = async_test('Check that a negative timeout value is equivalent to a 0 timeout value (watchPosition)');
+
+ try {
+ geo.getCurrentPosition(
+ t86.step_func(function(pos) {
+ assert_unreached('A success callback was invoked unexpectedly');
+ }),
+ t86.step_func(function(err) {
+ assert_equals(err.code, err.TIMEOUT);
+ t86.done();
+ }),
+ {timeout: 0, maximumAge: 0}
+ );
+ } catch(e) {
+ t86.step(function() {
+ assert_unreached('An exception was thrown unexpectedly: ' + e.message);
+ });
+ }
+
+ try {
+ geo.watchPosition(
+ t88.step_func(function(pos) {
+ assert_unreached('A success callback was invoked unexpectedly');
+ }),
+ t88.step_func(function(err) {
+ assert_equals(err.code, err.TIMEOUT);
+ t88.done();
+ }),
+ {timeout: 0, maximumAge: 0}
+ );
+ } catch(e) {
+ t88.step(function() {
+ assert_unreached('An exception was thrown unexpectedly: ' + e.message);
+ });
+ }
+
+ try {
+ geo.getCurrentPosition(
+ t91.step_func(function(pos) {
+ assert_unreached('A success callback was invoked unexpectedly');
+ }),
+ t91.step_func(function(err) {
+ assert_equals(err.code, err.TIMEOUT);
+ t91.done();
+ }),
+ {timeout:-1, maximumAge: 0}
+ );
+ } catch(e) {
+ t91.step(function() {
+ assert_unreached('An exception was thrown unexpectedly: ' + e.message);
+ });
+ }
+
+ try {
+ geo.watchPosition(
+ t92.step_func(function(pos) {
+ assert_unreached('A success callback was invoked unexpectedly');
+ done();
+ }),
+ t92.step_func(function(err) {
+ assert_equals(err.code, err.TIMEOUT);
+ done();
+ }),
+ {timeout: -1, maximumAge: 0}
+ );
+ } catch(e) {
+ t92.step(function() {
+ assert_unreached('An exception was thrown unexpectedly: ' + e.message);
+ });
+ }
+}, 'PositionOptions tests');
+</script>
diff --git a/testing/web-platform/tests/geolocation-API/clearWatch_TypeError.html b/testing/web-platform/tests/geolocation-API/clearWatch_TypeError.html
new file mode 100644
index 000000000..d752ebac1
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/clearWatch_TypeError.html
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML>
+<meta charset='utf-8'>
+<title>Geolocation Test: clearWatch TypeError tests</title>
+<link rel='help' href='http://www.w3.org/TR/geolocation-API/#clear-watch'>
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='support.js'></script>
+
+<div id='log'></div>
+
+<script>
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00080
+test(function() {
+ try {
+ geo.clearWatch(-1);
+ geo.clearWatch(0);
+ geo.clearWatch(1);
+ } catch(e) {
+ assert_unreached('An exception was thrown unexpectedly: ' + e.message);
+ }
+ done();
+}, 'Test that calling clearWatch with invalid watch IDs does not cause an exception');
+</script>
diff --git a/testing/web-platform/tests/geolocation-API/getCurrentPosition_IDL.html b/testing/web-platform/tests/geolocation-API/getCurrentPosition_IDL.html
new file mode 100644
index 000000000..2a85505b8
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/getCurrentPosition_IDL.html
@@ -0,0 +1,152 @@
+<!DOCTYPE HTML>
+<meta charset="utf-8">
+<title>Geolocation Test: getCurrentPosition tests</title>
+<link rel="help" href="http://www.w3.org/TR/geolocation-API/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<p>Clear all Geolocation permissions before running this test. If prompted for permission, please allow.</p>
+<div id="log"></div>
+<script>
+var geo, success, fail;
+
+setup(function() {
+ geo = navigator.geolocation;
+}, {explicit_done: true});
+
+function successCallback(position)
+{
+ var ii, oldval;
+
+ /*
+ [NoInterfaceObject]
+ interface Position {
+ readonly attribute Coordinates coords;
+ readonly attribute DOMTimeStamp timestamp;
+ };
+ */
+
+ test(function() {
+ assert_equals(position.toString(), "[object Position]",
+ "Position.toString should result in '[object Position]' was: " + position.toString());
+ }, "Position toString");
+
+ test(function() {
+ assert_equals(position.coords.toString(), "[object Coordinates]",
+ "position.coords.toString should result in '[object Coordinates]' was: " + position.coords.toString());
+ }, "Position.coordinates toString");
+
+ test(function() {
+ assert_equals(typeof(position.timestamp), "number",
+ "Position.timestamp should be of type 'number' was: " + typeof(position.timestamp));
+ }, "Position.timestamp is type number");
+
+ /*
+ [NoInterfaceObject]
+ interface Coordinates {
+ readonly attribute double latitude;
+ readonly attribute double longitude;
+ readonly attribute double? altitude;
+ readonly attribute double accuracy;
+ readonly attribute double? altitudeAccuracy;
+ readonly attribute double? heading;
+ readonly attribute double? speed;
+ };
+ */
+
+ for (ii in position.coords) {
+ // these four can be numbers or null
+ if (ii == "altitude" || ii == "altitudeAccuracy" || ii == "heading" || ii == "speed") {
+ test(function() {
+ assert_true(position.coords[ii] === null || typeof(position.coords[ii]) === "number",
+ ii + " must be null or 'number' type, was: " + typeof(position.coords[ii]));
+ }, ii+ " is null or number");
+ } else {
+ test(function() {
+ assert_equals(typeof(position.coords[ii]), "number",
+ ii + " should be type 'number' but typeof returned: " + typeof(position.coords[ii]));
+ }, ii + " is type number");
+ }
+
+ oldval = position.coords[ii];
+ position.coords[ii] = 666;
+
+ test(function() {
+ assert_equals(position.coords[ii], oldval,
+ ii + " should be readonly, wrote: " + position.coords[ii] + " old value was " + oldval);
+ }, ii + " readonly");
+
+ }
+
+ success.done();
+ done();
+}
+
+function BadErrorCallback(error)
+{
+ success.step(function() {
+ assert_unreached("Error callback called in error");
+ });
+ success.done();
+ done();
+}
+
+function BadSuccessCallback(position)
+{
+ fail.step(function() {
+ assert_unreached("Success callback called in error");
+ });
+ fail.done();
+}
+
+function errorCallback(error)
+{
+ test(function() {
+ assert_equals(error.toString(), "[object PositionError]",
+ "PositionError.toString should result in '[object PositionError]' was: " +
+ error.toString());
+ }, "PositionError toString");
+
+ test(function() {
+ assert_equals(error.PERMISSION_DENIED, 1,
+ "PERMISSION_DENIED should be 1 was: " + error.POSITION_DENIED);
+ }, "PERMISSION_DENIED value is 1");
+
+ test(function() {
+ assert_equals(error.POSITION_UNAVAILABLE, 2,
+ "POSITION_UNAVAILABLE should be 2' was: " + error.POSITION_UNAVAILABLE);
+ }, "POSITION_UNAVAILABLE is 2");
+
+ test(function() {
+ assert_equals(error.TIMEOUT, 3,
+ "TIMEOUT should be 3 was: " + error.TIMEOUT);
+ }, "TIMEOUT value is 3");
+
+ fail.done();
+}
+
+success = async_test("getCurrentPosition success callback tests", {timeout:20000});
+
+// with a longer timeout and with the user accepting the position request,
+// this should test the successcallback
+success.step(function() {
+ geo.getCurrentPosition(
+ successCallback,
+ BadErrorCallback,
+ {maximumAge:600000, timeout:10000}
+ );
+});
+
+fail = async_test("getCurrentPosition error callback tests");
+
+// with a timeout of 0 the error callback is hopefully consistently called
+fail.step(function() {
+ geo.getCurrentPosition(
+ BadSuccessCallback,
+ errorCallback,
+ {maximumAge:00, timeout:0}
+ );
+});
+
+</script>
+
diff --git a/testing/web-platform/tests/geolocation-API/getCurrentPosition_TypeError.html b/testing/web-platform/tests/geolocation-API/getCurrentPosition_TypeError.html
new file mode 100644
index 000000000..a2e578469
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/getCurrentPosition_TypeError.html
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML>
+<meta charset='utf-8'>
+<title>Geolocation Test: getCurrentPosition TypeError tests</title>
+<link rel='help' href='http://www.w3.org/TR/geolocation-API/'>
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='support.js'></script>
+
+<div id='log'></div>
+
+<script>
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00027
+test(function() {
+ assert_throws(new TypeError(), function() {
+ geo.getCurrentPosition();
+ });
+}, 'Call getCurrentPosition without arguments, check that exception is thrown');
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00011
+test(function() {
+ assert_throws(new TypeError(), function() {
+ geo.getCurrentPosition(null);
+ });
+}, 'Call getCurrentPosition with null success callback, check that exception is thrown');
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00013
+test(function() {
+ assert_throws(new TypeError(), function() {
+ geo.getCurrentPosition(null, null);
+ });
+}, 'Call getCurrentPosition with null success and error callbacks, check that exception is thrown');
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00028
+test(function() {
+ assert_throws(new TypeError(), function() {
+ geo.getCurrentPosition(3);
+ });
+}, 'Call getCurrentPosition() with wrong type for first argument. Exception expected.');
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00029
+test(function() {
+ assert_throws(new TypeError(), function() {
+ geo.getCurrentPosition(dummyFunction, 4);
+ });
+}, 'Call getCurrentPosition() with wrong type for second argument. Exception expected.');
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00030
+test(function() {
+ assert_throws(new TypeError(), function() {
+ geo.getCurrentPosition(dummyFunction, dummyFunction, 4);
+ });
+}, 'Call getCurrentPosition() with wrong type for third argument. Exception expected.');
+
+done();
+</script>
diff --git a/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission-manual.html b/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission-manual.html
new file mode 100644
index 000000000..20003cdff
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission-manual.html
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML>
+<meta charset='utf-8'>
+<title>Call getCurrentPosition, check that there is UI appearing with the document host</title>
+<link rel='help' href='http://www.w3.org/TR/geolocation-API/#privacy_for_uas'>
+
+<p>Clear all Geolocation permissions before running this test.</p>
+
+<p>Test passes if there is a permission prompt including the host <strong id='host'></strong> and no FAIL.</p>
+<div id='log'></div>
+
+<script>
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00018
+try {
+ var dummyFunction = function() {};
+ window.navigator.geolocation.getCurrentPosition(dummyFunction, dummyFunction);
+
+ document.getElementById('host').innerHTML = window.location.hostname;
+} catch (e) {
+ document.getElementById('log').innerHTML = 'FAIL: an exception was thrown unexpectedly: ' + e.message;
+}
+</script>
diff --git a/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_allow-manual.html b/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_allow-manual.html
new file mode 100644
index 000000000..4628275e3
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_allow-manual.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<meta charset='utf-8'>
+<title>User asked to approve/remember, then asked to revoke, then reload. The permission dialogue should reappear</title>
+<link rel='help' href='http://www.w3.org/TR/geolocation-API/#get-current-position'>
+
+<p>Clear all Geolocation permissions before running this test. If prompted for permission, please allow.</p>
+
+<div id='log'></div>
+
+<script>
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00141
+var nextStep, onError, isUsingPreemptivePermission = false;
+
+nextStep = function() {
+ document.querySelector('p').innerHTML =
+ 'Now revoke permissions for this origin (where applicable) and reload the page. Tests passes if there is a permission prompt again and no FAIL.';
+};
+
+onError = function(err) {
+ if (!isUsingPreemptivePermission && err.code === err.POSITION_UNAVAILABLE) {
+ nextStep();
+ } else {
+ document.getElementById('log').innerHTML = 'FAIL: an error callback was invoked unexpectedly: ' + err.message;
+ }
+};
+
+try {
+ window.navigator.geolocation.getCurrentPosition(nextStep, onError);
+} catch (e) {
+ document.getElementById('log').innerHTML = 'FAIL: an exception was thrown unexpectedly: ' + e.message;
+}
+</script>
diff --git a/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_allow.html b/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_allow.html
new file mode 100644
index 000000000..dfadcb09d
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_allow.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML>
+<meta charset='utf-8'>
+<title>Geolocation Test: getCurrentPosition location access allowed</title>
+<link rel='help' href='http://www.w3.org/TR/geolocation-API/#get-current-position'>
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='support.js'></script>
+
+<p>Clear all Geolocation permissions before running this test. If prompted for permission, please allow.</p>
+<div id='log'></div>
+
+<script>
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00002
+var t = async_test('User allows access, check that success callback is called or error callback is called with correct code.'),
+ onSuccess, onError, hasMethodReturned = false;
+
+onSuccess = t.step_func(function(pos) {
+ // Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00031
+ test(function() {
+ assert_true(hasMethodReturned);
+ }, 'Check that getCurrentPosition returns synchronously before any callbacks are invoked.');
+
+ done();
+});
+
+onError = t.step_func(function(err) {
+ // Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00031
+ test(function() {
+ assert_true(hasMethodReturned);
+ }, 'Check that getCurrentPosition returns synchronously before any callbacks are invoked.');
+
+ assert_true(!isUsingPreemptivePermission && err.code === err.POSITION_UNAVAILABLE);
+ done();
+});
+
+try {
+ geo.getCurrentPosition(onSuccess, onError);
+ hasMethodReturned = true;
+} catch(e) {
+ t.step(function() {
+ assert_unreached('An exception was thrown unexpectedly: ' + e.message);
+ });
+}
+</script>
diff --git a/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_deny-manual.html b/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_deny-manual.html
new file mode 100644
index 000000000..b468a65da
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_deny-manual.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<meta charset='utf-8'>
+<title>User asked to deny/remember, then asked to revoke, then reload. The permission dialogue should reappear</title>
+<link rel='help' href='http://www.w3.org/TR/geolocation-API/#get-current-position'>
+
+<p>Clear all Geolocation permissions before running this test. If prompted for permission, please deny.</p>
+
+<div id='log'></div>
+
+<script>
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00142
+var onSuccess, nextStep, isUsingPreemptivePermission = false;
+
+onSuccess = function() {
+ document.getElementById('log').innerHTML = 'FAIL: a success callback was invoked unexpectedly.';
+};
+
+nextStep = function(err) {
+ if ((err.code === err.PERMISSION_DENIED) ||
+ (!isUsingPreemptivePermission && err.code === err.POSITION_UNAVAILABLE)) {
+ document.querySelector('p').innerHTML =
+ 'Now revoke permissions for this origin (where applicable) and reload the page. Tests passes if there is a permission prompt again and no FAIL.';
+ } else {
+ document.getElementById('log').innerHTML =
+ 'FAIL: an error callback was invoked with unexpected error code: ' + err.code + ', error message: ' + err.message;
+ }
+};
+
+try {
+ navigator.geolocation.getCurrentPosition(onSuccess, nextStep);
+} catch (e) {
+ document.getElementById('log').innerHTML = 'FAIL: an exception was thrown unexpectedly: ' + e.message;
+}
+</script>
diff --git a/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_deny.html b/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_deny.html
new file mode 100644
index 000000000..26fe8899e
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/getCurrentPosition_permission_deny.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<meta charset='utf-8'>
+<title>Geolocation Test: getCurrentPosition location access denied</title>
+<link rel='help' href='http://www.w3.org/TR/geolocation-API/#privacy_for_uas'>
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='support.js'></script>
+
+<p>Clear all Geolocation permissions before running this test. If prompted for permission, please deny.</p>
+<div id='log'></div>
+
+<script>
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00001
+var t = async_test('User denies access, check that error callback is called with correct code'),
+ onSuccess, onError, hasMethodReturned = false;
+
+t.step(function() {
+ onSuccess = t.step_func(function(pos) {
+ assert_unreached('A success callback was invoked unexpectedly with position ' + positionToString(pos));
+ });
+
+ onError = t.step_func(function(err) {
+ // http://dev.w3.org/geo/api/test-suite/t.html?00031
+ assert_true(hasMethodReturned, 'Check that getCurrentPosition returns synchronously before any callbacks are invoked');
+ assert_equals(err.code, err.PERMISSION_DENIED,
+ 'PossitionError code: ' + err.code, + ', message: ' + err.message);
+ done();
+ });
+
+ geo.getCurrentPosition(onSuccess, onError);
+ hasMethodReturned = true;
+});
+</script>
+
diff --git a/testing/web-platform/tests/geolocation-API/interfaces.html b/testing/web-platform/tests/geolocation-API/interfaces.html
new file mode 100644
index 000000000..0db420465
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/interfaces.html
@@ -0,0 +1,95 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Geolocation API IDL tests</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="help" href="http://www.w3.org/TR/geolocation-API/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/WebIDLParser.js"></script>
+<script src="/resources/idlharness.js"></script>
+
+<h1>Geolocation API IDL tests</h1>
+<div id="log"></div>
+
+<script type=text/plain class=untested>
+interface Navigator {
+};
+
+typedef unsigned long long DOMTimeStamp;
+</script>
+
+<script type=text/plain>
+partial interface Navigator {
+ readonly attribute Geolocation geolocation;
+};
+
+[NoInterfaceObject]
+interface Geolocation {
+ void getCurrentPosition(PositionCallback successCallback,
+ optional PositionErrorCallback errorCallback,
+ optional PositionOptions options);
+
+ long watchPosition(PositionCallback successCallback,
+ optional PositionErrorCallback errorCallback,
+ optional PositionOptions options);
+
+ void clearWatch(long watchId);
+};
+
+callback PositionCallback = void (Position position);
+
+callback PositionErrorCallback = void (PositionError positionError);
+
+dictionary PositionOptions {
+ boolean enableHighAccuracy = false;
+ [Clamp] unsigned long timeout = 0xFFFFFFFF;
+ [Clamp] unsigned long maximumAge = 0;
+};
+
+[NoInterfaceObject]
+interface Position {
+ readonly attribute Coordinates coords;
+ readonly attribute DOMTimeStamp timestamp;
+};
+
+[NoInterfaceObject]
+interface Coordinates {
+ readonly attribute double latitude;
+ readonly attribute double longitude;
+ readonly attribute double? altitude;
+ readonly attribute double accuracy;
+ readonly attribute double? altitudeAccuracy;
+ readonly attribute double? heading;
+ readonly attribute double? speed;
+};
+
+[NoInterfaceObject]
+interface PositionError {
+ const unsigned short PERMISSION_DENIED = 1;
+ const unsigned short POSITION_UNAVAILABLE = 2;
+ const unsigned short TIMEOUT = 3;
+ readonly attribute unsigned short code;
+ readonly attribute DOMString message;
+};
+</script>
+
+<script>
+"use strict";
+var idlArray;
+setup(function() {
+ idlArray = new IdlArray();
+ [].forEach.call(document.querySelectorAll("script[type=text\\/plain]"), function(node) {
+ if (node.className == "untested") {
+ idlArray.add_untested_idls(node.textContent);
+ } else {
+ idlArray.add_idls(node.textContent);
+ }
+ });
+ idlArray.add_objects({
+ Navigator: ["navigator"],
+ Geolocation: ["navigator.geolocation"]
+ });
+});
+idlArray.test();
+</script>
+
diff --git a/testing/web-platform/tests/geolocation-API/support.js b/testing/web-platform/tests/geolocation-API/support.js
new file mode 100644
index 000000000..c85b5c87f
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/support.js
@@ -0,0 +1,30 @@
+var geo;
+
+setup(function() {
+ geo = navigator.geolocation;
+}, {explicit_done: true});
+
+// The spec states that an implementation SHOULD acquire user permission before
+// beggining the position acquisition steps. If an implementation follows this
+// advice, set the following flag to aid debugging.
+var isUsingPreemptivePermission = false;
+
+
+var dummyFunction = function() {};
+
+var positionToString = function(pos) {
+ var c = pos.coords;
+ return '[lat: ' + c.latitude + ', lon: ' + c.longitude + ', acc: ' + c.accuracy + ']';
+};
+
+var errorToString = function(err) {
+ var codeString;
+ switch(err.code) {
+ case err.UNKNOWN_ERROR: codeString = 'UNKNOWN_ERROR'; break;
+ case err.PERMISSION_DENIED: codeString = 'PERMISSION_DENIED'; break;
+ case err.POSITION_UNAVAILABLE: codeString = 'POSITION_UNAVAILABLE'; break;
+ case err.TIMEOUT: codeString = 'TIMEOUT'; break;
+ default: codeString = 'undefined error code'; break;
+ }
+ return '[code: ' + codeString + ' (' + err.code + '), message: ' + (err.message ? err.message : '(empty)') + ']';
+};
diff --git a/testing/web-platform/tests/geolocation-API/watchPosition_TypeError.html b/testing/web-platform/tests/geolocation-API/watchPosition_TypeError.html
new file mode 100644
index 000000000..9d7efd5e7
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/watchPosition_TypeError.html
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML>
+<meta charset='utf-8'>
+<title>Geolocation Test: watchPosition TypeError tests</title>
+<link rel='help' href='http://www.w3.org/TR/geolocation-API/'>
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='support.js'></script>
+
+<div id='log'></div>
+
+<script>
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00058
+test(function() {
+ assert_throws(new TypeError(), function() {
+ geo.watchPosition();
+ });
+}, 'Call watchPosition without arguments, check that exception is thrown');
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00015
+test(function() {
+ assert_throws(new TypeError(), function() {
+ geo.watchPosition(null);
+ });
+}, 'Call watchPosition with null success callback, check that exception is thrown');
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00017
+test(function() {
+ assert_throws(new TypeError(), function() {
+ geo.watchPosition(null, null);
+ });
+}, 'Call watchPosition with null success and error callbacks, check that exception is thrown');
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00059
+test(function() {
+ assert_throws(new TypeError(), function() {
+ geo.watchPosition(3);
+ });
+}, 'Call watchPosition() with wrong type for first argument. Exception expected.');
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00060
+test(function() {
+ assert_throws(new TypeError(), function() {
+ geo.watchPosition(dummyFunction, 4);
+ });
+}, 'Call watchPosition() with wrong type for second argument. Exception expected.');
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00061
+test(function() {
+ assert_throws(new TypeError(), function() {
+ geo.watchPosition(dummyFunction, dummyFunction, 4);
+ });
+}, 'Call watchPosition() with wrong type for third argument. Exception expected.');
+
+done();
+</script>
diff --git a/testing/web-platform/tests/geolocation-API/watchPosition_permission-manual.html b/testing/web-platform/tests/geolocation-API/watchPosition_permission-manual.html
new file mode 100644
index 000000000..e00980192
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/watchPosition_permission-manual.html
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML>
+<meta charset='utf-8'>
+<title>Call watchPosition, check that there is UI appearing with the document host</title>
+<link rel='help' href='http://www.w3.org/TR/geolocation-API/#privacy_for_uas'>
+
+<p>Clear all Geolocation permissions before running this test.</p>
+
+<p>Test passes if there is a permission prompt including the host <strong id='host'></strong> and no FAIL.</p>
+<div id='log'></div>
+
+<script>
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00019
+try {
+ var dummyFunction = function() {};
+ window.navigator.geolocation.watchPosition(dummyFunction, dummyFunction);
+
+ document.getElementById('host').innerHTML = window.location.hostname;
+} catch (e) {
+ document.getElementById('log').innerHTML = 'FAIL: ' + e.message;
+}
+</script>
diff --git a/testing/web-platform/tests/geolocation-API/watchPosition_permission_deny.html b/testing/web-platform/tests/geolocation-API/watchPosition_permission_deny.html
new file mode 100644
index 000000000..831a1544f
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/watchPosition_permission_deny.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<meta charset='utf-8'>
+<title>Geolocation Test: watchPosition location access denied</title>
+<link rel='help' href='http://www.w3.org/TR/geolocation-API/#watch-position'>
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<script src='support.js'></script>
+
+<p>Clear all Geolocation permissions before running this test. If prompted for permission, please deny.</p>
+<div id='log'></div>
+
+<script>
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00062
+var t = async_test('Check that watchPosition returns synchronously before any callbacks are invoked.'),
+ id, checkMethodHasReturned, hasMethodReturned = false;
+
+checkMethodHasReturned = t.step_func(function() {
+ assert_true(hasMethodReturned);
+ done();
+});
+
+try {
+ id = geo.watchPosition(checkMethodHasReturned, checkMethodHasReturned);
+ hasMethodReturned = true;
+} catch(e) {
+ t.step(function() {
+ assert_unreached('An exception was thrown unexpectedly: ' + e.message);
+ });
+}
+
+// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00151
+test(function() {
+ assert_greater_than_equal(id, -2147483648);
+ assert_less_than_equal(id, 2147483647);
+}, 'Check that watchPosition returns a long');
+</script>