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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/watch.html

Issue 2671933003: Move Geolocation out from 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 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 <script src="../../../resources/mojo-helpers.js"></script>
6 <script src="resources/geolocation-mock.js"></script>
7 </head>
8 <body>
9 <script>
10 description("Tests that watchPosition correctly reports position updates and err ors from the Geolocation service.");
11
12 var mockLatitude = 51.478;
13 var mockLongitude = -0.166;
14 var mockAccuracy = 100.0;
15
16 var mockMessage = 'test';
17
18 var position;
19 var error;
20
21 function checkPosition(p) {
22 position = p;
23 shouldBe('position.coords.latitude', 'mockLatitude');
24 shouldBe('position.coords.longitude', 'mockLongitude');
25 shouldBe('position.coords.accuracy', 'mockAccuracy');
26 debug('');
27 }
28
29 function checkError(e) {
30 error = e;
31 shouldBe('error.code', 'error.POSITION_UNAVAILABLE');
32 shouldBe('error.message', 'mockMessage');
33 debug('');
34 }
35
36 geolocationServiceMock.then(mock => {
37 mock.setGeolocationPermission(true);
38 mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy);
39
40 var state = 0;
41 navigator.geolocation.watchPosition(function(p) {
42 switch (state++) {
43 case 0:
44 checkPosition(p);
45 mock.setGeolocationPosition(++mockLatitude, ++mockLongitude, ++m ockAccuracy);
46 break;
47 case 1:
48 checkPosition(p);
49 mock.setGeolocationPositionUnavailableError(mockMessage);
50 break;
51 case 3:
52 checkPosition(p);
53 finishJSTest();
54 break;
55 default:
56 testFailed('Success callback invoked unexpectedly');
57 finishJSTest();
58 }
59 }, function(e) {
60 switch (state++) {
61 case 2:
62 checkError(e);
63 mock.setGeolocationPosition(++mockLatitude, ++mockLongitude, ++m ockAccuracy);
64 break;
65 default:
66 testFailed('Error callback invoked unexpectedly');
67 finishJSTest();
68 }
69 });
70 });
71
72 window.jsTestIsAsync = true;
73 </script>
74 </body>
75 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698