| OLD | NEW |
| (Empty) |
| 1 description("Tests that Geoposition timestamps are well-formed (non-zero and in
the same units as Date.getTime)."); | |
| 2 | |
| 3 var mockLatitude = 51.478; | |
| 4 var mockLongitude = -0.166; | |
| 5 var mockAccuracy = 100.0; | |
| 6 | |
| 7 var now = new Date().getTime(); | |
| 8 shouldBeTrue('now != 0'); | |
| 9 var t = null; | |
| 10 var then = null; | |
| 11 | |
| 12 geolocationServiceMock.then(mock => { | |
| 13 mock.setGeolocationPermission(true); | |
| 14 mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy); | |
| 15 | |
| 16 function checkPosition(p) { | |
| 17 t = p.timestamp; | |
| 18 var d = new Date(); | |
| 19 then = d.getTime(); | |
| 20 shouldBeTrue('t != 0'); | |
| 21 shouldBeTrue('then != 0'); | |
| 22 shouldBeTrue('now - 1 <= t'); // Avoid rounding errors | |
| 23 if (now - 1 > t) { | |
| 24 debug(" now - 1 = " + (now-1)); | |
| 25 debug(" t = " + t); | |
| 26 } | |
| 27 shouldBeTrue('t <= then + 1'); // Avoid rounding errors | |
| 28 finishJSTest(); | |
| 29 } | |
| 30 | |
| 31 navigator.geolocation.getCurrentPosition(checkPosition); | |
| 32 }); | |
| 33 window.jsTestIsAsync = true; | |
| OLD | NEW |