| OLD | NEW |
| (Empty) |
| 1 description("Tests that reentrant calls to Geolocation methods from the error ca
llback are OK."); | |
| 2 | |
| 3 var mockMessage = 'test'; | |
| 4 | |
| 5 var error; | |
| 6 | |
| 7 geolocationServiceMock.then(mock => { | |
| 8 mock.setGeolocationPermission(true); | |
| 9 mock.setGeolocationPositionUnavailableError(mockMessage); | |
| 10 | |
| 11 var errorCallbackInvoked = false; | |
| 12 navigator.geolocation.getCurrentPosition(function(p) { | |
| 13 testFailed('Success callback invoked unexpectedly'); | |
| 14 finishJSTest(); | |
| 15 }, function(e) { | |
| 16 if (errorCallbackInvoked) { | |
| 17 testFailed('Error callback invoked unexpectedly'); | |
| 18 finishJSTest(); | |
| 19 } | |
| 20 errorCallbackInvoked = true; | |
| 21 | |
| 22 error = e; | |
| 23 shouldBe('error.code', 'error.POSITION_UNAVAILABLE'); | |
| 24 shouldBe('error.message', 'mockMessage'); | |
| 25 debug(''); | |
| 26 continueTest(); | |
| 27 }); | |
| 28 | |
| 29 function continueTest() { | |
| 30 mockMessage += ' repeat'; | |
| 31 | |
| 32 mock.setGeolocationPositionUnavailableError(mockMessage); | |
| 33 | |
| 34 navigator.geolocation.getCurrentPosition(function(p) { | |
| 35 testFailed('Success callback invoked unexpectedly'); | |
| 36 finishJSTest(); | |
| 37 }, function(e) { | |
| 38 error = e; | |
| 39 shouldBe('error.code', 'error.POSITION_UNAVAILABLE'); | |
| 40 shouldBe('error.message', 'mockMessage'); | |
| 41 finishJSTest(); | |
| 42 }); | |
| 43 } | |
| 44 }); | |
| 45 | |
| 46 window.jsTestIsAsync = true; | |
| OLD | NEW |