OLD | NEW |
1 description("Tests that when Geolocation permission has been denied prior to a c
all to a Geolocation method, the error callback is invoked with code PERMISSION_
DENIED, when the Geolocation service has a good position."); | 1 description("Tests that when Geolocation permission has been denied prior to a c
all to a Geolocation method, the error callback is invoked with code PERMISSION_
DENIED, when the Geolocation service has a good position."); |
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 | |
8 // Prime the Geolocation instance by denying permission. | |
9 internals.setGeolocationPermission(document, false); | |
10 internals.setGeolocationPosition(document, 51.478, -0.166, 100); | |
11 | 5 |
12 var error; | 6 var error; |
13 navigator.geolocation.getCurrentPosition(function(p) { | |
14 testFailed('Success callback invoked unexpectedly'); | |
15 finishJSTest(); | |
16 }, function(e) { | |
17 error = e; | |
18 shouldBe('error.code', 'error.PERMISSION_DENIED'); | |
19 shouldBe('error.message', '"User denied Geolocation"'); | |
20 debug(''); | |
21 continueTest(); | |
22 }); | |
23 | 7 |
24 function continueTest() | 8 geolocationServiceMock.then(mock => { |
25 { | 9 |
26 // Make another request, with permission already denied. | 10 // Prime the Geolocation instance by denying permission. |
| 11 mock.setGeolocationPermission(false); |
| 12 mock.setGeolocationPosition(51.478, -0.166, 100); |
| 13 |
27 navigator.geolocation.getCurrentPosition(function(p) { | 14 navigator.geolocation.getCurrentPosition(function(p) { |
28 testFailed('Success callback invoked unexpectedly'); | 15 testFailed('Success callback invoked unexpectedly'); |
29 finishJSTest(); | 16 finishJSTest(); |
30 }, function(e) { | 17 }, function(e) { |
31 error = e; | 18 error = e; |
32 shouldBe('error.code', 'error.PERMISSION_DENIED'); | 19 shouldBe('error.code', 'error.PERMISSION_DENIED'); |
33 shouldBe('error.message', '"User denied Geolocation"'); | 20 shouldBe('error.message', '"User denied Geolocation"'); |
34 finishJSTest(); | 21 debug(''); |
| 22 continueTest(); |
35 }); | 23 }); |
36 } | 24 |
| 25 function continueTest() |
| 26 { |
| 27 // Make another request, with permission already denied. |
| 28 navigator.geolocation.getCurrentPosition(function(p) { |
| 29 testFailed('Success callback invoked unexpectedly'); |
| 30 finishJSTest(); |
| 31 }, function(e) { |
| 32 error = e; |
| 33 shouldBe('error.code', 'error.PERMISSION_DENIED'); |
| 34 shouldBe('error.message', '"User denied Geolocation"'); |
| 35 finishJSTest(); |
| 36 }); |
| 37 } |
| 38 }); |
37 | 39 |
38 window.jsTestIsAsync = true; | 40 window.jsTestIsAsync = true; |
OLD | NEW |