blob: 997061c405348d7c3ed45e1d39b0392c4890ebd9 [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>
5<script src="../resources/mojo-helpers.js"></script>
sammce6687802016-05-13 04:06:576<script src="resources/geolocation-mock.js"></script>
[email protected]344a13d2010-08-16 12:30:057</head>
8<body>
tkent98122ee2017-02-02 07:38:519<script>
10description("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.");
11
12var error;
13var iframe = document.createElement('iframe');
14
15function onIframeLoaded() {
16 iframeGeolocation = iframe.contentWindow.navigator.geolocation;
17 iframeGeolocation.getCurrentPosition(function() {
18 testFailed('Success callback invoked unexpectedly');
19 finishJSTest();
20 }, function(e) {
21 error = e;
22 shouldBe('error.code', 'error.PERMISSION_DENIED');
23 shouldBe('error.message', '"User denied Geolocation"');
24 debug('');
25 iframe.src = 'data:text/html,This frame should be visible when the test completes';
26 });
27}
28
29function onIframeUnloaded() {
30 // Make another request, with permission already denied.
31 iframeGeolocation.getCurrentPosition(function () {
32 testFailed('Success callback invoked unexpectedly');
33 finishJSTest();
34 }, function(e) {
35 testFailed('Error callback invoked unexpectedly');
36 finishJSTest();
37 });
38 setTimeout(function() {
39 testPassed('No callbacks invoked');
40 finishJSTest();
41 }, 100);
42}
43
44
45geolocationServiceMock.then(mock => {
46 // Prime the Geolocation instance by denying permission. This makes sure that we execute the
47 // same code path for both preemptive and non-preemptive permissions policies.
48 mock.setGeolocationPermission(false);
49 mock.setGeolocationPosition(51.478, -0.166, 100);
50
51 iframe.src = 'resources/disconnected-frame-inner.html';
52 document.body.appendChild(iframe);
53});
54
55window.jsTestIsAsync = true;
56</script>
[email protected]344a13d2010-08-16 12:30:0557</body>
58</html>