| <!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/blink/public/mojom/geolocation/geolocation_service.mojom.js"></script> |
| <script src="file:///gen/third_party/blink/public/mojom/permissions/permission.mojom.js"></script> |
| <script src="resources/geolocation-mock.js"></script> |
| </head> |
| <body> |
| <script> |
| description("Tests that reentrant calls to Geolocation methods from the error callback due to a PERMISSION_DENIED error are OK."); |
| |
| var error; |
| |
| let mock = geolocationMock; |
| mock.setGeolocationPermission(false); |
| mock.setGeolocationPosition(51.478, -0.166, 100.0); |
| |
| function checkPermissionError(e) { |
| error = e; |
| shouldBe('error.code', 'error.PERMISSION_DENIED'); |
| shouldBe('error.message', '"User denied Geolocation"'); |
| } |
| |
| var errorCallbackInvoked = false; |
| navigator.geolocation.getCurrentPosition(function(p) { |
| testFailed('Success callback invoked unexpectedly'); |
| finishJSTest(); |
| }, function(e) { |
| if (errorCallbackInvoked) { |
| testFailed('Error callback invoked unexpectedly'); |
| finishJSTest(); |
| } |
| errorCallbackInvoked = true; |
| checkPermissionError(e); |
| continueTest(); |
| }); |
| |
| function continueTest() { |
| navigator.geolocation.getCurrentPosition(function(p) { |
| testFailed('Success callback invoked unexpectedly'); |
| finishJSTest(); |
| }, function(e) { |
| checkPermissionError(e); |
| finishJSTest(); |
| }); |
| } |
| |
| window.jsTestIsAsync = true; |
| </script> |
| </body> |
| </html> |