show-open-file-picker.https.html (1278B)
1 <!DOCTYPE html> 2 <title>showOpenFilePicker API test</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 <script src="/common/dispatcher/dispatcher.js"></script> 10 <script src="/resources/testdriver-actions.js"></script> 11 12 <body> 13 <script> 14 promise_test(async () => { 15 const frame = attachFencedFrameContext(); 16 await multiClick(10, 10, frame.element); 17 const result = await frame.execute(async () => { 18 try { 19 const dir = await window.showOpenFilePicker(); 20 return 'opened file picker'; 21 } catch (e) { 22 if (e.name === 'SecurityError' && 23 e.message === "Failed to execute 'showOpenFilePicker' on 'Window': Cross origin sub frames aren't allowed to show a file picker.") { 24 return 'Access to the open file picker was disallowed'; 25 } 26 return `showOpenFilePicker failed with unknown error ${e.name} ${e.message}`; 27 } 28 }); 29 assert_equals(result, 'Access to the open file picker was disallowed'); 30 }, 'Directory information should not be read in the fenced frame.'); 31 </script> 32 </body>