serial-allowed-by-permissions-policy.https.sub.html (1868B)
1 <!DOCTYPE html> 2 <meta name=timeout content=long> 3 <body> 4 <script src=/resources/testharness.js></script> 5 <script src=/resources/testharnessreport.js></script> 6 <script src=/permissions-policy/resources/permissions-policy.js></script> 7 <script> 8 'use strict'; 9 const sub = 'https://{{domains[www]}}:{{ports[https][0]}}'; 10 const same_origin_src = '/permissions-policy/resources/permissions-policy-serial.html'; 11 const cross_origin_src = sub + same_origin_src; 12 const same_origin_worker_frame_src = 13 '/permissions-policy/resources/permissions-policy-serial-worker.html'; 14 const cross_origin_worker_frame_src = sub + same_origin_worker_frame_src; 15 const header = 'Permissions-Policy header serial=*'; 16 17 promise_test( 18 () => navigator.serial.getPorts(), 19 header + ' allows the top-level document.'); 20 21 async_test(t => { 22 test_feature_availability('serial.getPorts()', t, same_origin_src, 23 expect_feature_available_default); 24 }, header + ' allows same-origin iframes.'); 25 26 async_test(t => { 27 test_feature_availability('serial.getPorts()', t, same_origin_worker_frame_src, 28 expect_feature_available_default); 29 }, header + ' allows workers in same-origin iframes.'); 30 31 // Set allow="serial" on iframe element to delegate 'serial' to cross origin 32 // subframe. 33 async_test(t => { 34 test_feature_availability('serial.getPorts()', t, cross_origin_src, 35 expect_feature_available_default, 'serial'); 36 }, header + ' allows cross-origin iframes.'); 37 38 // Set allow="serial" on iframe element to delegate 'serial' to cross origin 39 // subframe. 40 async_test(t => { 41 test_feature_availability('serial.getPorts()', t, 42 cross_origin_worker_frame_src, 43 expect_feature_available_default, 'serial'); 44 }, header + ' allows workers in cross-origin iframes.'); 45 46 fetch_tests_from_worker(new Worker( 47 'resources/serial-allowed-by-permissions-policy-worker.js')); 48 </script> 49 </body>