OLD | NEW |
| (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("Test the attribute handling of the Coordinates interface"); | |
11 window.jsTestIsAsync = true; | |
12 | |
13 // Format: [Input], [Expected] | |
14 // Input: latitude, longitude, accuracy, altitude, altitudeAccuracy, heading, sp
eed. | |
15 // Expected: latitude, longitude, accuracy, altitude, altitudeAccuracy, heading,
speed. | |
16 var testSet = [ | |
17 [[1, 2, 3], [1, 2, 3, null, null, null, null]], | |
18 [[2, 3, 4, undefined, undefined, undefined, 5], [2, 3, 4, null, null, null,
5]], | |
19 [[3, 4, 5, undefined, 6, undefined, 7], [3, 4, 5, null, 6, null, 7]], | |
20 [[4, 5, 6, undefined, 7, 8, 9], [4, 5, 6, null, 7, 8, 9]], | |
21 [[5, 6, 7, 8, 9, 10, 11], [5, 6, 7, 8, 9, 10, 11]], | |
22 ]; | |
23 | |
24 var currentTestIndex = -1; | |
25 var globalCoordinates = null; | |
26 | |
27 geolocationServiceMock.then(mock => { | |
28 mock.setGeolocationPermission(true); | |
29 | |
30 function runNextTest() | |
31 { | |
32 ++currentTestIndex; | |
33 mock.setGeolocationPosition(...testSet[currentTestIndex][0]); | |
34 } | |
35 | |
36 function verifyResults() | |
37 { | |
38 shouldBe('globalCoordinates.latitude', 'testSet[currentTestIndex][1][0]'
); | |
39 shouldBe('globalCoordinates.longitude', 'testSet[currentTestIndex][1][1]
'); | |
40 shouldBe('globalCoordinates.accuracy', 'testSet[currentTestIndex][1][2]'
); | |
41 shouldBe('globalCoordinates.altitude', 'testSet[currentTestIndex][1][3]'
); | |
42 shouldBe('globalCoordinates.altitudeAccuracy', 'testSet[currentTestIndex
][1][4]'); | |
43 shouldBe('globalCoordinates.heading', 'testSet[currentTestIndex][1][5]')
; | |
44 shouldBe('globalCoordinates.speed', 'testSet[currentTestIndex][1][6]'); | |
45 debug(''); | |
46 } | |
47 | |
48 var watchId = navigator.geolocation.watchPosition(function(position) { | |
49 globalCoordinates = position.coords; | |
50 verifyResults(); | |
51 | |
52 if (currentTestIndex + 1 === testSet.length) { | |
53 finishJSTest(); | |
54 return; | |
55 } | |
56 runNextTest(); | |
57 }, function(e) { | |
58 debug("Error!: the error callback was called."); | |
59 finishJSTest(); | |
60 }); | |
61 | |
62 runNextTest(); | |
63 }); | |
64 | |
65 </script> | |
66 </body> | |
67 </html> | |
OLD | NEW |