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