[email protected] | 344a13d | 2010-08-16 12:30:05 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 | <html> |
| 3 | <head> |
tkent | c5e88f0 | 2017-02-06 22:47:31 | [diff] [blame^] | 4 | <script src="../resources/js-test.js"></script> |
| 5 | <script src="../resources/mojo-helpers.js"></script> |
sammc | e668780 | 2016-05-13 04:06:57 | [diff] [blame] | 6 | <script src="resources/geolocation-mock.js"></script> |
[email protected] | 344a13d | 2010-08-16 12:30:05 | [diff] [blame] | 7 | </head> |
| 8 | <body> |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 9 | <script> |
| 10 | 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."); |
| 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 that we execute the |
| 47 | // same code path for both preemptive and non-preemptive permissions policies. |
| 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> |
[email protected] | 344a13d | 2010-08-16 12:30:05 | [diff] [blame] | 57 | </body> |
| 58 | </html> |