blob: 9b287602f6b44f54e88faa0abcf1bd210a9932a6 [file] [log] [blame]
[email protected]b12e2ba2012-10-04 19:10:181<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2<html>
3<head>
tkentc5e88f02017-02-06 22:47:314<script src="../resources/js-test.js"></script>
Reilly Grantbe310ab2017-07-11 01:51:265<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
6<script src="file:///gen/device/geolocation/public/interfaces/geolocation.mojom.js"></script>
7<script src="file:///gen/third_party/WebKit/public/platform/modules/permissions/permission.mojom.js"></script>
sammce6687802016-05-13 04:06:578<script src="resources/geolocation-mock.js"></script>
[email protected]b12e2ba2012-10-04 19:10:189</head>
10<body>
11<script>
12description("Test the attribute handling of the Coordinates interface");
13window.jsTestIsAsync = true;
14
[email protected]b12e2ba2012-10-04 19:10:1815// Format: [Input], [Expected]
sammce6687802016-05-13 04:06:5716// Input: latitude, longitude, accuracy, altitude, altitudeAccuracy, heading, speed.
[email protected]b12e2ba2012-10-04 19:10:1817// Expected: latitude, longitude, accuracy, altitude, altitudeAccuracy, heading, speed.
18var testSet = [
19 [[1, 2, 3], [1, 2, 3, null, null, null, null]],
20 [[2, 3, 4, undefined, undefined, undefined, 5], [2, 3, 4, null, null, null, 5]],
21 [[3, 4, 5, undefined, 6, undefined, 7], [3, 4, 5, null, 6, null, 7]],
22 [[4, 5, 6, undefined, 7, 8, 9], [4, 5, 6, null, 7, 8, 9]],
23 [[5, 6, 7, 8, 9, 10, 11], [5, 6, 7, 8, 9, 10, 11]],
24];
25
26var currentTestIndex = -1;
27var globalCoordinates = null;
28
Reilly Grantbe310ab2017-07-11 01:51:2629let mock = geolocationMock;
30mock.setGeolocationPermission(true);
[email protected]b12e2ba2012-10-04 19:10:1831
Reilly Grantbe310ab2017-07-11 01:51:2632function runNextTest()
33{
34 ++currentTestIndex;
35 mock.setGeolocationPosition(...testSet[currentTestIndex][0]);
36}
[email protected]b12e2ba2012-10-04 19:10:1837
Reilly Grantbe310ab2017-07-11 01:51:2638function verifyResults()
39{
40 shouldBe('globalCoordinates.latitude', 'testSet[currentTestIndex][1][0]');
41 shouldBe('globalCoordinates.longitude', 'testSet[currentTestIndex][1][1]');
42 shouldBe('globalCoordinates.accuracy', 'testSet[currentTestIndex][1][2]');
43 shouldBe('globalCoordinates.altitude', 'testSet[currentTestIndex][1][3]');
44 shouldBe('globalCoordinates.altitudeAccuracy', 'testSet[currentTestIndex][1][4]');
45 shouldBe('globalCoordinates.heading', 'testSet[currentTestIndex][1][5]');
46 shouldBe('globalCoordinates.speed', 'testSet[currentTestIndex][1][6]');
47 debug('');
48}
sammce6687802016-05-13 04:06:5749
Reilly Grantbe310ab2017-07-11 01:51:2650var watchId = navigator.geolocation.watchPosition(function(position) {
51 globalCoordinates = position.coords;
52 verifyResults();
sammce6687802016-05-13 04:06:5753
Reilly Grantbe310ab2017-07-11 01:51:2654 if (currentTestIndex + 1 === testSet.length) {
sammce6687802016-05-13 04:06:5755 finishJSTest();
Reilly Grantbe310ab2017-07-11 01:51:2656 return;
57 }
sammce6687802016-05-13 04:06:5758 runNextTest();
Reilly Grantbe310ab2017-07-11 01:51:2659}, function(e) {
60 debug("Error!: the error callback was called.");
61 finishJSTest();
sammce6687802016-05-13 04:06:5762});
[email protected]b12e2ba2012-10-04 19:10:1863
Reilly Grantbe310ab2017-07-11 01:51:2664runNextTest();
65
[email protected]b12e2ba2012-10-04 19:10:1866</script>
[email protected]b12e2ba2012-10-04 19:10:1867</body>
68</html>