1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../../resources/js-test.js"></script>
8 description("Test the attribute handling of the Coordinates interface");
9 window
.jsTestIsAsync
= true;
11 if (!window
.testRunner
|| !window
.internals
)
12 debug('This test can not run without testRunner or internals');
14 internals
.setGeolocationClientMock(document
);
15 internals
.setGeolocationPermission(document
, true);
17 // Format: [Input], [Expected]
18 // Input: latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed.
19 // Expected: latitude, longitude, accuracy, altitude, altitudeAccuracy, heading, speed.
21 [[1, 2, 3], [1, 2, 3, null, null, null, null]],
22 [[2, 3, 4, undefined, undefined, undefined, 5], [2, 3, 4, null, null, null, 5]],
23 [[3, 4, 5, undefined, 6, undefined, 7], [3, 4, 5, null, 6, null, 7]],
24 [[4, 5, 6, undefined, 7, 8, 9], [4, 5, 6, null, 7, 8, 9]],
25 [[5, 6, 7, 8, 9, 10, 11], [5, 6, 7, 8, 9, 10, 11]],
28 var currentTestIndex
= -1;
29 var globalCoordinates
= null;
31 function runNextTest()
34 internals
.setGeolocationPosition
.apply(internals
, [document
].concat(testSet
[currentTestIndex
][0]));
37 function verifyResults()
39 shouldBe('globalCoordinates.latitude', 'testSet[currentTestIndex][1][0]');
40 shouldBe('globalCoordinates.longitude', 'testSet[currentTestIndex][1][1]');
41 shouldBe('globalCoordinates.accuracy', 'testSet[currentTestIndex][1][2]');
42 shouldBe('globalCoordinates.altitude', 'testSet[currentTestIndex][1][3]');
43 shouldBe('globalCoordinates.altitudeAccuracy', 'testSet[currentTestIndex][1][4]');
44 shouldBe('globalCoordinates.heading', 'testSet[currentTestIndex][1][5]');
45 shouldBe('globalCoordinates.speed', 'testSet[currentTestIndex][1][6]');
49 var watchId
= navigator
.geolocation
.watchPosition(function(position
) {
50 globalCoordinates
= position
.coords
;
53 if (currentTestIndex
+ 1 === testSet
.length
) {
59 debug("Error!: the error callback was called.");