1 description("Tests that watchPosition correctly reports position updates and errors from the Geolocation service.");
3 var mockLatitude
= 51.478;
4 var mockLongitude
= -0.166;
5 var mockAccuracy
= 100.0;
7 var mockMessage
= 'test';
12 function checkPosition(p
) {
14 shouldBe('position.coords.latitude', 'mockLatitude');
15 shouldBe('position.coords.longitude', 'mockLongitude');
16 shouldBe('position.coords.accuracy', 'mockAccuracy');
20 function checkError(e
) {
22 shouldBe('error.code', 'error.POSITION_UNAVAILABLE');
23 shouldBe('error.message', 'mockMessage');
27 if (!window
.testRunner
|| !window
.internals
)
28 debug('This test can not run without testRunner or internals');
30 internals
.setGeolocationClientMock(document
);
31 internals
.setGeolocationPermission(document
, true);
32 internals
.setGeolocationPosition(document
, mockLatitude
, mockLongitude
, mockAccuracy
);
35 navigator
.geolocation
.watchPosition(function(p
) {
39 internals
.setGeolocationPosition(document
, ++mockLatitude
, ++mockLongitude
, ++mockAccuracy
);
43 internals
.setGeolocationPositionUnavailableError(document
, mockMessage
);
50 testFailed('Success callback invoked unexpectedly');
57 internals
.setGeolocationPosition(document
, ++mockLatitude
, ++mockLongitude
, ++mockAccuracy
);
60 testFailed('Error callback invoked unexpectedly');
65 window
.jsTestIsAsync
= true;