permission-denied-already-success.js revision e78cbe89e6f337f2f1fe40315be88f742b547151
1description("Tests that when Geolocation permission has been denied prior to a call to a Geolocation method, the error callback is invoked with code PERMISSION_DENIED, when the Geolocation service has a good position.");
2
3// Prime the Geolocation instance by denying permission.
4window.layoutTestController.setGeolocationPermission(false);
5window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100);
6
7var error;
8navigator.geolocation.getCurrentPosition(function(p) {
9    testFailed('Success callback invoked unexpectedly');
10    finishJSTest();
11}, function(e) {
12    error = e
13    shouldBe('error.code', 'error.PERMISSION_DENIED');
14    shouldBe('error.message', '"User denied Geolocation"');
15    debug('');
16    continueTest();
17});
18
19function continueTest()
20{
21    // Make another request, with permission already denied.
22    navigator.geolocation.getCurrentPosition(function(p) {
23        testFailed('Success callback invoked unexpectedly');
24        finishJSTest();
25    }, function(e) {
26        error = e
27        shouldBe('error.code', 'error.PERMISSION_DENIED');
28        shouldBe('error.message', '"User denied Geolocation"');
29        finishJSTest();
30    });
31}
32window.layoutTestController.waitUntilDone();
33
34window.jsTestIsAsync = true;
35window.successfullyParsed = true;
36