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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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. |
58 internals.setGeolocationPositionUnavailableError(document, mockMessage); | 58 internals.setGeolocationPositionUnavailableError(document, mockMessage); |
59 // The maximumAge is non-zero, so we expect the cached position, not the err or from the service. | 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) { | 60 navigator.geolocation.getCurrentPosition(function(p) { |
61 checkPosition(p); | 61 checkPosition(p); |
62 testNegativeValueMaximumAge(); | |
63 }, function(e) { | |
64 testFailed('Error callback invoked unexpectedly'); | |
65 finishJSTest(); | |
66 }, {maximumAge: 1000}); | |
67 } | |
68 | |
69 function testNegativeValueMaximumAge() { | |
70 // Update the position provided by the mock service. | |
71 internals.setGeolocationPosition(document, ++mockLatitude, ++mockLongitude, ++mockAccuracy); | |
72 // The maximumAge is same as zero, so we expect the updated position from th e service. | |
73 navigator.geolocation.getCurrentPosition(function(p) { | |
74 checkPosition(p); | |
75 testOverSignedIntMaximumAge(); | |
76 }, function(e) { | |
77 testFailed('Error callback invoked unexpectedly'); | |
78 finishJSTest(); | |
79 }, {maximumAge: -1000}); | |
80 } | |
81 | |
82 function testOverSignedIntMaximumAge() { | |
83 // Update the mock service to report an error. | |
84 internals.setGeolocationPositionUnavailableError(document, mockMessage); | |
Michael van Ouwerkerk
2014/05/15 11:01:47
I understand now... this is a non-fatal error so t
| |
85 // The maximumAge is non-zero, so we expect the cached position, not the err or from the service. | |
86 navigator.geolocation.getCurrentPosition(function(p) { | |
87 checkPosition(p); | |
88 testOverUnsignedIntMaximumAge(); | |
89 }, function(e) { | |
90 testFailed('Error callback invoked unexpectedly'); | |
91 finishJSTest(); | |
92 }, {maximumAge: 2147483648}); | |
93 } | |
94 | |
95 function testOverUnsignedIntMaximumAge() { | |
96 // Update the mock service to report an error. | |
97 internals.setGeolocationPositionUnavailableError(document, mockMessage); | |
98 // The maximumAge is max-value of unsigned, so we expect the cached position , not the error from the service. | |
99 navigator.geolocation.getCurrentPosition(function(p) { | |
100 checkPosition(p); | |
62 testZeroMaximumAgeError(); | 101 testZeroMaximumAgeError(); |
63 }, function(e) { | 102 }, function(e) { |
64 testFailed('Error callback invoked unexpectedly'); | 103 testFailed('Error callback invoked unexpectedly'); |
65 finishJSTest(); | 104 finishJSTest(); |
66 }, {maximumAge: 1000}); | 105 }, {maximumAge: 4294967296}); |
67 } | 106 } |
68 | 107 |
69 function testZeroMaximumAgeError() { | 108 function testZeroMaximumAgeError() { |
70 // The default maximumAge is zero, so we expect the error from the service. | 109 // The default maximumAge is zero, so we expect the error from the service. |
71 navigator.geolocation.getCurrentPosition(function(p) { | 110 navigator.geolocation.getCurrentPosition(function(p) { |
72 testFailed('Success callback invoked unexpectedly'); | 111 testFailed('Success callback invoked unexpectedly'); |
73 finishJSTest(); | 112 finishJSTest(); |
74 }, function(e) { | 113 }, function(e) { |
75 checkError(e); | 114 checkError(e); |
76 finishJSTest(); | 115 finishJSTest(); |
77 }); | 116 }); |
78 } | 117 } |
79 | 118 |
80 window.jsTestIsAsync = true; | 119 window.jsTestIsAsync = true; |
OLD | NEW |