Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Geolocation / coordinates-interface-attributes.html
blobcfda7af88308af74ce04e88c75f56e7baa1f2212
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <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.
20 var testSet = [
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()
33 ++currentTestIndex;
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]');
46 debug('');
49 var watchId = navigator.geolocation.watchPosition(function(position) {
50 globalCoordinates = position.coords;
51 verifyResults();
53 if (currentTestIndex + 1 === testSet.length) {
54 finishJSTest();
55 return;
57 runNextTest();
58 }, function(e) {
59 debug("Error!: the error callback was called.");
60 finishJSTest();
61 });
63 runNextTest();
65 </script>
66 </body>
67 </html>