1description("Tests that reentrant calls to Geolocation methods from the error callback due to a PERMISSION_DENIED error are OK."); 2 3if (window.layoutTestController) { 4 layoutTestController.setGeolocationPermission(false); 5 layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100.0); 6} else 7 debug('This test can not be run without the LayoutTestController'); 8 9var error; 10function checkPermissionError(e) { 11 error = e; 12 shouldBe('error.code', 'error.PERMISSION_DENIED'); 13 shouldBe('error.message', '"User denied Geolocation"'); 14} 15 16var errorCallbackInvoked = false; 17navigator.geolocation.getCurrentPosition(function(p) { 18 testFailed('Success callback invoked unexpectedly'); 19 finishJSTest(); 20}, function(e) { 21 if (errorCallbackInvoked) { 22 testFailed('Error callback invoked unexpectedly'); 23 finishJSTest(); 24 } 25 errorCallbackInvoked = true; 26 checkPermissionError(e); 27 continueTest(); 28}); 29 30function continueTest() { 31 navigator.geolocation.getCurrentPosition(function(p) { 32 testFailed('Success callback invoked unexpectedly'); 33 finishJSTest(); 34 }, function(e) { 35 checkPermissionError(e); 36 finishJSTest(); 37 }); 38} 39 40window.jsTestIsAsync = true; 41window.successfullyParsed = true; 42