OLD | NEW |
1 description("Tests that when Geolocation permission has been denied prior to a c
all to watchPosition, and the watch is cleared in the error callback, there is n
o crash. This a regression test for https://bugs.webkit.org/show_bug.cgi?id=3211
1."); | 1 description("Tests that when Geolocation permission has been denied prior to a c
all to watchPosition, and the watch is cleared in the error callback, there is n
o crash. This a regression test for https://bugs.webkit.org/show_bug.cgi?id=3211
1."); |
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. |
27 var watchId = navigator.geolocation.watchPosition(function(p) { | 11 mock.setGeolocationPermission(false); |
| 12 mock.setGeolocationPosition(51.478, -0.166, 100); |
| 13 |
| 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 navigator.geolocation.clearWatch(watchId); | 21 debug(''); |
35 window.setTimeout(finishJSTest, 0); | 22 continueTest(); |
36 }); | 23 }); |
37 } | 24 |
| 25 function continueTest() |
| 26 { |
| 27 // Make another request, with permission already denied. |
| 28 var watchId = navigator.geolocation.watchPosition(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 navigator.geolocation.clearWatch(watchId); |
| 36 window.setTimeout(finishJSTest, 0); |
| 37 }); |
| 38 } |
| 39 }); |
38 | 40 |
39 window.jsTestIsAsync = true; | 41 window.jsTestIsAsync = true; |
OLD | NEW |