forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathdelayed-permission-denied.https.html
43 lines (37 loc) · 1.15 KB
/
delayed-permission-denied.https.html
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
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/testharness-adapter.js"></script>
</head>
<body>
<script type="module">
import {GeolocationMock} from './resources/geolocation-mock.js';
description("Tests that when a position is available, no callbacks are invoked until permission is denied.");
let error;
const mock = new GeolocationMock();
mock.setGeolocationPosition(51.478, -0.166, 100);
let permissionSet = false;
function denyPermission() {
permissionSet = true;
mock.setGeolocationPermission(false);
}
navigator.geolocation.getCurrentPosition(function() {
testFailed('Success callback invoked unexpectedly');
finishJSTest();
}, function(e) {
if (permissionSet) {
error = e;
assert_equals(error.code, error.PERMISSION_DENIED);
assert_equals(error.message, "User denied Geolocation");
finishJSTest();
return;
}
testFailed('Error callback invoked unexpectedly');
finishJSTest();
});
window.setTimeout(denyPermission, 100);
</script>
</body>
</html>