blob: dc02a97dd85a1e54af932901cbc46eac4db9718d [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/testharness-adapter.js"></script>
</head>
<body>
<script type="module">
import {GeolocationMock} from './resources/geolocation-mock.js';
description("Tests that when Geolocation permission is denied, watches are stopped, as well as one-shots.");
let error;
// Configure the mock Geolocation service to report a position to cause permission
// to be requested, then deny it.
const mock = new GeolocationMock();
mock.setGeolocationPermission(false);
mock.setGeolocationPosition(51.478, -0.166, 100.0);
let errorCallbackInvoked = false;
navigator.geolocation.watchPosition(function(p) {
testFailed('Success callback invoked unexpectedly');
finishJSTest();
}, function(e) {
if (errorCallbackInvoked) {
testFailed('Error callback invoked unexpectedly : ' + error.message);
finishJSTest();
}
errorCallbackInvoked = true;
error = e;
assert_equals(error.code, error.PERMISSION_DENIED);
assert_equals(error.message, "User denied Geolocation");
// Update the mock Geolocation service to report a new position, then
// yield to allow a chance for the success callback to be invoked.
mock.setGeolocationPosition(55.478, -0.166, 100);
window.setTimeout(finishJSTest, 0);
});
</script>
</body>
</html>