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, no callbacks are made.");
3 if (!window.testRunner || !window.internals)
4 debug('This test can not run without testRunner or internals');
6 internals.setGeolocationClientMock(document);
8 // Prime the Geolocation instance by denying permission. This makes sure that we execute the
9 // same code path for both preemptive and non-preemptive permissions policies.
10 internals.setGeolocationPermission(document, false);
11 internals.setGeolocationPosition(document, 51.478, -0.166, 100);
14 function onIframeLoaded() {
15 iframeGeolocation = iframe.contentWindow.navigator.geolocation;
16 iframeGeolocation.getCurrentPosition(function() {
17 testFailed('Success callback invoked unexpectedly');
21 shouldBe('error.code', 'error.PERMISSION_DENIED');
22 shouldBe('error.message', '"User denied Geolocation"');
24 iframe.src = 'data:text/html,This frame should be visible when the test completes';
28 function onIframeUnloaded() {
29 // Make another request, with permission already denied.
30 iframeGeolocation.getCurrentPosition(function () {
31 testFailed('Success callback invoked unexpectedly');
34 testFailed('Error callback invoked unexpectedly');
37 setTimeout(function() {
38 testPassed('No callbacks invoked');
43 var iframe = document.createElement('iframe');
44 iframe.src = 'resources/disconnected-frame-inner.html';
45 document.body.appendChild(iframe);
47 window.jsTestIsAsync = true;