Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Geolocation / script-tests / permission-denied-already-success.js
blob2a14a41c4cf8d153ceba5307845f96b10016d5dc
1 description("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.");
3 if (!window.testRunner || !window.internals)
4 debug('This test can not run without testRunner or internals');
6 internals.setGeolocationClientMock(document);
8 // Prime the Geolocation instance by denying permission.
9 internals.setGeolocationPermission(document, false);
10 internals.setGeolocationPosition(document, 51.478, -0.166, 100);
12 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 });
24 function continueTest()
26 // Make another request, with permission already denied.
27 navigator.geolocation.getCurrentPosition(function(p) {
28 testFailed('Success callback invoked unexpectedly');
29 finishJSTest();
30 }, function(e) {
31 error = e;
32 shouldBe('error.code', 'error.PERMISSION_DENIED');
33 shouldBe('error.message', '"User denied Geolocation"');
34 finishJSTest();
35 });
38 window.jsTestIsAsync = true;