Home | History | Annotate | Download | only in script-tests
      1 description("Tests that when a request is made on a Geolocation object, permission is denied and its Frame is disconnected before a callback is made, the error callback is invoked with PERMISSION_DENIED.");
      2 
      3 // Prime the Geolocation instance by denying permission. This makes sure that we execute the
      4 // same code path for both preemptive and non-preemtive permissions policies.
      5 if (window.layoutTestController) {
      6     layoutTestController.setGeolocationPermission(false);
      7     layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100);
      8 } else
      9     debug('This test can not be run without the LayoutTestController');
     10 
     11 var error;
     12 function onIframeLoaded() {
     13     iframeGeolocation = iframe.contentWindow.navigator.geolocation;
     14     iframeGeolocation.getCurrentPosition(function() {
     15         testFailed('Success callback invoked unexpectedly');
     16         finishJSTest();
     17     }, function(e) {
     18         error = e;
     19         shouldBe('error.code', 'error.PERMISSION_DENIED');
     20         shouldBe('error.message', '"User denied Geolocation"');
     21         debug('');
     22         iframe.src = 'data:text/html,This frame should be visible when the test completes';
     23     });
     24 }
     25 
     26 function onIframeUnloaded() {
     27     // Make another request, with permission already denied.
     28     iframeGeolocation.getCurrentPosition(function () {
     29         testFailed('Success callback invoked unexpectedly');
     30         finishJSTest();
     31     }, function(e) {
     32         error = e;
     33         shouldBe('error.code', 'error.PERMISSION_DENIED');
     34         shouldBe('error.message', '"User denied Geolocation"');
     35         debug('');
     36         finishJSTest();
     37     });
     38 }
     39 
     40 var iframe = document.createElement('iframe');
     41 iframe.src = 'resources/disconnected-frame-inner.html';
     42 document.body.appendChild(iframe);
     43 
     44 window.jsTestIsAsync = true;
     45 window.successfullyParsed = true;
     46