| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <script> |
| description("Test the attribute handling of the Coordinates interface"); |
| window.jsTestIsAsync = true; |
| |
| // Format: [Input], [Expected] |
| // Input: latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed. |
| // Expected: latitude, longitude, accuracy, altitude, altitudeAccuracy, heading, speed. |
| var testSet = [ |
| [[1, 2, 3], [1, 2, 3, null, null, null, null]], |
| [[2, 3, 4, undefined, undefined, undefined, 5], [2, 3, 4, null, null, null, 5]], |
| [[3, 4, 5, undefined, 6, undefined, 7], [3, 4, 5, null, 6, null, 7]], |
| [[4, 5, 6, undefined, 7, 8, 9], [4, 5, 6, null, 7, 8, 9]], |
| [[5, 6, 7, 8, 9, 10, 11], [5, 6, 7, 8, 9, 10, 11]], |
| ]; |
| |
| var currentTestIndex = -1; |
| var globalCoordinates = null; |
| |
| function runNextTest() |
| { |
| ++currentTestIndex; |
| testRunner.setMockGeolocationPosition.apply(testRunner, testSet[currentTestIndex][0]); |
| } |
| |
| function verifyResults() |
| { |
| shouldBe('globalCoordinates.latitude', 'testSet[currentTestIndex][1][0]'); |
| shouldBe('globalCoordinates.longitude', 'testSet[currentTestIndex][1][1]'); |
| shouldBe('globalCoordinates.accuracy', 'testSet[currentTestIndex][1][2]'); |
| shouldBe('globalCoordinates.altitude', 'testSet[currentTestIndex][1][3]'); |
| shouldBe('globalCoordinates.altitudeAccuracy', 'testSet[currentTestIndex][1][4]'); |
| shouldBe('globalCoordinates.heading', 'testSet[currentTestIndex][1][5]'); |
| shouldBe('globalCoordinates.speed', 'testSet[currentTestIndex][1][6]'); |
| debug(''); |
| } |
| |
| if (window.testRunner) { |
| testRunner.setGeolocationPermission(true); |
| } else |
| debug('This test can not be without TestRunner.'); |
| |
| var watchId = navigator.geolocation.watchPosition(function(position) { |
| globalCoordinates = position.coords; |
| verifyResults(); |
| |
| if (currentTestIndex + 1 === testSet.length) { |
| finishJSTest(); |
| return; |
| } |
| runNextTest(); |
| }, function(e) { |
| debug("Error!: the error callback was called."); |
| finishJSTest(); |
| }); |
| |
| runNextTest(); |
| |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |