| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../resources/js-test.js"></script> |
| <script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script> |
| <script src="file:///gen/device/geolocation/public/interfaces/geolocation.mojom.js"></script> |
| <script src="file:///gen/third_party/WebKit/public/platform/modules/permissions/permission.mojom.js"></script> |
| <script src="resources/geolocation-mock.js"></script> |
| </head> |
| <body> |
| <script> |
| description("Tests that when a position is available, no callbacks are invoked until permission is allowed."); |
| |
| let mock = geolocationMock; |
| mock.setGeolocationPosition(51.478, -0.166, 100); |
| |
| var permissionSet = false; |
| |
| function allowPermission() { |
| permissionSet = true; |
| mock.setGeolocationPermission(true); |
| } |
| |
| navigator.geolocation.getCurrentPosition(function() { |
| if (permissionSet) { |
| testPassed('Success callback invoked'); |
| finishJSTest(); |
| return; |
| } |
| testFailed('Success callback invoked unexpectedly'); |
| finishJSTest(); |
| }, function() { |
| testFailed('Error callback invoked unexpectedly'); |
| finishJSTest(); |
| }); |
| window.setTimeout(allowPermission, 100); |
| |
| window.jsTestIsAsync = true; |
| </script> |
| </body> |
| </html> |