| OLD | NEW |
| 1 description("Tests that when timeout is non-zero, the success callback is called
as expected."); | 1 description("Tests that when timeout is non-zero, the success callback is called
as expected."); |
| 2 | 2 |
| 3 var mockLatitude = 51.478; | 3 var mockLatitude = 51.478; |
| 4 var mockLongitude = -0.166; | 4 var mockLongitude = -0.166; |
| 5 var mockAccuracy = 100.0; | 5 var mockAccuracy = 100.0; |
| 6 | 6 |
| 7 if (!window.testRunner || !window.mojo) | |
| 8 debug('This test can not run without testRunner or mojo'); | |
| 9 | |
| 10 var position; | 7 var position; |
| 11 | 8 |
| 12 geolocationServiceMock.then(mock => { | 9 geolocationServiceMock.then(mock => { |
| 13 mock.setGeolocationPermission(true); | 10 mock.setGeolocationPermission(true); |
| 14 mock.setGeolocationPosition(mockLatitude, | 11 mock.setGeolocationPosition(mockLatitude, |
| 15 mockLongitude, | 12 mockLongitude, |
| 16 mockAccuracy); | 13 mockAccuracy); |
| 17 | 14 |
| 18 navigator.geolocation.getCurrentPosition(function(p) { | 15 navigator.geolocation.getCurrentPosition(function(p) { |
| 19 position = p; | 16 position = p; |
| 20 shouldBe('position.coords.latitude', 'mockLatitude'); | 17 shouldBe('position.coords.latitude', 'mockLatitude'); |
| 21 shouldBe('position.coords.longitude', 'mockLongitude'); | 18 shouldBe('position.coords.longitude', 'mockLongitude'); |
| 22 shouldBe('position.coords.accuracy', 'mockAccuracy'); | 19 shouldBe('position.coords.accuracy', 'mockAccuracy'); |
| 23 finishJSTest(); | 20 finishJSTest(); |
| 24 }, function(e) { | 21 }, function(e) { |
| 25 testFailed('Error callback invoked unexpectedly'); | 22 testFailed('Error callback invoked unexpectedly'); |
| 26 finishJSTest(); | 23 finishJSTest(); |
| 27 }, { | 24 }, { |
| 28 timeout: 1000 | 25 timeout: 1000 |
| 29 }); | 26 }); |
| 30 }); | 27 }); |
| 31 | 28 |
| 32 window.jsTestIsAsync = true; | 29 window.jsTestIsAsync = true; |
| OLD | NEW |