Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Geolocation / script-tests / delayed-permission-denied-for-multiple-requests.js
bloba2b0cbde54af831ee25d8aabb4da58ce15477ab7
1 description("Tests that when multiple requests are waiting for permission, no callbacks are invoked until permission is denied.");
3 if (!window.testRunner || !window.internals)
4 debug('This test can not run without testRunner or internals');
6 internals.setGeolocationClientMock(document);
7 internals.setGeolocationPosition(document, 51.478, -0.166, 100);
9 var permissionSet = false;
11 function denyPermission() {
12 permissionSet = true;
13 internals.setGeolocationPermission(document, false);
16 var watchCallbackInvoked = false;
17 var oneShotCallbackInvoked = false;
18 var error;
20 navigator.geolocation.watchPosition(function() {
21 testFailed('Success callback invoked unexpectedly');
22 finishJSTest();
23 }, function(e) {
24 if (permissionSet) {
25 error = e;
26 shouldBe('error.code', 'error.PERMISSION_DENIED');
27 shouldBe('error.message', '"User denied Geolocation"');
28 watchCallbackInvoked = true;
29 maybeFinishTest();
30 return;
32 testFailed('Error callback invoked unexpectedly');
33 finishJSTest();
34 });
36 navigator.geolocation.getCurrentPosition(function() {
37 testFailed('Success callback invoked unexpectedly');
38 finishJSTest();
39 }, function(e) {
40 if (permissionSet) {
41 error = e;
42 shouldBe('error.code', 'error.PERMISSION_DENIED');
43 shouldBe('error.message', '"User denied Geolocation"');
44 oneShotCallbackInvoked = true;
45 maybeFinishTest();
46 return;
48 testFailed('Error callback invoked unexpectedly');
49 finishJSTest();
50 });
51 window.setTimeout(denyPermission, 100);
53 function maybeFinishTest() {
54 if (watchCallbackInvoked && oneShotCallbackInvoked)
55 finishJSTest();
58 window.jsTestIsAsync = true;