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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/watch.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 watchPosition correctly reports position updates and err ors from the Geolocation service."); 1 description("Tests that watchPosition correctly reports position updates and err ors from the Geolocation service.");
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 mockMessage = 'test'; 7 var mockMessage = 'test';
8 8
9 var position; 9 var position;
10 var error; 10 var error;
11 11
12 function checkPosition(p) { 12 function checkPosition(p) {
13 position = p; 13 position = p;
14 shouldBe('position.coords.latitude', 'mockLatitude'); 14 shouldBe('position.coords.latitude', 'mockLatitude');
15 shouldBe('position.coords.longitude', 'mockLongitude'); 15 shouldBe('position.coords.longitude', 'mockLongitude');
16 shouldBe('position.coords.accuracy', 'mockAccuracy'); 16 shouldBe('position.coords.accuracy', 'mockAccuracy');
17 debug(''); 17 debug('');
18 } 18 }
19 19
20 function checkError(e) { 20 function checkError(e) {
21 error = e; 21 error = e;
22 shouldBe('error.code', 'error.POSITION_UNAVAILABLE'); 22 shouldBe('error.code', 'error.POSITION_UNAVAILABLE');
23 shouldBe('error.message', 'mockMessage'); 23 shouldBe('error.message', 'mockMessage');
24 debug(''); 24 debug('');
25 } 25 }
26 26
27 if (!window.testRunner || !window.mojo)
28 debug('This test can not run without testRunner or mojo');
29
30 geolocationServiceMock.then(mock => { 27 geolocationServiceMock.then(mock => {
31 mock.setGeolocationPermission(true); 28 mock.setGeolocationPermission(true);
32 mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy); 29 mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy);
33 30
34 var state = 0; 31 var state = 0;
35 navigator.geolocation.watchPosition(function(p) { 32 navigator.geolocation.watchPosition(function(p) {
36 switch (state++) { 33 switch (state++) {
37 case 0: 34 case 0:
38 checkPosition(p); 35 checkPosition(p);
39 mock.setGeolocationPosition(++mockLatitude, ++mockLongitude, ++m ockAccuracy); 36 mock.setGeolocationPosition(++mockLatitude, ++mockLongitude, ++m ockAccuracy);
(...skipping 17 matching lines...) Expand all
57 mock.setGeolocationPosition(++mockLatitude, ++mockLongitude, ++m ockAccuracy); 54 mock.setGeolocationPosition(++mockLatitude, ++mockLongitude, ++m ockAccuracy);
58 break; 55 break;
59 default: 56 default:
60 testFailed('Error callback invoked unexpectedly'); 57 testFailed('Error callback invoked unexpectedly');
61 finishJSTest(); 58 finishJSTest();
62 } 59 }
63 }); 60 });
64 }); 61 });
65 62
66 window.jsTestIsAsync = true; 63 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698