mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 0b22439430b6d8d9a6d43a0908e86c0366f207c0
This commit is contained in:
parent
39ec04a065
commit
c8e806d0ef
93 changed files with 2118 additions and 597 deletions
|
@ -3,39 +3,74 @@ promise_test(async t => cleanupSandboxedFileSystem(),
|
|||
'Cleanup to setup test environment');
|
||||
|
||||
promise_test(async t => {
|
||||
const dir = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const handle = await createFileWithContents(t, 'file-to-remove', '12345', dir);
|
||||
await createFileWithContents(t, 'file-to-keep', 'abc');
|
||||
await handle.remove();
|
||||
const root = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
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(dir), ['file-to-keep']);
|
||||
assert_array_equals(await getSortedDirectoryEntries(root), ['file-to-keep']);
|
||||
await promise_rejects(t, 'NotFoundError', getFileContents(handle));
|
||||
}, 'remove() to remove a file');
|
||||
}, 'removeEntry() to remove a file');
|
||||
|
||||
promise_test(async t => {
|
||||
const handle = await createFileWithContents(t, 'file-to-remove', '12345');
|
||||
await handle.remove();
|
||||
const root = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const handle = await createFileWithContents(t, 'file-to-remove', '12345', root);
|
||||
await root.removeEntry('file-to-remove');
|
||||
|
||||
await promise_rejects(t, 'NotFoundError', handle.remove());
|
||||
}, 'remove() on an already removed file should fail');
|
||||
await promise_rejects(t, 'NotFoundError', root.removeEntry('file-to-remove'));
|
||||
}, 'removeEntry() on an already removed file should fail');
|
||||
|
||||
promise_test(async t => {
|
||||
const root = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const dir = await root.getDirectory('dir-to-remove', { create: true });
|
||||
await createFileWithContents(t, 'file-to-keep', 'abc');
|
||||
await dir.remove();
|
||||
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(t, 'NotFoundError', getSortedDirectoryEntries(dir));
|
||||
}, 'remove() to remove an empty directory');
|
||||
}, 'removeEntry() to remove an empty directory');
|
||||
|
||||
promise_test(async t => {
|
||||
const root = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const dir = await root.getDirectory('dir-to-remove', { create: true });
|
||||
t.add_cleanup(() => dir.removeRecursively());
|
||||
t.add_cleanup(() => root.removeEntry('dir-to-remove', { recursive: true }));
|
||||
await createEmptyFile(t, 'file-in-dir', dir);
|
||||
|
||||
await promise_rejects(t, 'InvalidModificationError', dir.remove());
|
||||
await promise_rejects(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']);
|
||||
}, 'remove() on a non-empty directory should fail');
|
||||
}, 'removeEntry() on a non-empty directory should fail');
|
||||
|
||||
promise_test(async t => {
|
||||
const root = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const dir = await createDirectory(t, 'dir', root);
|
||||
await promise_rejects(t, 'NotFoundError', dir.removeEntry(""));
|
||||
}, 'removeEntry() with empty name should fail');
|
||||
|
||||
promise_test(async t => {
|
||||
const root = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const dir = await createDirectory(t, 'dir', root);
|
||||
await promise_rejects(t, 'SecurityError', dir.removeEntry(kCurrentDirectory));
|
||||
}, `removeEntry() with "${kCurrentDirectory}" name should fail`);
|
||||
|
||||
promise_test(async t => {
|
||||
const root = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const dir = await createDirectory(t, 'dir', root);
|
||||
await promise_rejects(t, 'SecurityError', dir.removeEntry(kParentDirectory));
|
||||
}, `removeEntry() with "${kParentDirectory}" name should fail`);
|
||||
|
||||
promise_test(async t => {
|
||||
const root = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
|
||||
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(t, 'SecurityError', root.removeEntry(path_with_separator),
|
||||
`removeEntry() must reject names containing "${kPathSeparators[i]}"`);
|
||||
}
|
||||
}, 'removeEntry() with a path separator should fail.');
|
||||
|
|
|
@ -10,7 +10,7 @@ promise_test(async t => {
|
|||
promise_test(async t => {
|
||||
const root = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const handle = await root.getDirectory('non-existing-dir', { create: true });
|
||||
t.add_cleanup(() => handle.removeRecursively());
|
||||
t.add_cleanup(() => root.removeEntry('non-existing-dir', { recursive: true }));
|
||||
|
||||
assert_false(handle.isFile);
|
||||
assert_true(handle.isDirectory);
|
||||
|
@ -22,7 +22,7 @@ promise_test(async t => {
|
|||
promise_test(async t => {
|
||||
const root = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const existing_handle = await root.getDirectory('dir-with-contents', { create: true });
|
||||
t.add_cleanup(() => existing_handle.removeRecursively());
|
||||
t.add_cleanup(() => root.removeEntry('dir-with-contents', { recursive: true }));
|
||||
const file_handle = await createEmptyFile(t, 'test-file', existing_handle);
|
||||
|
||||
const handle = await root.getDirectory('dir-with-contents', { create: false });
|
||||
|
@ -36,7 +36,7 @@ promise_test(async t => {
|
|||
promise_test(async t => {
|
||||
const root = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const existing_handle = await root.getDirectory('dir-with-contents', { create: true });
|
||||
t.add_cleanup(() => existing_handle.removeRecursively());
|
||||
t.add_cleanup(() => root.removeEntry('dir-with-contents', { recursive: true }));
|
||||
const file_handle = await existing_handle.getFile('test-file', { create: true });
|
||||
|
||||
const handle = await root.getDirectory('dir-with-contents', { create: true });
|
||||
|
|
|
@ -10,7 +10,7 @@ promise_test(async t => {
|
|||
promise_test(async t => {
|
||||
const dir = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const handle = await dir.getFile('non-existing-file', { create: true });
|
||||
t.add_cleanup(() => handle.remove());
|
||||
t.add_cleanup(() => dir.removeEntry('non-existing-file'));
|
||||
|
||||
assert_true(handle.isFile);
|
||||
assert_false(handle.isDirectory);
|
||||
|
@ -48,7 +48,7 @@ promise_test(async t => {
|
|||
promise_test(async t => {
|
||||
const dir = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const dir_handle = await dir.getDirectory('dir-name', { create: true });
|
||||
t.add_cleanup(() => dir_handle.removeRecursively());
|
||||
t.add_cleanup(() => dir.removeEntry('dir-name', { recursive: true }));
|
||||
|
||||
await promise_rejects(t, 'TypeMismatchError', dir.getFile('dir-name'));
|
||||
}, 'getFile(create=false) when a directory already exists with the same name');
|
||||
|
@ -56,7 +56,7 @@ promise_test(async t => {
|
|||
promise_test(async t => {
|
||||
const dir = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
const dir_handle = await dir.getDirectory('dir-name', { create: true });
|
||||
t.add_cleanup(() => dir_handle.removeRecursively());
|
||||
t.add_cleanup(() => dir.removeEntry('dir-name', { recursive: true }));
|
||||
|
||||
await promise_rejects(t, 'TypeMismatchError', dir.getFile('dir-name', { create: true }));
|
||||
}, 'getFile(create=true) when a directory already exists with the same name');
|
||||
|
|
|
@ -15,12 +15,8 @@ if (navigator.userAgent.includes("Windows NT")) {
|
|||
|
||||
async function cleanupSandboxedFileSystem() {
|
||||
const dir = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' });
|
||||
for await (let entry of dir.getEntries()) {
|
||||
if (entry.isDirectory)
|
||||
await entry.removeRecursively();
|
||||
else
|
||||
await entry.remove();
|
||||
}
|
||||
for await (let entry of dir.getEntries())
|
||||
dir.removeEntry(entry.name, { recursive: entry.isDirectory });
|
||||
}
|
||||
|
||||
async function getFileSize(handle) {
|
||||
|
@ -60,7 +56,7 @@ async function createDirectory(test, name, parent) {
|
|||
const new_dir_handle = await parent_dir_handle.getDirectory(name, { create: true });
|
||||
test.add_cleanup(async () => {
|
||||
try {
|
||||
await new_dir_handle.removeRecursively();
|
||||
await parent_dir_handle.removeEntry(name, { recursive: true });
|
||||
} catch (e) {
|
||||
// Ignore any errors when removing directories, as tests might
|
||||
// have already removed the directory.
|
||||
|
@ -74,7 +70,7 @@ async function createEmptyFile(test, name, parent) {
|
|||
const handle = await dir.getFile(name, { create: true });
|
||||
test.add_cleanup(async () => {
|
||||
try {
|
||||
await handle.remove();
|
||||
await dir.removeEntry(name);
|
||||
} catch (e) {
|
||||
// Ignore any errors when removing files, as tests might already remove the file.
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue