Home | History | Annotate | Download | only in script-tests
      1 description("Tests that when Geolocation permission is denied, watches are stopped, as well as one-shots.");
      2 
      3 // Configure the mock Geolocation service to report a position to cause permission
      4 // to be requested, then deny it.
      5 if (window.layoutTestController) {
      6     layoutTestController.setGeolocationPermission(false);
      7     layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100.0);
      8 } else
      9     debug('This test can not be run without the LayoutTestController');
     10 
     11 var error;
     12 var errorCallbackInvoked = false;
     13 navigator.geolocation.watchPosition(function(p) {
     14     testFailed('Success callback invoked unexpectedly');
     15     finishJSTest();
     16 }, function(e) {
     17     if (errorCallbackInvoked) {
     18         testFailed('Error callback invoked unexpectedly : ' + error.message);
     19         finishJSTest();
     20     }
     21     errorCallbackInvoked = true;
     22 
     23     error = e;
     24     shouldBe('error.code', 'error.PERMISSION_DENIED');
     25     shouldBe('error.message', '"User denied Geolocation"');
     26 
     27     // Update the mock Geolocation service to report a new position, then
     28     // yield to allow a chance for the success callback to be invoked.
     29     if (window.layoutTestController)
     30         layoutTestController.setMockGeolocationPosition(55.478, -0.166, 100);
     31     window.setTimeout(finishJSTest, 0);
     32 });
     33 
     34 
     35 window.jsTestIsAsync = true;
     36 window.successfullyParsed = true;
     37