blob: 2f08f819bce7718734972e6cc2ee6788dca8caf1 [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 reentrant calls to Geolocation methods from the error callback are OK.");
var mockMessage = 'test';
if (window.testRunner) {
testRunner.setGeolocationPermission(true);
testRunner.setMockGeolocationPositionUnavailableError(mockMessage);
} else
debug('This test can not be run without the testRunner');
var error;
var errorCallbackInvoked = false;
navigator.geolocation.getCurrentPosition(function(p) {
testFailed('Success callback invoked unexpectedly');
finishJSTest();
}, function(e) {
if (errorCallbackInvoked) {
testFailed('Error callback invoked unexpectedly');
finishJSTest();
}
errorCallbackInvoked = true;
error = e;
shouldBe('error.code', 'error.POSITION_UNAVAILABLE');
shouldBe('error.message', 'mockMessage');
debug('');
continueTest();
});
function continueTest() {
mockMessage += ' repeat';
if (window.testRunner)
testRunner.setMockGeolocationPositionUnavailableError(mockMessage);
navigator.geolocation.getCurrentPosition(function(p) {
testFailed('Success callback invoked unexpectedly');
finishJSTest();
}, function(e) {
error = e;
shouldBe('error.code', 'error.POSITION_UNAVAILABLE');
shouldBe('error.message', 'mockMessage');
finishJSTest();
});
}
window.jsTestIsAsync = true;
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>