| OLD | NEW |
| (Empty) |
| 1 description("Tests that reentrant calls to Geolocation methods from the success
callback are OK."); | |
| 2 | |
| 3 var mockLatitude = 51.478; | |
| 4 var mockLongitude = -0.166; | |
| 5 var mockAccuracy = 100.0; | |
| 6 | |
| 7 var position; | |
| 8 | |
| 9 geolocationServiceMock.then(mock => { | |
| 10 mock.setGeolocationPermission(true); | |
| 11 mock.setGeolocationPosition(mockLatitude, | |
| 12 mockLongitude, | |
| 13 mockAccuracy); | |
| 14 | |
| 15 var successCallbackInvoked = false; | |
| 16 navigator.geolocation.getCurrentPosition(function(p) { | |
| 17 if (successCallbackInvoked) { | |
| 18 testFailed('Success callback invoked unexpectedly'); | |
| 19 finishJSTest(); | |
| 20 } | |
| 21 successCallbackInvoked = true; | |
| 22 | |
| 23 position = p; | |
| 24 shouldBe('position.coords.latitude', 'mockLatitude'); | |
| 25 shouldBe('position.coords.longitude', 'mockLongitude'); | |
| 26 shouldBe('position.coords.accuracy', 'mockAccuracy'); | |
| 27 debug(''); | |
| 28 continueTest(); | |
| 29 }, function(e) { | |
| 30 testFailed('Error callback invoked unexpectedly'); | |
| 31 finishJSTest(); | |
| 32 }); | |
| 33 | |
| 34 function continueTest() { | |
| 35 mock.setGeolocationPosition(++mockLatitude, | |
| 36 ++mockLongitude, | |
| 37 ++mockAccuracy); | |
| 38 | |
| 39 navigator.geolocation.getCurrentPosition(function(p) { | |
| 40 position = p; | |
| 41 shouldBe('position.coords.latitude', 'mockLatitude'); | |
| 42 shouldBe('position.coords.longitude', 'mockLongitude'); | |
| 43 shouldBe('position.coords.accuracy', 'mockAccuracy'); | |
| 44 finishJSTest(); | |
| 45 }, function(e) { | |
| 46 testFailed('Error callback invoked unexpectedly'); | |
| 47 finishJSTest(); | |
| 48 }); | |
| 49 } | |
| 50 }); | |
| 51 | |
| 52 window.jsTestIsAsync = true; | |
| OLD | NEW |