| OLD | NEW |
| 1 description("Tests formatting of position.toString()."); | 1 description("Tests formatting of position.toString()."); |
| 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 // shouldBe can't use local variables yet. | 16 // shouldBe can't use local variables yet. |
| 20 position = p; | 17 position = p; |
| 21 shouldBe('position.coords.latitude', 'mockLatitude'); | 18 shouldBe('position.coords.latitude', 'mockLatitude'); |
| 22 shouldBe('position.coords.longitude', 'mockLongitude'); | 19 shouldBe('position.coords.longitude', 'mockLongitude'); |
| 23 shouldBe('position.coords.accuracy', 'mockAccuracy'); | 20 shouldBe('position.coords.accuracy', 'mockAccuracy'); |
| 24 shouldBe('position.toString()', '"[object Geoposition]"'); | 21 shouldBe('position.toString()', '"[object Geoposition]"'); |
| 25 shouldBe('position.coords.toString()', '"[object Coordinates]"'); | 22 shouldBe('position.coords.toString()', '"[object Coordinates]"'); |
| 26 finishJSTest(); | 23 finishJSTest(); |
| 27 }, function(e) { | 24 }, function(e) { |
| 28 testFailed('Error callback invoked unexpectedly'); | 25 testFailed('Error callback invoked unexpectedly'); |
| 29 finishJSTest(); | 26 finishJSTest(); |
| 30 }); | 27 }); |
| 31 }); | 28 }); |
| 32 | 29 |
| 33 window.jsTestIsAsync = true; | 30 window.jsTestIsAsync = true; |
| OLD | NEW |