Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSA: Reject moves with empty names #35850

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 4 additions & 31 deletions fs/script-tests/FileSystemFileHandle-move.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ directory_test(async (t, root) => {
const dir_src = await root.getDirectoryHandle('dir-src', {create: true});
const dir_dest = await root.getDirectoryHandle('dir-dest', {create: true});
const file = await createFileWithContents(t, 'file', 'abc', dir_src);
await file.move(dir_dest, '');
await promise_rejects_js(t, TypeError, file.move(dir_dest, ''));

assert_array_equals(
await getSortedDirectoryEntries(root), ['dir-dest/', 'dir-src/']);
assert_array_equals(await getSortedDirectoryEntries(dir_src), []);
assert_array_equals(await getSortedDirectoryEntries(dir_dest), ['file']);
assert_array_equals(await getSortedDirectoryEntries(dir_src), ['file']);
assert_array_equals(await getSortedDirectoryEntries(dir_dest), []);
assert_equals(await getFileContents(file), 'abc');
assert_equals(await getFileSize(file), 3);
}, 'move(dir, "") to move a file to a new directory');
}, 'move(dir, "") to move a file to a new directory fails');

directory_test(async (t, root) => {
const dir_src = await root.getDirectoryHandle('dir-src', {create: true});
Expand Down Expand Up @@ -191,33 +191,6 @@ directory_test(async (t, root) => {
assert_equals(await getFileContents(handle), 'foo');
}, 'move(dir) can be called multiple times');

directory_test(async (t, root) => {
const dir1 = await root.getDirectoryHandle('dir1', {create: true});
const dir2 = await root.getDirectoryHandle('dir2', {create: true});
const handle = await createFileWithContents(t, 'file', 'foo', root);

await handle.move(dir1, "");
assert_array_equals(
await getSortedDirectoryEntries(root), ['dir1/', 'dir2/']);
assert_array_equals(await getSortedDirectoryEntries(dir1), ['file']);
assert_array_equals(await getSortedDirectoryEntries(dir2), []);
assert_equals(await getFileContents(handle), 'foo');

await handle.move(dir2, "");
assert_array_equals(
await getSortedDirectoryEntries(root), ['dir1/', 'dir2/']);
assert_array_equals(await getSortedDirectoryEntries(dir1), []);
assert_array_equals(await getSortedDirectoryEntries(dir2), ['file']);
assert_equals(await getFileContents(handle), 'foo');

await handle.move(root, "");
assert_array_equals(
await getSortedDirectoryEntries(root), ['dir1/', 'dir2/', 'file']);
assert_array_equals(await getSortedDirectoryEntries(dir1), []);
assert_array_equals(await getSortedDirectoryEntries(dir2), []);
assert_equals(await getFileContents(handle), 'foo');
}, 'move(dir, "") can be called multiple times');

directory_test(async (t, root) => {
const dir1 = await root.getDirectoryHandle('dir1', {create: true});
const dir2 = await root.getDirectoryHandle('dir2', {create: true});
Expand Down