Files
sousa-gecko/testing/web-platform/tests/file-system-access/showOpenFilePicker-manual.https.html
T
Joel Hockey 92478f2d6f Bug 1945727 [wpt PR 50477] - Store display-name with FileSystemFileHandle to allow mime guess, a=testonly
Automatic update from web-platform-tests
Store display-name with FileSystemFileHandle to allow mime guess

Android content-URIs typically are not related to the display name, so
we must keep the display name to use it for mime guessing for File.type.

Bug: 393513313
Change-Id: I811cf81d9e17402a401190f67604addf094dbed0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6228436
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Reviewed-by: Fergal Daly <fergal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1415390}

--

wpt-commits: 23e74311b52e3a33a25501a680904e77ed707f9f
wpt-pr: 50477
2025-02-06 12:59:00 +00:00

47 lines
1.7 KiB
HTML

<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/test-helpers.js"></script>
<script>
promise_test(async t => {
await new Promise(resolve => {
window.addEventListener('DOMContentLoaded', resolve);
});
// Small delay to give chrome's test automation a chance to actually install
// itself.
await new Promise(resolve => step_timeout(resolve, 100));
await window.test_driver.bless(
'show a file picker.<br />Please select file-system-access/resources/data/testfile.txt');
const files = await self.showOpenFilePicker({
multiple: false, types: [
{ description: 'Text files', accept: { ' text/plain ': ['.txt'] } },
{ description: 'Images', accept: { ' image/* ': ['.jpg', '.jpeg', '.png'] } },
],
});
assert_true(Array.isArray(files));
assert_equals(files.length, 1);
assert_true(files[0] instanceof FileSystemHandle);
assert_true(files[0] instanceof FileSystemFileHandle);
assert_equals(files[0].kind, "file");
assert_equals(files[0].name, 'testfile.txt');
const file = await files[0].getFile();
assert_equals(file.name, 'testfile.txt');
assert_equals(file.size, 13);
assert_equals(file.type, 'text/plain');
assert_equals(await file.text(), 'Hello World!\n');
promise_test(async t => {
assert_equals(await files[0].queryPermission(), 'granted');
}, 'showOpenFilePicker returns correct permissions');
}, 'showOpenFilePicker works');
</script>