[email protected] | 9349c56 | 2010-08-04 11:13:20 | [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> |
| 7 | <script src="file:///gen/third_party/WebKit/public/platform/modules/permissions/permission.mojom.js"></script> |
sammc | e668780 | 2016-05-13 04:06:57 | [diff] [blame] | 8 | <script src="resources/geolocation-mock.js"></script> |
[email protected] | 9349c56 | 2010-08-04 11:13:20 | [diff] [blame] | 9 | </head> |
| 10 | <body> |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 11 | <script> |
| 12 | description("Tests that when a position is available, no callbacks are invoked until permission is allowed."); |
| 13 | |
Reilly Grant | be310ab | 2017-07-11 01:51:26 | [diff] [blame] | 14 | let mock = geolocationMock; |
| 15 | mock.setGeolocationPosition(51.478, -0.166, 100); |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 16 | |
Reilly Grant | be310ab | 2017-07-11 01:51:26 | [diff] [blame] | 17 | var permissionSet = false; |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 18 | |
Reilly Grant | be310ab | 2017-07-11 01:51:26 | [diff] [blame] | 19 | function allowPermission() { |
| 20 | permissionSet = true; |
| 21 | mock.setGeolocationPermission(true); |
| 22 | } |
| 23 | |
| 24 | navigator.geolocation.getCurrentPosition(function() { |
| 25 | if (permissionSet) { |
| 26 | testPassed('Success callback invoked'); |
| 27 | finishJSTest(); |
| 28 | return; |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 29 | } |
Reilly Grant | be310ab | 2017-07-11 01:51:26 | [diff] [blame] | 30 | testFailed('Success callback invoked unexpectedly'); |
| 31 | finishJSTest(); |
| 32 | }, function() { |
| 33 | testFailed('Error callback invoked unexpectedly'); |
| 34 | finishJSTest(); |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 35 | }); |
Reilly Grant | be310ab | 2017-07-11 01:51:26 | [diff] [blame] | 36 | window.setTimeout(allowPermission, 100); |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 37 | |
| 38 | window.jsTestIsAsync = true; |
| 39 | </script> |
[email protected] | 9349c56 | 2010-08-04 11:13:20 | [diff] [blame] | 40 | </body> |
| 41 | </html> |