Home | History | Annotate | Download | only in resources
      1 description("Tests that when Geolocation permission has been denied prior to a call to watchPosition, and the watch is cleared in the error callback, there is no crash. This a regression test for https://bugs.webkit.org/show_bug.cgi?id=32111.");
      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     var watchId = navigator.geolocation.watchPosition(function(p) {
     23         testFailed('Success callback invoked unexpectedly');
     24         window.layoutTestController.notifyDone();
     25     }, function(e) {
     26         error = e
     27         shouldBe('error.code', 'error.PERMISSION_DENIED');
     28         shouldBe('error.message', '"User denied Geolocation"');
     29         navigator.geolocation.clearWatch(watchId);
     30         window.setTimeout(completeTest, 0);
     31     });
     32 }
     33 
     34 function completeTest()
     35 {
     36     debug('<br /><span class="pass">TEST COMPLETE</span>');
     37     window.layoutTestController.notifyDone();
     38 }
     39 window.layoutTestController.waitUntilDone();
     40 
     41 var isAsynchronous = true;
     42 var successfullyParsed = true;
     43