OLD | NEW |
1 description("Tests that reentrant calls to Geolocation methods from the error ca
llback due to a PERMISSION_DENIED error are OK."); | 1 description("Tests that reentrant calls to Geolocation methods from the error ca
llback due to a PERMISSION_DENIED error are OK."); |
2 | 2 |
3 if (!window.testRunner || !window.internals) | 3 if (!window.testRunner || !window.mojo) |
4 debug('This test can not run without testRunner or internals'); | 4 debug('This test can not run without testRunner or mojo'); |
5 | |
6 internals.setGeolocationClientMock(document); | |
7 internals.setGeolocationPermission(document, false); | |
8 internals.setGeolocationPosition(document, 51.478, -0.166, 100.0); | |
9 | 5 |
10 var error; | 6 var error; |
11 function checkPermissionError(e) { | |
12 error = e; | |
13 shouldBe('error.code', 'error.PERMISSION_DENIED'); | |
14 shouldBe('error.message', '"User denied Geolocation"'); | |
15 } | |
16 | 7 |
17 var errorCallbackInvoked = false; | 8 geolocationServiceMock.then(mock => { |
18 navigator.geolocation.getCurrentPosition(function(p) { | 9 mock.setGeolocationPermission(false); |
19 testFailed('Success callback invoked unexpectedly'); | 10 mock.setGeolocationPosition(51.478, -0.166, 100.0); |
20 finishJSTest(); | 11 |
21 }, function(e) { | 12 function checkPermissionError(e) { |
22 if (errorCallbackInvoked) { | 13 error = e; |
23 testFailed('Error callback invoked unexpectedly'); | 14 shouldBe('error.code', 'error.PERMISSION_DENIED'); |
24 finishJSTest(); | 15 shouldBe('error.message', '"User denied Geolocation"'); |
25 } | 16 } |
26 errorCallbackInvoked = true; | |
27 checkPermissionError(e); | |
28 continueTest(); | |
29 }); | |
30 | 17 |
31 function continueTest() { | 18 var errorCallbackInvoked = false; |
32 navigator.geolocation.getCurrentPosition(function(p) { | 19 navigator.geolocation.getCurrentPosition(function(p) { |
33 testFailed('Success callback invoked unexpectedly'); | 20 testFailed('Success callback invoked unexpectedly'); |
34 finishJSTest(); | 21 finishJSTest(); |
35 }, function(e) { | 22 }, function(e) { |
| 23 if (errorCallbackInvoked) { |
| 24 testFailed('Error callback invoked unexpectedly'); |
| 25 finishJSTest(); |
| 26 } |
| 27 errorCallbackInvoked = true; |
36 checkPermissionError(e); | 28 checkPermissionError(e); |
37 finishJSTest(); | 29 continueTest(); |
38 }); | 30 }); |
39 } | 31 |
| 32 function continueTest() { |
| 33 navigator.geolocation.getCurrentPosition(function(p) { |
| 34 testFailed('Success callback invoked unexpectedly'); |
| 35 finishJSTest(); |
| 36 }, function(e) { |
| 37 checkPermissionError(e); |
| 38 finishJSTest(); |
| 39 }); |
| 40 } |
| 41 }); |
40 | 42 |
41 window.jsTestIsAsync = true; | 43 window.jsTestIsAsync = true; |
OLD | NEW |