| OLD | NEW |
| 1 description("Tests that when a position is available, no callbacks are invoked u
ntil permission is allowed."); | 1 description("Tests that when a position is available, no callbacks are invoked u
ntil permission is allowed."); |
| 2 | 2 |
| 3 if (!window.testRunner || !window.mojo) | |
| 4 debug('This test can not run without testRunner or mojo'); | |
| 5 | |
| 6 geolocationServiceMock.then(mock => { | 3 geolocationServiceMock.then(mock => { |
| 7 mock.setGeolocationPosition(51.478, -0.166, 100); | 4 mock.setGeolocationPosition(51.478, -0.166, 100); |
| 8 | 5 |
| 9 var permissionSet = false; | 6 var permissionSet = false; |
| 10 | 7 |
| 11 function allowPermission() { | 8 function allowPermission() { |
| 12 permissionSet = true; | 9 permissionSet = true; |
| 13 mock.setGeolocationPermission(true); | 10 mock.setGeolocationPermission(true); |
| 14 } | 11 } |
| 15 | 12 |
| 16 navigator.geolocation.getCurrentPosition(function() { | 13 navigator.geolocation.getCurrentPosition(function() { |
| 17 if (permissionSet) { | 14 if (permissionSet) { |
| 18 testPassed('Success callback invoked'); | 15 testPassed('Success callback invoked'); |
| 19 finishJSTest(); | 16 finishJSTest(); |
| 20 return; | 17 return; |
| 21 } | 18 } |
| 22 testFailed('Success callback invoked unexpectedly'); | 19 testFailed('Success callback invoked unexpectedly'); |
| 23 finishJSTest(); | 20 finishJSTest(); |
| 24 }, function() { | 21 }, function() { |
| 25 testFailed('Error callback invoked unexpectedly'); | 22 testFailed('Error callback invoked unexpectedly'); |
| 26 finishJSTest(); | 23 finishJSTest(); |
| 27 }); | 24 }); |
| 28 window.setTimeout(allowPermission, 100); | 25 window.setTimeout(allowPermission, 100); |
| 29 }); | 26 }); |
| 30 | 27 |
| 31 window.jsTestIsAsync = true; | 28 window.jsTestIsAsync = true; |
| OLD | NEW |