[email protected] | df7846b | 2009-09-09 16:27:32 | [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] | df7846b | 2009-09-09 16:27:32 | [diff] [blame] | 10 | </head> |
| 11 | <body> |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 12 | <script> |
| 13 | description("Tests that when an exception is thrown in the success callback, the error callback is not invoked. Note that this test throws an exception which is not caught."); |
| 14 | |
| 15 | var mockLatitude = 51.478; |
| 16 | var mockLongitude = -0.166; |
| 17 | var mockAccuracy = 100; |
| 18 | |
| 19 | var position; |
| 20 | |
Reilly Grant | be310ab | 2017-07-11 01:51:26 | [diff] [blame] | 21 | let mock = geolocationMock; |
| 22 | mock.setGeolocationPermission(true); |
| 23 | mock.setGeolocationPosition(mockLatitude, |
| 24 | mockLongitude, |
| 25 | mockAccuracy); |
| 26 | navigator.geolocation.getCurrentPosition(function(p) { |
| 27 | position = p; |
| 28 | shouldBe('position.coords.latitude', 'mockLatitude'); |
| 29 | shouldBe('position.coords.longitude', 'mockLongitude'); |
| 30 | shouldBe('position.coords.accuracy', 'mockAccuracy'); |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 31 | |
Reilly Grant | be310ab | 2017-07-11 01:51:26 | [diff] [blame] | 32 | // Yield to allow for the error callback to be invoked. The timer |
| 33 | // must be started before the exception is thrown. |
| 34 | window.setTimeout(assertWeGotException, 0); |
| 35 | expectError(); |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 36 | |
Reilly Grant | be310ab | 2017-07-11 01:51:26 | [diff] [blame] | 37 | throw new Error('Exception in success callback'); |
| 38 | }, function(e) { |
| 39 | testFailed('Error callback invoked unexpectedly'); |
| 40 | finishJSTest(); |
Maxim Kolosovskiy | 2291dbc | 2017-12-08 10:48:54 | [diff] [blame] | 41 | }); |
tkent | 98122ee | 2017-02-02 07:38:51 | [diff] [blame] | 42 | |
| 43 | function assertWeGotException() |
| 44 | { |
| 45 | shouldHaveHadError(); |
| 46 | finishJSTest(); |
| 47 | } |
| 48 | |
| 49 | window.jsTestIsAsync = true; |
| 50 | </script> |
[email protected] | df7846b | 2009-09-09 16:27:32 | [diff] [blame] | 51 | </body> |
| 52 | </html> |