blob: ba92d68c839266d9126ff2b0f86f26343528cfb7 [file] [log] [blame]
[email protected]344a13d2010-08-16 12:30:051<!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>
Julie Jeongeun Kim162c2d282019-03-13 07:23:527<script src="file:///gen/third_party/blink/public/mojom/geolocation/geolocation_service.mojom.js"></script>
8<script src="file:///gen/third_party/blink/public/mojom/permissions/permission.mojom.js"></script>
sammce6687802016-05-13 04:06:579<script src="resources/geolocation-mock.js"></script>
[email protected]344a13d2010-08-16 12:30:0510</head>
11<body>
tkent98122ee2017-02-02 07:38:5112<script>
13description("Tests that when a request is made on a Geolocation object, permission is denied and its Frame is disconnected before a callback is made, no callbacks are made.");
14
15var error;
16var iframe = document.createElement('iframe');
17
18function onIframeLoaded() {
19 iframeGeolocation = iframe.contentWindow.navigator.geolocation;
20 iframeGeolocation.getCurrentPosition(function() {
21 testFailed('Success callback invoked unexpectedly');
22 finishJSTest();
23 }, function(e) {
24 error = e;
25 shouldBe('error.code', 'error.PERMISSION_DENIED');
26 shouldBe('error.message', '"User denied Geolocation"');
27 debug('');
28 iframe.src = 'data:text/html,This frame should be visible when the test completes';
Maxim Kolosovskiy2291dbc2017-12-08 10:48:5429 });
tkent98122ee2017-02-02 07:38:5130}
31
32function onIframeUnloaded() {
33 // Make another request, with permission already denied.
34 iframeGeolocation.getCurrentPosition(function () {
35 testFailed('Success callback invoked unexpectedly');
36 finishJSTest();
37 }, function(e) {
38 testFailed('Error callback invoked unexpectedly');
39 finishJSTest();
Maxim Kolosovskiy2291dbc2017-12-08 10:48:5440 });
tkent98122ee2017-02-02 07:38:5141 setTimeout(function() {
42 testPassed('No callbacks invoked');
43 finishJSTest();
44 }, 100);
45}
46
47
Reilly Grantbe310ab2017-07-11 01:51:2648// Prime the Geolocation instance by denying permission. This makes sure that we execute the
49// same code path for both preemptive and non-preemptive permissions policies.
50let mock = geolocationMock;
51mock.setGeolocationPermission(false);
52mock.setGeolocationPosition(51.478, -0.166, 100);
tkent98122ee2017-02-02 07:38:5153
Reilly Grantbe310ab2017-07-11 01:51:2654iframe.src = 'resources/disconnected-frame-inner.html';
55document.body.appendChild(iframe);
tkent98122ee2017-02-02 07:38:5156
57window.jsTestIsAsync = true;
58</script>
[email protected]344a13d2010-08-16 12:30:0559</body>
60</html>