| OLD | NEW |
| 1 description("Tests Geolocation success callback using the mock service."); | 1 description("Tests Geolocation success callback using the mock service."); |
| 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; | 5 var mockAccuracy = 100; |
| 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 }); | 25 }); |
| 29 | 26 |
| 30 window.jsTestIsAsync = true; | 27 window.jsTestIsAsync = true; |
| OLD | NEW |