blob: 21cb4882e8dd1b5dfe1605d8a9b785a55d5368b0 [file] [log] [blame]
[email protected]a4ca4262010-08-17 16:54:231<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2<html>
3<head>
tkentc5e88f02017-02-06 22:47:314<script src="../resources/js-test.js"></script>
Reilly Grantbe310ab2017-07-11 01:51:265<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
6<script src="file:///gen/device/geolocation/public/interfaces/geolocation.mojom.js"></script>
7<script src="file:///gen/third_party/WebKit/public/platform/modules/permissions/permission.mojom.js"></script>
sammce6687802016-05-13 04:06:578<script src="resources/geolocation-mock.js"></script>
[email protected]a4ca4262010-08-17 16:54:239</head>
10<body>
tkent98122ee2017-02-02 07:38:5111<script>
12description("Tests that when multiple requests are waiting for permission, no callbacks are invoked until permission is denied.");
13
14var error;
15
Reilly Grantbe310ab2017-07-11 01:51:2616let mock = geolocationMock;
17mock.setGeolocationPosition(51.478, -0.166, 100);
tkent98122ee2017-02-02 07:38:5118
Reilly Grantbe310ab2017-07-11 01:51:2619var permissionSet = false;
tkent98122ee2017-02-02 07:38:5120
Reilly Grantbe310ab2017-07-11 01:51:2621function denyPermission() {
22 permissionSet = true;
23 mock.setGeolocationPermission(false);
24}
25
26var watchCallbackInvoked = false;
27var oneShotCallbackInvoked = false;
28
29navigator.geolocation.watchPosition(function() {
30 testFailed('Success callback invoked unexpectedly');
31 finishJSTest();
32}, function(e) {
33 if (permissionSet) {
34 error = e;
35 shouldBe('error.code', 'error.PERMISSION_DENIED');
36 shouldBe('error.message', '"User denied Geolocation"');
37 watchCallbackInvoked = true;
38 maybeFinishTest();
39 return;
tkent98122ee2017-02-02 07:38:5140 }
Reilly Grantbe310ab2017-07-11 01:51:2641 testFailed('Error callback invoked unexpectedly');
42 finishJSTest();
tkent98122ee2017-02-02 07:38:5143});
44
Reilly Grantbe310ab2017-07-11 01:51:2645navigator.geolocation.getCurrentPosition(function() {
46 testFailed('Success callback invoked unexpectedly');
47 finishJSTest();
48}, function(e) {
49 if (permissionSet) {
50 error = e;
51 shouldBe('error.code', 'error.PERMISSION_DENIED');
52 shouldBe('error.message', '"User denied Geolocation"');
53 oneShotCallbackInvoked = true;
54 maybeFinishTest();
55 return;
56 }
57 testFailed('Error callback invoked unexpectedly');
58 finishJSTest();
59});
60window.setTimeout(denyPermission, 100);
61
62function maybeFinishTest() {
63 if (watchCallbackInvoked && oneShotCallbackInvoked)
64 finishJSTest();
65}
66
tkent98122ee2017-02-02 07:38:5167window.jsTestIsAsync = true;
68</script>
[email protected]a4ca4262010-08-17 16:54:2369</body>
70</html>