permission-geolocation.https.html (2679B)
1 <!DOCTYPE html> 2 <title>Test permission of geolocation</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/resources/testdriver.js"></script> 6 <script src="/resources/testdriver-vendor.js"></script> 7 <script src="resources/utils.js"></script> 8 <script src="/common/utils.js"></script> 9 10 <body> 11 12 <script> 13 14 async function runTest(policy_header_in_primary_page, 15 policy_header_in_fenced_frame_page, 16 allow_attribute_iframe_in_fanced_frame) { 17 const permission_geolocation_key = token(); 18 const pipe_for_policy = 'pipe=header(Permissions-Policy,geolocation=self)'; 19 const test_runner_url = 20 'resources/permission-geolocation-test-runner.html?' + 21 (policy_header_in_primary_page ? pipe_for_policy : ''); 22 let fenced_frame_url_params = []; 23 if (policy_header_in_fenced_frame_page) { 24 fenced_frame_url_params.push(pipe_for_policy); 25 } 26 if (allow_attribute_iframe_in_fanced_frame) { 27 fenced_frame_url_params.push('load_allow_attribute_iframe=true'); 28 } 29 const fenced_frame_url = 'permission-geolocation-inner.html?' + 30 fenced_frame_url_params.join('&'); 31 32 const win = window.open(generateURL(test_runner_url, 33 [permission_geolocation_key])); 34 await new Promise(resolve => { 35 win.onload = resolve; 36 }); 37 await test_driver.set_permission({name: 'geolocation'}, 'granted'); 38 39 // Pagehide can be used to detect the document destruction. 40 const pagehidePromise = new Promise(resolve => { 41 win.onpagehide = resolve; 42 }); 43 44 await win.runTest(fenced_frame_url); 45 win.close(); 46 await pagehidePromise; 47 } 48 49 promise_test(async t => { 50 await runTest(false, false, false); 51 }, 'geolocation permission is not permitted for fenced frames'); 52 53 promise_test(async t => { 54 await runTest(true, false, false); 55 }, 'geolocation permission is not permitted for fenced frames, even if a ' + 56 '`Permissions-Policy` header is sent on the primary page.'); 57 58 promise_test(async t => { 59 await runTest(false, true, false); 60 }, 'geolocation permission is not permitted for fenced frames, even if a ' + 61 '`Permissions-Policy` header is sent on the fenced frame response.'); 62 63 promise_test(async t => { 64 await runTest(false, false, true); 65 }, 'geolocation permission is not permitted for fenced frames, even if an ' + 66 '`allow` attribute is set for an iframe in the fenced frame.'); 67 68 promise_test(async t => { 69 await runTest(false, true, true); 70 }, 'geolocation permission is not permitted for fenced frames, even if a ' + 71 '`Permissions-Policy` header and an `allow` attribute is set for an iframe' + 72 ' in the fenced frame.'); 73 </script> 74 75 </body>