| 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; |
| 11 | 11 |
| 12 function checkPosition(p) { | 12 function checkPosition(p) { |
| 13 debug(''); | 13 debug(''); |
| 14 position = p; | 14 position = p; |
| 15 shouldBe('position.coords.latitude', 'mockLatitude'); | 15 shouldBe('position.coords.latitude', 'mockLatitude'); |
| 16 shouldBe('position.coords.longitude', 'mockLongitude'); | 16 shouldBe('position.coords.longitude', 'mockLongitude'); |
| 17 shouldBe('position.coords.accuracy', 'mockAccuracy'); | 17 shouldBe('position.coords.accuracy', 'mockAccuracy'); |
| 18 } | 18 } |
| 19 | 19 |
| 20 function checkError(e) { | 20 function checkError(e) { |
| 21 debug(''); | 21 debug(''); |
| 22 error = e; | 22 error = e; |
| 23 shouldBe('error.code', 'error.POSITION_UNAVAILABLE'); | 23 shouldBe('error.code', 'error.POSITION_UNAVAILABLE'); |
| 24 shouldBe('error.message', 'mockMessage'); | 24 shouldBe('error.message', 'mockMessage'); |
| 25 } | 25 } |
| 26 | 26 |
| 27 if (!window.testRunner || !window.mojo) | |
| 28 debug('This test can not run without testRunner or mojo'); | |
| 29 | |
| 30 geolocationServiceMock.then(mock => { | 27 geolocationServiceMock.then(mock => { |
| 31 mock.setGeolocationPermission(true); | 28 mock.setGeolocationPermission(true); |
| 32 mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy); | 29 mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy); |
| 33 | 30 |
| 34 // Initialize the cached Position | 31 // Initialize the cached Position |
| 35 navigator.geolocation.getCurrentPosition(function(p) { | 32 navigator.geolocation.getCurrentPosition(function(p) { |
| 36 checkPosition(p); | 33 checkPosition(p); |
| 37 testZeroMaximumAge(); | 34 testZeroMaximumAge(); |
| 38 }, function(e) { | 35 }, function(e) { |
| 39 testFailed('Error callback invoked unexpectedly'); | 36 testFailed('Error callback invoked unexpectedly'); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 testFailed('Success callback invoked unexpectedly'); | 108 testFailed('Success callback invoked unexpectedly'); |
| 112 finishJSTest(); | 109 finishJSTest(); |
| 113 }, function(e) { | 110 }, function(e) { |
| 114 checkError(e); | 111 checkError(e); |
| 115 finishJSTest(); | 112 finishJSTest(); |
| 116 }); | 113 }); |
| 117 } | 114 } |
| 118 }); | 115 }); |
| 119 | 116 |
| 120 window.jsTestIsAsync = true; | 117 window.jsTestIsAsync = true; |
| OLD | NEW |