blob: f230091608f4d921761e426d77f08a870ebd3d34 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
description("Tests that when multiple requests are waiting for permission, no callbacks are invoked until permission is denied.");
if (window.layoutTestController)
window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100);
function denyPermission() {
permissionSet = true;
if (window.layoutTestController)
layoutTestController.setGeolocationPermission(false);
}
var watchCallbackInvoked = false;
var oneShotCallbackInvoked = false;
var error;
navigator.geolocation.watchPosition(function() {
testFailed('Success callback invoked unexpectedly');
finishJSTest();
}, function(e) {
if (permissionSet) {
error = e;
shouldBe('error.code', 'error.PERMISSION_DENIED');
shouldBe('error.message', '"User denied Geolocation"');
watchCallbackInvoked = true;
maybeFinishTest();
return;
}
testFailed('Error callback invoked unexpectedly');
finishJSTest();
});
navigator.geolocation.getCurrentPosition(function() {
testFailed('Success callback invoked unexpectedly');
finishJSTest();
}, function(e) {
if (permissionSet) {
error = e;
shouldBe('error.code', 'error.PERMISSION_DENIED');
shouldBe('error.message', '"User denied Geolocation"');
oneShotCallbackInvoked = true;
maybeFinishTest();
return;
}
testFailed('Error callback invoked unexpectedly');
finishJSTest();
});
window.setTimeout(denyPermission, 100);
function maybeFinishTest() {
if (watchCallbackInvoked && oneShotCallbackInvoked)
finishJSTest();
}
window.jsTestIsAsync = true;
window.successfullyParsed = true;
|