OLD | NEW |
---|---|
1 description("Tests that the PositionOptions.maximumAge parameter is correctly ap plied."); | 1 description("Tests that the PositionOptions.maximumAge parameter is correctly ap plied."); |
2 | 2 |
3 var mockLatitude = 51.478; | 3 var mockLatitude = 51.478; |
4 var mockLongitude = -0.166; | 4 var mockLongitude = -0.166; |
5 var mockAccuracy = 100.0; | 5 var mockAccuracy = 100.0; |
6 | 6 |
7 var mockMessage = 'test'; | 7 var mockMessage = 'test'; |
8 | 8 |
9 var position; | 9 var position; |
10 var error; | 10 var error; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 navigator.geolocation.getCurrentPosition(function(p) { | 47 navigator.geolocation.getCurrentPosition(function(p) { |
48 checkPosition(p); | 48 checkPosition(p); |
49 testNonZeroMaximumAge(); | 49 testNonZeroMaximumAge(); |
50 }, function(e) { | 50 }, function(e) { |
51 testFailed('Error callback invoked unexpectedly'); | 51 testFailed('Error callback invoked unexpectedly'); |
52 finishJSTest(); | 52 finishJSTest(); |
53 }); | 53 }); |
54 } | 54 } |
55 | 55 |
56 function testNonZeroMaximumAge() { | 56 function testNonZeroMaximumAge() { |
57 // Update the mock service to report an error. | 57 // Update the mock service to report an error. |
Michael van Ouwerkerk
2014/05/13 16:15:17
Fix this comment, the line below does not set an e
kihong
2014/05/14 03:44:25
Done.
| |
58 internals.setGeolocationPosition(document, ++mockLatitude, ++mockLongitude, ++mockAccuracy); | |
59 // The maximumAge is non-zero, so we expect the cached position, not the err or from the service. | |
60 navigator.geolocation.getCurrentPosition(function(p) { | |
61 checkPosition(p); | |
62 testOverSignedIntMaximumAge(); | |
63 }, function(e) { | |
64 testFailed('Error callback invoked unexpectedly'); | |
65 finishJSTest(); | |
66 }, {maximumAge: 1000}); | |
67 } | |
68 | |
69 function testOverSignedIntMaximumAge() { | |
70 // Update the mock service to report an error. | |
Michael van Ouwerkerk
2014/05/13 16:15:17
Actually, this is strange... maximum-age-expected.
kihong
2014/05/14 03:44:25
As you mentioned, this is slightly strange there m
| |
58 internals.setGeolocationPositionUnavailableError(document, mockMessage); | 71 internals.setGeolocationPositionUnavailableError(document, mockMessage); |
59 // The maximumAge is non-zero, so we expect the cached position, not the err or from the service. | 72 // The maximumAge is non-zero, so we expect the cached position, not the err or from the service. |
60 navigator.geolocation.getCurrentPosition(function(p) { | 73 navigator.geolocation.getCurrentPosition(function(p) { |
61 checkPosition(p); | 74 checkPosition(p); |
62 testZeroMaximumAgeError(); | 75 testZeroMaximumAgeError(); |
63 }, function(e) { | 76 }, function(e) { |
64 testFailed('Error callback invoked unexpectedly'); | 77 testFailed('Error callback invoked unexpectedly'); |
65 finishJSTest(); | 78 finishJSTest(); |
66 }, {maximumAge: 1000}); | 79 }, {maximumAge: 2147483648}); |
67 } | 80 } |
68 | 81 |
69 function testZeroMaximumAgeError() { | 82 function testZeroMaximumAgeError() { |
70 // The default maximumAge is zero, so we expect the error from the service. | 83 // The default maximumAge is zero, so we expect the error from the service. |
71 navigator.geolocation.getCurrentPosition(function(p) { | 84 navigator.geolocation.getCurrentPosition(function(p) { |
72 testFailed('Success callback invoked unexpectedly'); | 85 testFailed('Success callback invoked unexpectedly'); |
73 finishJSTest(); | 86 finishJSTest(); |
74 }, function(e) { | 87 }, function(e) { |
75 checkError(e); | 88 checkError(e); |
76 finishJSTest(); | 89 finishJSTest(); |
77 }); | 90 }); |
78 } | 91 } |
79 | 92 |
80 window.jsTestIsAsync = true; | 93 window.jsTestIsAsync = true; |
OLD | NEW |