Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/timestamp.js

Issue 2667393002: Stop using script-tests in fast/dom/. (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698