Skip to content

Commit abede1d

Browse files
a-sullychromium-wpt-export-bot
authored andcommitted
FSA: Relax file name checks in the BucketFS
Unlike when saving files to the local file system, the names of files in the the Bucket File System (a.k.a. OPFS) are obfuscated before they end up on disk - if they even end up on disk at all. As such, we don't need to perform the same name sanitization and obfuscation for these files as we do for files that end up on the user-visible file system. See whatwg/fs#93 for context Bug: 1399536 Change-Id: I019b393b731cd20aa4c45eade4eca19b6633e9cd
1 parent 50857a6 commit abede1d

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

fs/resources/test-helpers.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@ const LOCK_ACCESS = {
1717
};
1818

1919
// Array of separators used to separate components in hierarchical paths.
20-
let kPathSeparators;
21-
if (navigator.userAgent.includes('Windows NT')) {
22-
// Windows uses both '/' and '\' as path separators.
23-
kPathSeparators = ['/', '\\'];
24-
} else {
25-
kPathSeparators = ['/'];
26-
}
20+
// Consider both '/' and '\' as path separators to ensure file names are
21+
// platform-agnostic.
22+
let kPathSeparators = ['/', '\\'];
2723

2824
async function getFileSize(handle) {
2925
const file = await handle.getFile();

fs/script-tests/FileSystemFileHandle-move.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,15 @@ directory_test(async (t, root) => {
5050
assert_array_equals(await getSortedDirectoryEntries(root), ['file-1']);
5151
}, 'move(name) can be called multiple times');
5252

53-
directory_test(async (t, root) => {
54-
const dir = await root.getDirectoryHandle('dir', {create: true});
55-
const handle = await createFileWithContents(t, 'file-before', 'foo', dir);
56-
await promise_rejects_js(t, TypeError, handle.move('Lorem.'));
57-
58-
assert_array_equals(await getSortedDirectoryEntries(root), ['dir/']);
59-
assert_array_equals(await getSortedDirectoryEntries(dir), ['file-before']);
60-
assert_equals(await getFileContents(handle), 'foo');
61-
assert_equals(await getFileSize(handle), 3);
62-
}, 'move(name) with a name with a trailing period should fail');
63-
6453
directory_test(async (t, root) => {
6554
const handle = await createFileWithContents(t, 'file-before', 'foo', root);
6655
await promise_rejects_js(t, TypeError, handle.move('test/test'));
56+
await promise_rejects_js(t, TypeError, handle.move('test\\test'));
6757

6858
assert_array_equals(await getSortedDirectoryEntries(root), ['file-before']);
6959
assert_equals(await getFileContents(handle), 'foo');
7060
assert_equals(await getFileSize(handle), 3);
71-
}, 'move(name) with a name with invalid characters should fail');
61+
}, 'move(name) with a name with path separators should fail');
7262

7363
directory_test(async (t, root) => {
7464
const handle = await createFileWithContents(t, 'file-before', 'abc', root);

0 commit comments

Comments
 (0)