Home | History | Annotate | Download | only in resources
      1 description("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.
      4 window.layoutTestController.setGeolocationPermission(false);
      5 window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100);
      6 
      7 var error;
      8 navigator.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 
     19 function 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 }
     35 window.layoutTestController.waitUntilDone();
     36 
     37 var isAsynchronous = true;
     38 var successfullyParsed = true;
     39