OLD | NEW |
1 description('Tests that when a cached position is available the callback for get
CurrentPosition is called only once. This is a regression test for http://crbug.
com/311876 .'); | 1 description('Tests that when a cached position is available the callback for get
CurrentPosition is called only once. This is a regression test for http://crbug.
com/311876 .'); |
2 | 2 |
3 if (!window.testRunner || !window.internals) | 3 if (!window.testRunner || !window.internals) |
4 debug('This test can not run without testRunner or internals'); | 4 debug('This test can not run without testRunner or internals'); |
5 | 5 |
6 internals.setGeolocationClientMock(document); | 6 internals.setGeolocationClientMock(document); |
7 internals.setGeolocationPosition(document, 31.478, -0.166, 100); | 7 internals.setGeolocationPosition(document, 31.478, -0.166, 100); |
8 internals.setGeolocationPermission(document, true); | 8 internals.setGeolocationPermission(document, true); |
9 | 9 |
10 // Only one success callback should be reported per call to getCurrentPosition. | 10 // Only one success callback should be reported per call to getCurrentPosition. |
(...skipping 16 matching lines...) Expand all Loading... |
27 reportCallback(true, id); | 27 reportCallback(true, id); |
28 }, | 28 }, |
29 function(error) { | 29 function(error) { |
30 reportCallback(false, id); | 30 reportCallback(false, id); |
31 }, | 31 }, |
32 { maximumAge:600000, timeout:0 }); | 32 { maximumAge:600000, timeout:0 }); |
33 }; | 33 }; |
34 setTimeout(fn, milliseconds); | 34 setTimeout(fn, milliseconds); |
35 } | 35 } |
36 | 36 |
37 // The test terminates at the 3rd reported callback. If the bug still exists | 37 // Make a geolocation request to populate the cached value so requests with a |
38 // this happens after the 2nd call to getCurrentPosition, one of them is a | 38 // timeout of 0 can succeed. |
39 // repeat of the first. | 39 navigator.geolocation.getCurrentPosition(function(position) { |
40 getPosition(0); | 40 // The test terminates at the 3rd reported callback. If the bug still exists |
41 getPosition(100); | 41 // this happens after the 2nd call to getCurrentPosition, one of them is a |
42 getPosition(200); | 42 // repeat of the first. |
| 43 getPosition(0); |
| 44 getPosition(100); |
| 45 getPosition(200); |
| 46 }, function(error) { |
| 47 testFailed('Error callback invoked unexpectedly'); |
| 48 }); |
43 | 49 |
44 window.jsTestIsAsync = true; | 50 window.jsTestIsAsync = true; |
OLD | NEW |