mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 21:00:42 +02:00
Automatic update from web-platform-tests
Replace some "promise_rejects(t, 'SomeDOMError', stuff)" calls with promise_rejects_dom.
This diff was generated by running:
find . -type f -print0 | xargs -0 perl -pi -e "BEGIN { \$/ = undef; } s/promise_rejects\(([ \n]*[a-zA-Z_]+[ \n]*,[ \n]*)([\"'][A-Za-z_]*[\"']) *(, *.)/promise_rejects_dom(\1\2\3/gs"
in bash (doesn't work in tcsh, due to the $ inside "").
--
wpt-commits: b7f2dd315a8d84ce786f6336510ee51423011009
wpt-pr: 21600
69 lines
2.9 KiB
JavaScript
69 lines
2.9 KiB
JavaScript
|
|
directory_test(async (t, root) => {
|
|
const handle =
|
|
await createFileWithContents(t, 'file-to-remove', '12345', root);
|
|
await createFileWithContents(t, 'file-to-keep', 'abc', root);
|
|
await root.removeEntry('file-to-remove');
|
|
|
|
assert_array_equals(await getSortedDirectoryEntries(root), ['file-to-keep']);
|
|
await promise_rejects_dom(t, 'NotFoundError', getFileContents(handle));
|
|
}, 'removeEntry() to remove a file');
|
|
|
|
directory_test(async (t, root) => {
|
|
const handle =
|
|
await createFileWithContents(t, 'file-to-remove', '12345', root);
|
|
await root.removeEntry('file-to-remove');
|
|
|
|
await promise_rejects_dom(t, 'NotFoundError', root.removeEntry('file-to-remove'));
|
|
}, 'removeEntry() on an already removed file should fail');
|
|
|
|
directory_test(async (t, root) => {
|
|
const dir = await root.getDirectory('dir-to-remove', {create: true});
|
|
await createFileWithContents(t, 'file-to-keep', 'abc', root);
|
|
await root.removeEntry('dir-to-remove');
|
|
|
|
assert_array_equals(await getSortedDirectoryEntries(root), ['file-to-keep']);
|
|
await promise_rejects_dom(t, 'NotFoundError', getSortedDirectoryEntries(dir));
|
|
}, 'removeEntry() to remove an empty directory');
|
|
|
|
directory_test(async (t, root) => {
|
|
const dir = await root.getDirectory('dir-to-remove', {create: true});
|
|
t.add_cleanup(() => root.removeEntry('dir-to-remove', {recursive: true}));
|
|
await createEmptyFile(t, 'file-in-dir', dir);
|
|
|
|
await promise_rejects_dom(
|
|
t, 'InvalidModificationError', root.removeEntry('dir-to-remove'));
|
|
assert_array_equals(
|
|
await getSortedDirectoryEntries(root), ['dir-to-remove/']);
|
|
assert_array_equals(await getSortedDirectoryEntries(dir), ['file-in-dir']);
|
|
}, 'removeEntry() on a non-empty directory should fail');
|
|
|
|
directory_test(async (t, root) => {
|
|
const dir = await createDirectory(t, 'dir', root);
|
|
await promise_rejects_js(t, TypeError, dir.removeEntry(''));
|
|
}, 'removeEntry() with empty name should fail');
|
|
|
|
directory_test(async (t, root) => {
|
|
const dir = await createDirectory(t, 'dir', root);
|
|
await promise_rejects_js(t, TypeError, dir.removeEntry(kCurrentDirectory));
|
|
}, `removeEntry() with "${kCurrentDirectory}" name should fail`);
|
|
|
|
directory_test(async (t, root) => {
|
|
const dir = await createDirectory(t, 'dir', root);
|
|
await promise_rejects_js(t, TypeError, dir.removeEntry(kParentDirectory));
|
|
}, `removeEntry() with "${kParentDirectory}" name should fail`);
|
|
|
|
directory_test(async (t, root) => {
|
|
const dir_name = 'dir-name';
|
|
const dir = await createDirectory(t, dir_name, root);
|
|
|
|
const file_name = 'file-name';
|
|
await createEmptyFile(t, file_name, dir);
|
|
|
|
for (let i = 0; i < kPathSeparators.length; ++i) {
|
|
const path_with_separator = `${dir_name}${kPathSeparators[i]}${file_name}`;
|
|
await promise_rejects_js(
|
|
t, TypeError, root.removeEntry(path_with_separator),
|
|
`removeEntry() must reject names containing "${kPathSeparators[i]}"`);
|
|
}
|
|
}, 'removeEntry() with a path separator should fail.');
|