1description("Tests that when Geolocation permission has been denied prior to a call to a Geolocation method, the error callback is invoked with code PERMISSION_DENIED, when the Geolocation service encounters an error."); 2 3// Prime the Geolocation instance by denying permission. 4window.layoutTestController.setGeolocationPermission(false); 5window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100); 6 7var error; 8navigator.geolocation.getCurrentPosition(function(p) { 9 testFailed('Success callback invoked unexpectedly'); 10 window.layoutTestController.notifyDone(); 11}, function(e) { 12 error = e 13 shouldBe('error.code', 'error.PERMISSION_DENIED'); 14 shouldBe('error.message', '"User denied Geolocation"'); 15 debug(''); 16 continueTest(); 17}); 18 19function continueTest() 20{ 21 // Make another request, with permission already denied. 22 window.layoutTestController.setMockGeolocationError(0, 'test'); 23 24 navigator.geolocation.getCurrentPosition(function(p) { 25 testFailed('Success callback invoked unexpectedly'); 26 window.layoutTestController.notifyDone(); 27 }, function(e) { 28 error = e 29 shouldBe('error.code', 'error.PERMISSION_DENIED'); 30 shouldBe('error.message', '"User denied Geolocation"'); 31 debug('<br /><span class="pass">TEST COMPLETE</span>'); 32 window.layoutTestController.notifyDone(); 33 }); 34} 35window.layoutTestController.waitUntilDone(); 36 37var isAsynchronous = true; 38var successfullyParsed = true; 39