blob: f66a98b655067f89df052c96f8cb43e0e5b70643 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Tests that when Geolocation permission has been denied prior to a call to watchPosition, and the watch is cleared in the error callback, there is no crash. This a regression test for https://bugs.webkit.org/show_bug.cgi?id=32111.");
// Prime the Geolocation instance by denying permission.
if (window.testRunner) {
testRunner.setGeolocationPermission(false);
testRunner.setMockGeolocationPosition(51.478, -0.166, 100);
} else
debug('This test can not be run without the testRunner');
var error;
navigator.geolocation.getCurrentPosition(function(p) {
testFailed('Success callback invoked unexpectedly');
finishJSTest();
}, function(e) {
error = e;
shouldBe('error.code', 'error.PERMISSION_DENIED');
shouldBe('error.message', '"User denied Geolocation"');
debug('');
continueTest();
});
function continueTest()
{
// Make another request, with permission already denied.
var watchId = navigator.geolocation.watchPosition(function(p) {
testFailed('Success callback invoked unexpectedly');
finishJSTest();
}, function(e) {
error = e;
shouldBe('error.code', 'error.PERMISSION_DENIED');
shouldBe('error.message', '"User denied Geolocation"');
navigator.geolocation.clearWatch(watchId);
window.setTimeout(finishJSTest, 0);
});
}
window.jsTestIsAsync = true;
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>