1 description("Tests that when a position is available, no callbacks are invoked until permission is denied."); 2 3 if (window.layoutTestController) 4 window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100); 5 6 function denyPermission() { 7 permissionSet = true; 8 if (window.layoutTestController) 9 layoutTestController.setGeolocationPermission(false); 10 } 11 12 var error; 13 navigator.geolocation.getCurrentPosition(function() { 14 testFailed('Success callback invoked unexpectedly'); 15 finishJSTest(); 16 }, function(e) { 17 if (permissionSet) { 18 error = e; 19 shouldBe('error.code', 'error.PERMISSION_DENIED'); 20 shouldBe('error.message', '"User denied Geolocation"'); 21 finishJSTest(); 22 return; 23 } 24 testFailed('Error callback invoked unexpectedly'); 25 finishJSTest(); 26 }); 27 window.setTimeout(denyPermission, 100); 28 29 window.jsTestIsAsync = true; 30 window.successfullyParsed = true; 31