зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1784405: Fixes for OPFS web-platform tests r=smaug
Depends on D150665 Differential Revision: https://phabricator.services.mozilla.com/D154482
This commit is contained in:
Родитель
297df7cf98
Коммит
55aa3bd13c
|
@ -26,7 +26,7 @@
|
|||
[removeEntry() with a path separator should fail.]
|
||||
expected: FAIL
|
||||
|
||||
[removeEntry() while the file has an open writable succeeds]
|
||||
[removeEntry() while the file has an open writable fails]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
|
@ -58,5 +58,5 @@
|
|||
[removeEntry() with a path separator should fail.]
|
||||
expected: FAIL
|
||||
|
||||
[removeEntry() while the file has an open writable succeeds]
|
||||
[removeEntry() while the file has an open writable fails]
|
||||
expected: FAIL
|
||||
|
|
|
@ -30,12 +30,17 @@ async function serialize_handle(handle) {
|
|||
// serialized properties shared by both FileSystemFileHandle and
|
||||
// FileSystemDirectoryHandle.
|
||||
async function serialize_file_system_handle(handle) {
|
||||
const read_permission =
|
||||
await handle.queryPermission({ mode: 'read' });
|
||||
|
||||
const write_permission =
|
||||
await handle.queryPermission({ mode: 'readwrite' })
|
||||
let read_permission = "granted";
|
||||
let write_permission = "granted";
|
||||
// query-permission is part of the File System Acecss API
|
||||
// https://wicg.github.io/file-system-access, which may not be supported
|
||||
if ("queryPermission" in FileSystemHandle.prototype) {
|
||||
read_permission =
|
||||
await handle.queryPermission({ mode: 'read' });
|
||||
|
||||
write_permission =
|
||||
await handle.queryPermission({ mode: 'readwrite' })
|
||||
}
|
||||
return {
|
||||
kind: handle.kind,
|
||||
name: handle.name,
|
||||
|
|
|
@ -86,3 +86,21 @@ function garbageCollect() {
|
|||
if (self.gc)
|
||||
self.gc();
|
||||
};
|
||||
|
||||
async function cleanup(test, value, cleanup_func) {
|
||||
test.add_cleanup(async () => {
|
||||
try {
|
||||
await cleanup_func();
|
||||
} catch (e) {
|
||||
// Ignore any errors when removing files, as tests might already remove
|
||||
// the file.
|
||||
}
|
||||
});
|
||||
return value;
|
||||
}
|
||||
|
||||
async function cleanup_writable(test, value) {
|
||||
return cleanup(test, value, async () => {
|
||||
value.close();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ directory_test(async (t, root_dir) => {
|
|||
const db = await createDatabase(t, db => {
|
||||
const store = db.createObjectStore('store');
|
||||
});
|
||||
t.add_cleanup(() => deleteAllDatabases(t));
|
||||
|
||||
const value = handles;
|
||||
|
||||
|
@ -28,7 +27,6 @@ directory_test(async (t, root_dir) => {
|
|||
const db = await createDatabase(t, db => {
|
||||
const store = db.createObjectStore('store');
|
||||
});
|
||||
t.add_cleanup(() => deleteAllDatabases(t));
|
||||
|
||||
const value = handles;
|
||||
|
||||
|
@ -53,7 +51,6 @@ directory_test(async (t, root_dir) => {
|
|||
const db = await createDatabase(t, db => {
|
||||
const store = db.createObjectStore('store');
|
||||
});
|
||||
t.add_cleanup(() => deleteAllDatabases(t));
|
||||
|
||||
const value = {handles, blob: new Blob(["foobar"])};
|
||||
|
||||
|
@ -80,7 +77,6 @@ directory_test(async (t, root_dir) => {
|
|||
const db = await createDatabase(t, db => {
|
||||
const store = db.createObjectStore('store');
|
||||
});
|
||||
t.add_cleanup(() => deleteAllDatabases(t));
|
||||
|
||||
const value = handles;
|
||||
|
||||
|
@ -107,7 +103,6 @@ directory_test(async (t, root_dir) => {
|
|||
const db = await createDatabase(t, db => {
|
||||
const store = db.createObjectStore('store', {keyPath: 'key'});
|
||||
});
|
||||
t.add_cleanup(() => deleteAllDatabases(t));
|
||||
|
||||
const value = handles;
|
||||
let tx = db.transaction('store', 'readwrite');
|
||||
|
|
|
@ -23,7 +23,6 @@ directory_test(async (t, 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) => {
|
||||
|
@ -93,11 +92,13 @@ directory_test(async (t, root) => {
|
|||
await createFileWithContents(t, 'file-to-keep', 'abc', root);
|
||||
|
||||
const writable = await handle.createWritable();
|
||||
await root.removeEntry('file-to-remove');
|
||||
await promise_rejects_dom(t, 'NotFoundError', getFileContents(handle));
|
||||
await promise_rejects_dom(
|
||||
t, 'InvalidModificationError', root.removeEntry('file-to-remove'));
|
||||
|
||||
await writable.close();
|
||||
await root.removeEntry('file-to-remove');
|
||||
|
||||
assert_array_equals(
|
||||
await getSortedDirectoryEntries(root),
|
||||
['file-to-keep', 'file-to-remove']);
|
||||
}, 'removeEntry() while the file has an open writable succeeds');
|
||||
['file-to-keep']);
|
||||
}, 'removeEntry() while the file has an open writable fails');
|
||||
|
|
|
@ -74,7 +74,7 @@ directory_test(async (t, root) => {
|
|||
const handle = await createFileWithContents(t, 'file-before', 'abc', root);
|
||||
|
||||
// Cannot rename handle with an active writable.
|
||||
const stream = await handle.createWritable();
|
||||
const stream = await cleanup_writable(t, await handle.createWritable());
|
||||
await promise_rejects_dom(
|
||||
t, 'NoModificationAllowedError', handle.move('file-after'));
|
||||
|
||||
|
@ -90,7 +90,7 @@ directory_test(async (t, root) => {
|
|||
await createFileWithContents(t, 'file-after', '123', root);
|
||||
|
||||
// Cannot overwrite a handle with an active writable.
|
||||
const stream = await handle_dest.createWritable();
|
||||
const stream = await cleanup_writable(t, await handle_dest.createWritable());
|
||||
await promise_rejects_dom(
|
||||
t, 'NoModificationAllowedError', handle.move('file-after'));
|
||||
|
||||
|
@ -259,7 +259,7 @@ directory_test(async (t, root) => {
|
|||
const file = await createFileWithContents(t, 'file', 'abc', dir_src);
|
||||
|
||||
// Cannot move handle with an active writable.
|
||||
const stream = await file.createWritable();
|
||||
const stream = await cleanup_writable(t, await file.createWritable());
|
||||
await promise_rejects_dom(t, 'NoModificationAllowedError', file.move(dir_dest));
|
||||
|
||||
assert_array_equals(
|
||||
|
@ -282,7 +282,7 @@ directory_test(async (t, root) => {
|
|||
const file = await createFileWithContents(t, 'file-before', 'abc', dir_src);
|
||||
|
||||
// Cannot move handle with an active writable.
|
||||
const stream = await file.createWritable();
|
||||
const stream = await cleanup_writable(t, await file.createWritable());
|
||||
await promise_rejects_dom(t, 'NoModificationAllowedError', file.move(dir_dest));
|
||||
|
||||
assert_array_equals(
|
||||
|
@ -307,7 +307,7 @@ directory_test(async (t, root) => {
|
|||
const file_dest = await createFileWithContents(t, 'file', '123', dir_dest);
|
||||
|
||||
// Cannot overwrite handle with an active writable.
|
||||
const stream = await file_dest.createWritable();
|
||||
const stream = await cleanup_writable(t, await file_dest.createWritable());
|
||||
await promise_rejects_dom(t, 'NoModificationAllowedError', file.move(dir_dest));
|
||||
|
||||
assert_array_equals(
|
||||
|
@ -334,7 +334,7 @@ directory_test(async (t, root) => {
|
|||
await createFileWithContents(t, 'file-dest', '123', dir_dest);
|
||||
|
||||
// Cannot overwrite handle with an active writable.
|
||||
const stream = await file_dest.createWritable();
|
||||
const stream = await cleanup_writable(t, await file_dest.createWritable());
|
||||
await promise_rejects_dom(
|
||||
t, 'NoModificationAllowedError', file.move(dir_dest, 'file-dest'));
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче