| OLD | NEW |
| (Empty) |
| 1 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."); | |
| 2 | |
| 3 var mockLatitude = 51.478; | |
| 4 var mockLongitude = -0.166; | |
| 5 var mockAccuracy = 100; | |
| 6 | |
| 7 var position; | |
| 8 | |
| 9 geolocationServiceMock.then(mock => { | |
| 10 mock.setGeolocationPermission(true); | |
| 11 mock.setGeolocationPosition(mockLatitude, | |
| 12 mockLongitude, | |
| 13 mockAccuracy); | |
| 14 navigator.geolocation.getCurrentPosition(function(p) { | |
| 15 position = p; | |
| 16 shouldBe('position.coords.latitude', 'mockLatitude'); | |
| 17 shouldBe('position.coords.longitude', 'mockLongitude'); | |
| 18 shouldBe('position.coords.accuracy', 'mockAccuracy'); | |
| 19 | |
| 20 // Yield to allow for the error callback to be invoked. The timer | |
| 21 // must be started before the exception is thrown. | |
| 22 window.setTimeout(assertWeGotException, 0); | |
| 23 expectError(); | |
| 24 | |
| 25 throw new Error('Exception in success callback'); | |
| 26 }, function(e) { | |
| 27 testFailed('Error callback invoked unexpectedly'); | |
| 28 finishJSTest(); | |
| 29 }); | |
| 30 }); | |
| 31 | |
| 32 function assertWeGotException() | |
| 33 { | |
| 34 shouldHaveHadError(); | |
| 35 finishJSTest(); | |
| 36 } | |
| 37 | |
| 38 window.jsTestIsAsync = true; | |
| OLD | NEW |