blob: 3e21b3a6b7af18c825adfd1e9a801940875ea116 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/device/geolocation/public/interfaces/geolocation.mojom.js"></script>
<script src="file:///gen/third_party/WebKit/public/platform/modules/geolocation/geolocation_service.mojom.js"></script>
<script src="file:///gen/third_party/WebKit/public/platform/modules/permissions/permission.mojom.js"></script>
<script src="resources/geolocation-mock.js"></script>
</head>
<body>
<script>
description("Test the attribute handling of the Coordinates interface");
window.jsTestIsAsync = true;
// Format: [Input], [Expected]
// Input: latitude, longitude, accuracy, altitude, altitudeAccuracy, heading, 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;
let mock = geolocationMock;
mock.setGeolocationPermission(true);
function runNextTest()
{
++currentTestIndex;
mock.setGeolocationPosition(...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('');
}
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>
</body>
</html>