file-webkitRelativePath-manual.html (1154B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>Entries API: File webitRelativePath manual test</title> 4 <link rel=help href="https://wicg.github.io/entries-api/#file-interface"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 Select the <b>support/a</b> directory: 9 10 <input type=file multiple webkitdirectory> 11 12 <script> 13 setup({explicit_timeout: true}); 14 15 const filesPromise = new Promise(resolve => { 16 const elem = document.querySelector('input[type=file]'); 17 elem.addEventListener('change', e => resolve(elem.files)); 18 }); 19 20 promise_test(t => filesPromise.then(files => { 21 assert_equals(files.length, 3, 'expected 3 items'); 22 files = Array.from(files).sort( 23 (a, b) => a.name < b.name ? -1 : b.name < a.name ? 1 : 0); 24 assert_equals(files[0].name, '1.txt'); 25 assert_equals(files[1].name, '2.txt'); 26 assert_equals(files[2].name, '3.txt'); 27 assert_equals(files[0].webkitRelativePath, 'a/b/c/d/1.txt'); 28 assert_equals(files[1].webkitRelativePath, 'a/b/c/d/2.txt'); 29 assert_equals(files[2].webkitRelativePath, 'a/b/c/3.txt'); 30 31 }), 'webkitRelativePath is shortest common ancestor'); 32 33 </script>