Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /geolocation/getCurrentPosition_TypeError.https.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<meta charset='utf-8'>
<title>Geolocation Test: getCurrentPosition TypeError tests</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script>
test(function() {
assert_throws_js(TypeError, function() {
navigator.geolocation.getCurrentPosition();
});
}, 'Call getCurrentPosition without arguments, check that exception is thrown');
test(function() {
assert_throws_js(TypeError, function() {
navigator.geolocation.getCurrentPosition(null);
});
}, 'Call getCurrentPosition with null success callback, check that exception is thrown');
test(function() {
assert_throws_js(TypeError, function() {
navigator.geolocation.getCurrentPosition(null, null);
});
}, 'Call getCurrentPosition with null success and error callbacks, check that exception is thrown');
test(function() {
assert_throws_js(TypeError, function() {
navigator.geolocation.getCurrentPosition(3);
});
}, 'Call getCurrentPosition() with wrong type for first argument. Exception expected.');
test(function() {
assert_throws_js(TypeError, function() {
navigator.geolocation.getCurrentPosition(()=>{}, 4);
});
}, 'Call getCurrentPosition() with wrong type for second argument. Exception expected.');
test(function() {
assert_throws_js(TypeError, function() {
navigator.geolocation.getCurrentPosition(()=>{}, ()=>{}, 4);
});
}, 'Call getCurrentPosition() with wrong type for third argument. Exception expected.');
test(function () {
const handleEvent = ()=>{};
assert_throws_js(TypeError, function () {
navigator.geolocation.getCurrentPosition({ handleEvent });
});
assert_throws_js(TypeError, function () {
navigator.geolocation.getCurrentPosition(()=>{}, { handleEvent });
});
}, "Calling getCurrentPosition() with a legacy event handler objects.");
</script>