selectAudioOutput-permissions-policy.https.sub.html (1684B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <body> 4 <script src="/resources/testharness.js" 5 type="text/javascript{{GET[in-iframe]}}"></script> 6 <script src="/resources/testharnessreport.js" 7 type="text/javascript{{GET[in-iframe]}}"></script> 8 <script src="/resources/testdriver.js"></script> 9 <script src="/resources/testdriver-vendor.js"></script> 10 <script src="/common/get-host-info.sub.js"></script> 11 <script src="/permissions-policy/resources/permissions-policy.js"></script> 12 <script> 13 'use strict'; 14 15 async function testSelectAudioOutput() { 16 await test_driver.bless('transient activation for selectAudioOutput()'); 17 const selected = await navigator.mediaDevices.selectAudioOutput(); 18 19 let devices; 20 try { 21 devices = await navigator.mediaDevices.enumerateDevices(); 22 } catch (e) { 23 // Throw a unique error to avoid risk of false-pass if e should match 24 // an expected error from selectAudioOutput(). 25 throw Error(`enumerateDevices() failed with ${e}`); 26 } 27 const selected_devices = 28 devices.filter(info => info.deviceId == selected.deviceId); 29 // Don't use assert_not_equals() because testharness.js cannot be 30 // loaded in the iframe with testdriver.js. 31 if (selected_devices.length != 1) { 32 throw Error('Device count matching selected is ' + 33 selected_devices.length); 34 } 35 } 36 37 if (page_loaded_in_iframe()) { 38 test_driver.set_test_context(window.parent); 39 } 40 const cross_domain = get_host_info().HTTPS_REMOTE_ORIGIN; 41 run_all_fp_tests_allow_self( 42 cross_domain, 43 'speaker-selection', 44 'NotAllowedError', 45 testSelectAudioOutput 46 ); 47 </script> 48 </body>