[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> |
Reilly Grant | be310ab | 2017-07-11 01:51:26 | [diff] [blame] | 5 | <script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script> |
| 6 | <script src="file:///gen/device/geolocation/public/interfaces/geolocation.mojom.js"></script> |
Julie Jeongeun Kim | 162c2d28 | 2019-03-13 07:23:52 | [diff] [blame] | 7 | <script src="file:///gen/third_party/blink/public/mojom/geolocation/geolocation_service.mojom.js"></script> |
| 8 | <script src="file:///gen/third_party/blink/public/mojom/permissions/permission.mojom.js"></script> |
sammc | e668780 | 2016-05-13 04:06:57 | [diff] [blame] | 9 | <script src="resources/geolocation-mock.js"></script> |
[email protected] | 344a13d | 2010-08-16 12:30:05 | [diff] [blame] | 10 | </head> |
| 11 | <body> |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 12 | <script> |
| 13 | 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."); |
| 14 | |
| 15 | var error; |
| 16 | var iframe = document.createElement('iframe'); |
| 17 | |
| 18 | function onIframeLoaded() { |
| 19 | iframeGeolocation = iframe.contentWindow.navigator.geolocation; |
| 20 | iframeGeolocation.getCurrentPosition(function() { |
| 21 | testFailed('Success callback invoked unexpectedly'); |
| 22 | finishJSTest(); |
| 23 | }, function(e) { |
| 24 | error = e; |
| 25 | shouldBe('error.code', 'error.PERMISSION_DENIED'); |
| 26 | shouldBe('error.message', '"User denied Geolocation"'); |
| 27 | debug(''); |
| 28 | iframe.src = 'data:text/html,This frame should be visible when the test completes'; |
Maxim Kolosovskiy | 2291dbc | 2017-12-08 10:48:54 | [diff] [blame] | 29 | }); |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | function onIframeUnloaded() { |
| 33 | // Make another request, with permission already denied. |
| 34 | iframeGeolocation.getCurrentPosition(function () { |
| 35 | testFailed('Success callback invoked unexpectedly'); |
| 36 | finishJSTest(); |
| 37 | }, function(e) { |
| 38 | testFailed('Error callback invoked unexpectedly'); |
| 39 | finishJSTest(); |
Maxim Kolosovskiy | 2291dbc | 2017-12-08 10:48:54 | [diff] [blame] | 40 | }); |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 41 | setTimeout(function() { |
| 42 | testPassed('No callbacks invoked'); |
| 43 | finishJSTest(); |
| 44 | }, 100); |
| 45 | } |
| 46 | |
| 47 | |
Reilly Grant | be310ab | 2017-07-11 01:51:26 | [diff] [blame] | 48 | // Prime the Geolocation instance by denying permission. This makes sure that we execute the |
| 49 | // same code path for both preemptive and non-preemptive permissions policies. |
| 50 | let mock = geolocationMock; |
| 51 | mock.setGeolocationPermission(false); |
| 52 | mock.setGeolocationPosition(51.478, -0.166, 100); |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 53 | |
Reilly Grant | be310ab | 2017-07-11 01:51:26 | [diff] [blame] | 54 | iframe.src = 'resources/disconnected-frame-inner.html'; |
| 55 | document.body.appendChild(iframe); |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 56 | |
| 57 | window.jsTestIsAsync = true; |
| 58 | </script> |
[email protected] | 344a13d | 2010-08-16 12:30:05 | [diff] [blame] | 59 | </body> |
| 60 | </html> |