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

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

Issue 2642873002: Moves mojo.define -> gin.define. (Closed)
Patch Set: rebaseline Created 3 years, 11 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
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.mojo)
13 debug('This test can not run without testRunner or mojo');
14
15 geolocationServiceMock.then(mock => { 12 geolocationServiceMock.then(mock => {
16 mock.setGeolocationPermission(true); 13 mock.setGeolocationPermission(true);
17 mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy); 14 mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy);
18 15
19 function checkPosition(p) { 16 function checkPosition(p) {
20 t = p.timestamp; 17 t = p.timestamp;
21 var d = new Date(); 18 var d = new Date();
22 then = d.getTime(); 19 then = d.getTime();
23 shouldBeTrue('t != 0'); 20 shouldBeTrue('t != 0');
24 shouldBeTrue('then != 0'); 21 shouldBeTrue('then != 0');
25 shouldBeTrue('now - 1 <= t'); // Avoid rounding errors 22 shouldBeTrue('now - 1 <= t'); // Avoid rounding errors
26 if (now - 1 > t) { 23 if (now - 1 > t) {
27 debug(" now - 1 = " + (now-1)); 24 debug(" now - 1 = " + (now-1));
28 debug(" t = " + t); 25 debug(" t = " + t);
29 } 26 }
30 shouldBeTrue('t <= then + 1'); // Avoid rounding errors 27 shouldBeTrue('t <= then + 1'); // Avoid rounding errors
31 finishJSTest(); 28 finishJSTest();
32 } 29 }
33 30
34 navigator.geolocation.getCurrentPosition(checkPosition); 31 navigator.geolocation.getCurrentPosition(checkPosition);
35 }); 32 });
36 window.jsTestIsAsync = true; 33 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698