| <!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/geolocation/geolocation_service.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 Geolocation permission is denied, watches are stopped, as well as one-shots."); |
| |
| var error; |
| |
| // Configure the mock Geolocation service to report a position to cause permission |
| // to be requested, then deny it. |
| let mock = geolocationMock; |
| mock.setGeolocationPermission(false); |
| mock.setGeolocationPosition(51.478, -0.166, 100.0); |
| |
| var errorCallbackInvoked = false; |
| navigator.geolocation.watchPosition(function(p) { |
| testFailed('Success callback invoked unexpectedly'); |
| finishJSTest(); |
| }, function(e) { |
| if (errorCallbackInvoked) { |
| testFailed('Error callback invoked unexpectedly : ' + error.message); |
| finishJSTest(); |
| } |
| errorCallbackInvoked = true; |
| |
| error = e; |
| shouldBe('error.code', 'error.PERMISSION_DENIED'); |
| shouldBe('error.message', '"User denied Geolocation"'); |
| |
| // Update the mock Geolocation service to report a new position, then |
| // yield to allow a chance for the success callback to be invoked. |
| mock.setGeolocationPosition(55.478, -0.166, 100); |
| window.setTimeout(finishJSTest, 0); |
| }); |
| |
| window.jsTestIsAsync = true; |
| </script> |
| </body> |
| </html> |