| OLD | NEW |
| 1 description("Tests Geolocation error callback using the mock service."); | 1 description("Tests Geolocation error callback using the mock service."); |
| 2 | 2 |
| 3 var mockMessage = "debug"; | 3 var mockMessage = "debug"; |
| 4 | 4 |
| 5 if (!window.testRunner || !window.internals) | 5 if (!window.testRunner || !window.mojo) |
| 6 debug('This test can not run without testRunner or internals'); | 6 debug('This test can not run without testRunner or mojo'); |
| 7 | |
| 8 internals.setGeolocationClientMock(document); | |
| 9 internals.setGeolocationPermission(document, true); | |
| 10 internals.setGeolocationPositionUnavailableError(document, mockMessage); | |
| 11 | 7 |
| 12 var error; | 8 var error; |
| 13 navigator.geolocation.getCurrentPosition(function(p) { | 9 |
| 10 geolocationServiceMock.then(mock => { |
| 11 mock.setGeolocationPermission(true); |
| 12 mock.setGeolocationPositionUnavailableError(mockMessage); |
| 13 |
| 14 navigator.geolocation.getCurrentPosition(function(p) { |
| 14 testFailed('Success callback invoked unexpectedly'); | 15 testFailed('Success callback invoked unexpectedly'); |
| 15 finishJSTest(); | 16 finishJSTest(); |
| 16 }, function(e) { | 17 }, function(e) { |
| 17 error = e; | 18 error = e; |
| 18 shouldBe('error.code', 'error.POSITION_UNAVAILABLE'); | 19 shouldBe('error.code', 'error.POSITION_UNAVAILABLE'); |
| 19 shouldBe('error.message', 'mockMessage'); | 20 shouldBe('error.message', 'mockMessage'); |
| 20 shouldBe('error.UNKNOWN_ERROR', 'undefined'); | 21 shouldBe('error.UNKNOWN_ERROR', 'undefined'); |
| 21 shouldBe('error.PERMISSION_DENIED', '1'); | 22 shouldBe('error.PERMISSION_DENIED', '1'); |
| 22 shouldBe('error.POSITION_UNAVAILABLE', '2'); | 23 shouldBe('error.POSITION_UNAVAILABLE', '2'); |
| 23 shouldBe('error.TIMEOUT', '3'); | 24 shouldBe('error.TIMEOUT', '3'); |
| 24 finishJSTest(); | 25 finishJSTest(); |
| 26 }); |
| 25 }); | 27 }); |
| 26 | 28 |
| 27 window.jsTestIsAsync = true; | 29 window.jsTestIsAsync = true; |
| OLD | NEW |