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