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