1 description('Tests that when a cached position is available the callback for getCurrentPosition is called only once. This is a regression test for http://crbug.com/311876 .');
3 if (!window.testRunner || !window.internals)
4 debug('This test can not run without testRunner or internals');
6 internals.setGeolocationClientMock(document);
7 internals.setGeolocationPosition(document, 31.478, -0.166, 100);
8 internals.setGeolocationPermission(document, true);
10 // Only one success callback should be reported per call to getCurrentPosition.
12 function reportCallback(success, id) {
14 shouldBeTrue('isSuccess');
15 getCurrentPositionCallId = id;
16 shouldBe('getCurrentPositionCallId', 'reportCount');
17 if (++reportCount >= 3)
21 var getCurrentPositionCall = 0;
22 function getPosition(milliseconds) {
23 var id = getCurrentPositionCall++;
25 navigator.geolocation.getCurrentPosition(
27 reportCallback(true, id);
30 reportCallback(false, id);
32 { maximumAge:600000, timeout:0 });
34 setTimeout(fn, milliseconds);
37 // The test terminates at the 3rd reported callback. If the bug still exists
38 // this happens after the 2nd call to getCurrentPosition, one of them is a
39 // repeat of the first.
44 window.jsTestIsAsync = true;