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() {
13 internals
.setGeolocationPermission(document
, false);
16 var watchCallbackInvoked
= false;
17 var oneShotCallbackInvoked
= false;
20 navigator
.geolocation
.watchPosition(function() {
21 testFailed('Success callback invoked unexpectedly');
26 shouldBe('error.code', 'error.PERMISSION_DENIED');
27 shouldBe('error.message', '"User denied Geolocation"');
28 watchCallbackInvoked
= true;
32 testFailed('Error callback invoked unexpectedly');
36 navigator
.geolocation
.getCurrentPosition(function() {
37 testFailed('Success callback invoked unexpectedly');
42 shouldBe('error.code', 'error.PERMISSION_DENIED');
43 shouldBe('error.message', '"User denied Geolocation"');
44 oneShotCallbackInvoked
= true;
48 testFailed('Error callback invoked unexpectedly');
51 window
.setTimeout(denyPermission
, 100);
53 function maybeFinishTest() {
54 if (watchCallbackInvoked
&& oneShotCallbackInvoked
)
58 window
.jsTestIsAsync
= true;