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