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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/watch.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 watchPosition correctly reports position updates and err ors from the Geolocation service.");
2
3 var mockLatitude = 51.478;
4 var mockLongitude = -0.166;
5 var mockAccuracy = 100.0;
6
7 var mockMessage = 'test';
8
9 var position;
10 var error;
11
12 function checkPosition(p) {
13 position = p;
14 shouldBe('position.coords.latitude', 'mockLatitude');
15 shouldBe('position.coords.longitude', 'mockLongitude');
16 shouldBe('position.coords.accuracy', 'mockAccuracy');
17 debug('');
18 }
19
20 function checkError(e) {
21 error = e;
22 shouldBe('error.code', 'error.POSITION_UNAVAILABLE');
23 shouldBe('error.message', 'mockMessage');
24 debug('');
25 }
26
27 geolocationServiceMock.then(mock => {
28 mock.setGeolocationPermission(true);
29 mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy);
30
31 var state = 0;
32 navigator.geolocation.watchPosition(function(p) {
33 switch (state++) {
34 case 0:
35 checkPosition(p);
36 mock.setGeolocationPosition(++mockLatitude, ++mockLongitude, ++m ockAccuracy);
37 break;
38 case 1:
39 checkPosition(p);
40 mock.setGeolocationPositionUnavailableError(mockMessage);
41 break;
42 case 3:
43 checkPosition(p);
44 finishJSTest();
45 break;
46 default:
47 testFailed('Success callback invoked unexpectedly');
48 finishJSTest();
49 }
50 }, function(e) {
51 switch (state++) {
52 case 2:
53 checkError(e);
54 mock.setGeolocationPosition(++mockLatitude, ++mockLongitude, ++m ockAccuracy);
55 break;
56 default:
57 testFailed('Error callback invoked unexpectedly');
58 finishJSTest();
59 }
60 });
61 });
62
63 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698