| OLD | NEW |
| 1 description("Tests that Geoposition timestamps are well-formed (non-zero and in
the same units as Date.getTime)."); | 1 description("Tests that Geoposition timestamps are well-formed (non-zero and in
the same units as Date.getTime)."); |
| 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 var now = new Date().getTime(); | 7 var now = new Date().getTime(); |
| 8 shouldBeTrue('now != 0'); | 8 shouldBeTrue('now != 0'); |
| 9 var t = null; | 9 var t = null; |
| 10 var then = null; | 10 var then = null; |
| 11 | 11 |
| 12 if (!window.testRunner || !window.internals) | 12 if (!window.testRunner || !window.mojo) |
| 13 debug('This test can not run without testRunner or internals'); | 13 debug('This test can not run without testRunner or mojo'); |
| 14 | 14 |
| 15 internals.setGeolocationClientMock(document); | 15 geolocationServiceMock.then(mock => { |
| 16 internals.setGeolocationPermission(document, true); | 16 mock.setGeolocationPermission(true); |
| 17 internals.setGeolocationPosition(document, mockLatitude, mockLongitude, mockAccu
racy); | 17 mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy); |
| 18 | 18 |
| 19 function checkPosition(p) { | 19 function checkPosition(p) { |
| 20 t = p.timestamp; | 20 t = p.timestamp; |
| 21 var d = new Date(); | 21 var d = new Date(); |
| 22 then = d.getTime(); | 22 then = d.getTime(); |
| 23 shouldBeTrue('t != 0'); | 23 shouldBeTrue('t != 0'); |
| 24 shouldBeTrue('then != 0'); | 24 shouldBeTrue('then != 0'); |
| 25 shouldBeTrue('now - 1 <= t'); // Avoid rounding errors | 25 shouldBeTrue('now - 1 <= t'); // Avoid rounding errors |
| 26 if (now - 1 > t) { | 26 if (now - 1 > t) { |
| 27 debug(" now - 1 = " + (now-1)); | 27 debug(" now - 1 = " + (now-1)); |
| 28 debug(" t = " + t); | 28 debug(" t = " + t); |
| 29 } |
| 30 shouldBeTrue('t <= then + 1'); // Avoid rounding errors |
| 31 finishJSTest(); |
| 29 } | 32 } |
| 30 shouldBeTrue('t <= then + 1'); // Avoid rounding errors | |
| 31 finishJSTest(); | |
| 32 } | |
| 33 | 33 |
| 34 navigator.geolocation.getCurrentPosition(checkPosition); | 34 navigator.geolocation.getCurrentPosition(checkPosition); |
| 35 }); |
| 35 window.jsTestIsAsync = true; | 36 window.jsTestIsAsync = true; |
| OLD | NEW |