show-picker-child-iframe.html (622B)
1 <!DOCTYPE html> 2 <title>Test showPicker() in an iframe</title> 3 <script type=module> 4 const urlParams = new URLSearchParams(location.search); 5 const documentDomain = urlParams.get('documentDomain'); 6 if (documentDomain) { 7 document.domain = documentDomain; 8 } 9 10 let securityErrors = []; 11 const select = document.createElement("select"); 12 try { 13 select.showPicker(); 14 } catch (error) { 15 if (error instanceof DOMException && error.name == 'SecurityError') { 16 securityErrors.push("select"); 17 } 18 } 19 parent.postMessage(securityErrors.join(','), "*"); 20 </script>