| OLD | NEW |
| (Empty) |
| 1 description("Tests that when a request is made on a Geolocation object, permissi
on is denied and its Frame is disconnected before a callback is made, no callbac
ks are made."); | |
| 2 | |
| 3 var error; | |
| 4 var iframe = document.createElement('iframe'); | |
| 5 | |
| 6 function onIframeLoaded() { | |
| 7 iframeGeolocation = iframe.contentWindow.navigator.geolocation; | |
| 8 iframeGeolocation.getCurrentPosition(function() { | |
| 9 testFailed('Success callback invoked unexpectedly'); | |
| 10 finishJSTest(); | |
| 11 }, function(e) { | |
| 12 error = e; | |
| 13 shouldBe('error.code', 'error.PERMISSION_DENIED'); | |
| 14 shouldBe('error.message', '"User denied Geolocation"'); | |
| 15 debug(''); | |
| 16 iframe.src = 'data:text/html,This frame should be visible when the test
completes'; | |
| 17 }); | |
| 18 } | |
| 19 | |
| 20 function onIframeUnloaded() { | |
| 21 // Make another request, with permission already denied. | |
| 22 iframeGeolocation.getCurrentPosition(function () { | |
| 23 testFailed('Success callback invoked unexpectedly'); | |
| 24 finishJSTest(); | |
| 25 }, function(e) { | |
| 26 testFailed('Error callback invoked unexpectedly'); | |
| 27 finishJSTest(); | |
| 28 }); | |
| 29 setTimeout(function() { | |
| 30 testPassed('No callbacks invoked'); | |
| 31 finishJSTest(); | |
| 32 }, 100); | |
| 33 } | |
| 34 | |
| 35 | |
| 36 geolocationServiceMock.then(mock => { | |
| 37 // Prime the Geolocation instance by denying permission. This makes sure tha
t we execute the | |
| 38 // same code path for both preemptive and non-preemptive permissions policie
s. | |
| 39 mock.setGeolocationPermission(false); | |
| 40 mock.setGeolocationPosition(51.478, -0.166, 100); | |
| 41 | |
| 42 iframe.src = 'resources/disconnected-frame-inner.html'; | |
| 43 document.body.appendChild(iframe); | |
| 44 }); | |
| 45 | |
| 46 window.jsTestIsAsync = true; | |
| OLD | NEW |