1 description("Tests that Geoposition timestamps are well-formed (non-zero and in the same units as Date.getTime).");
3 var mockLatitude
= 51.478;
4 var mockLongitude
= -0.166;
5 var mockAccuracy
= 100.0;
7 var now
= new Date().getTime();
8 shouldBeTrue('now != 0');
12 if (!window
.testRunner
|| !window
.internals
)
13 debug('This test can not run without testRunner or internals');
15 internals
.setGeolocationClientMock(document
);
16 internals
.setGeolocationPermission(document
, true);
17 internals
.setGeolocationPosition(document
, mockLatitude
, mockLongitude
, mockAccuracy
);
19 function checkPosition(p
) {
23 shouldBeTrue('t != 0');
24 shouldBeTrue('then != 0');
25 shouldBeTrue('now - 1 <= t'); // Avoid rounding errors
27 debug(" now - 1 = " + (now
-1));
30 shouldBeTrue('t <= then + 1'); // Avoid rounding errors
34 navigator
.geolocation
.getCurrentPosition(checkPosition
);
35 window
.jsTestIsAsync
= true;