1 description("Tests that reentrant calls to Geolocation methods from the error callback due to a PERMISSION_DENIED error are OK."); 2 3 if (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 9 var error; 10 function checkPermissionError(e) { 11 error = e; 12 shouldBe('error.code', 'error.PERMISSION_DENIED'); 13 shouldBe('error.message', '"User denied Geolocation"'); 14 } 15 16 var errorCallbackInvoked = false; 17 navigator.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 30 function 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 40 window.jsTestIsAsync = true; 41 window.successfullyParsed = true; 42