зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1651439 [wpt PR 24515] - [NativeFS] Rename getFile/Directory to getXXXHandle., a=testonly
Automatic update from web-platform-tests
[NativeFS] Rename getFile/Directory to getXXXHandle.
Following changes in https://github.com/WICG/native-file-system/pull/196
Bug: 1103022
Change-Id: I4ba11f12cf2e47ec326a09efa7b06fd300402945
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2285670
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786488}
--
wpt-commits: 0f3f2b950d26ab0c88084c1537143e38712cb4b9
wpt-pr: 24515
This commit is contained in:
Родитель
cf9c4d31da
Коммит
d0bf099a85
|
@ -7,4 +7,4 @@
|
|||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="resources/test-helpers.js"></script>
|
||||
<script src="resources/native-fs-test-helpers.js"></script>
|
||||
<script src="script-tests/FileSystemDirectoryHandle-getDirectory.js"></script>
|
||||
<script src="script-tests/FileSystemDirectoryHandle-getDirectoryHandle.js"></script>
|
|
@ -7,4 +7,4 @@
|
|||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="resources/test-helpers.js"></script>
|
||||
<script src="resources/native-fs-test-helpers.js"></script>
|
||||
<script src="script-tests/FileSystemDirectoryHandle-getFile.js"></script>
|
||||
<script src="script-tests/FileSystemDirectoryHandle-getFileHandle.js"></script>
|
|
@ -87,7 +87,7 @@ function add_message_event_handlers(receiver, target, target_origin) {
|
|||
const directory =
|
||||
await self.getOriginPrivateDirectory();
|
||||
const file_handle =
|
||||
await directory.getFile('temp-file', { create: true });
|
||||
await directory.getFileHandle('temp-file', { create: true });
|
||||
message_source.postMessage(
|
||||
{ type: 'receive-file', file_handle },
|
||||
{ targetOrigin: target_origin });
|
||||
|
@ -140,4 +140,4 @@ function add_message_event_handlers(receiver, target, target_origin) {
|
|||
{ targetOrigin: target_origin });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ async function getSortedDirectoryEntries(handle) {
|
|||
}
|
||||
|
||||
async function createDirectory(test, name, parent) {
|
||||
const new_dir_handle = await parent.getDirectory(name, {create: true});
|
||||
const new_dir_handle = await parent.getDirectoryHandle(name, {create: true});
|
||||
test.add_cleanup(async () => {
|
||||
try {
|
||||
await parent.removeEntry(name, {recursive: true});
|
||||
|
@ -57,7 +57,7 @@ async function createDirectory(test, name, parent) {
|
|||
}
|
||||
|
||||
async function createEmptyFile(test, name, parent) {
|
||||
const handle = await parent.getFile(name, {create: true});
|
||||
const handle = await parent.getFileHandle(name, {create: true});
|
||||
test.add_cleanup(async () => {
|
||||
try {
|
||||
await parent.removeEntry(name);
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
// META: script=resources/test-helpers.js
|
||||
// META: script=resources/sandboxed-fs-test-helpers.js
|
||||
// META: script=script-tests/FileSystemDirectoryHandle-getDirectory.js
|
||||
// META: script=script-tests/FileSystemDirectoryHandle-getDirectoryHandle.js
|
|
@ -1,3 +1,3 @@
|
|||
// META: script=resources/test-helpers.js
|
||||
// META: script=resources/sandboxed-fs-test-helpers.js
|
||||
// META: script=script-tests/FileSystemDirectoryHandle-getFile.js
|
||||
// META: script=script-tests/FileSystemDirectoryHandle-getFileHandle.js
|
|
@ -16,7 +16,7 @@ directory_test(async (t, root_dir) => {
|
|||
|
||||
directory_test(async (t, root_dir) => {
|
||||
const subdir = await createDirectory(t, 'subdir-name', root_dir);
|
||||
const subdir2 = await root_dir.getDirectory('subdir-name');
|
||||
const subdir2 = await root_dir.getDirectoryHandle('subdir-name');
|
||||
|
||||
assert_true(await subdir.isSameEntry(subdir2));
|
||||
assert_true(await subdir2.isSameEntry(subdir));
|
||||
|
@ -38,7 +38,7 @@ directory_test(async (t, root_dir) => {
|
|||
|
||||
directory_test(async (t, root_dir) => {
|
||||
const handle1 = await createEmptyFile(t, 'mtime.txt', root_dir);
|
||||
const handle2 = await root_dir.getFile('mtime.txt');
|
||||
const handle2 = await root_dir.getFileHandle('mtime.txt');
|
||||
|
||||
assert_true(await handle1.isSameEntry(handle2));
|
||||
assert_true(await handle2.isSameEntry(handle1));
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
directory_test(async (t, root) => {
|
||||
await promise_rejects_dom(
|
||||
t, 'NotFoundError', root.getDirectory('non-existing-dir'));
|
||||
}, 'getDirectory(create=false) rejects for non-existing directories');
|
||||
t, 'NotFoundError', root.getDirectoryHandle('non-existing-dir'));
|
||||
}, 'getDirectoryHandle(create=false) rejects for non-existing directories');
|
||||
|
||||
directory_test(async (t, root) => {
|
||||
const handle = await root.getDirectory('non-existing-dir', {create: true});
|
||||
const handle =
|
||||
await root.getDirectoryHandle('non-existing-dir', {create: true});
|
||||
t.add_cleanup(() => root.removeEntry('non-existing-dir', {recursive: true}));
|
||||
|
||||
assert_false(handle.isFile);
|
||||
|
@ -13,70 +14,75 @@ directory_test(async (t, root) => {
|
|||
assert_equals(await getDirectoryEntryCount(handle), 0);
|
||||
assert_array_equals(
|
||||
await getSortedDirectoryEntries(root), ['non-existing-dir/']);
|
||||
}, 'getDirectory(create=true) creates an empty directory');
|
||||
}, 'getDirectoryHandle(create=true) creates an empty directory');
|
||||
|
||||
directory_test(async (t, root) => {
|
||||
const existing_handle =
|
||||
await root.getDirectory('dir-with-contents', {create: true});
|
||||
await root.getDirectoryHandle('dir-with-contents', {create: true});
|
||||
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});
|
||||
const handle =
|
||||
await root.getDirectoryHandle('dir-with-contents', {create: false});
|
||||
|
||||
assert_false(handle.isFile);
|
||||
assert_true(handle.isDirectory);
|
||||
assert_equals(handle.name, 'dir-with-contents');
|
||||
assert_array_equals(await getSortedDirectoryEntries(handle), ['test-file']);
|
||||
}, 'getDirectory(create=false) returns existing directories');
|
||||
}, 'getDirectoryHandle(create=false) returns existing directories');
|
||||
|
||||
directory_test(async (t, root) => {
|
||||
const existing_handle =
|
||||
await root.getDirectory('dir-with-contents', {create: true});
|
||||
await root.getDirectoryHandle('dir-with-contents', {create: true});
|
||||
t.add_cleanup(() => root.removeEntry('dir-with-contents', {recursive: true}));
|
||||
const file_handle =
|
||||
await existing_handle.getFile('test-file', {create: true});
|
||||
await existing_handle.getFileHandle('test-file', {create: true});
|
||||
|
||||
const handle = await root.getDirectory('dir-with-contents', {create: true});
|
||||
const handle =
|
||||
await root.getDirectoryHandle('dir-with-contents', {create: true});
|
||||
|
||||
assert_false(handle.isFile);
|
||||
assert_true(handle.isDirectory);
|
||||
assert_equals(handle.name, 'dir-with-contents');
|
||||
assert_array_equals(await getSortedDirectoryEntries(handle), ['test-file']);
|
||||
}, 'getDirectory(create=true) returns existing directories without erasing');
|
||||
}, 'getDirectoryHandle(create=true) returns existing directories without erasing');
|
||||
|
||||
directory_test(async (t, root) => {
|
||||
await createEmptyFile(t, 'file-name', root);
|
||||
|
||||
await promise_rejects_dom(t, 'TypeMismatchError', root.getDirectory('file-name'));
|
||||
await promise_rejects_dom(
|
||||
t, 'TypeMismatchError', root.getDirectory('file-name', {create: false}));
|
||||
t, 'TypeMismatchError', root.getDirectoryHandle('file-name'));
|
||||
await promise_rejects_dom(
|
||||
t, 'TypeMismatchError', root.getDirectory('file-name', {create: true}));
|
||||
}, 'getDirectory() when a file already exists with the same name');
|
||||
t, 'TypeMismatchError',
|
||||
root.getDirectoryHandle('file-name', {create: false}));
|
||||
await promise_rejects_dom(
|
||||
t, 'TypeMismatchError',
|
||||
root.getDirectoryHandle('file-name', {create: true}));
|
||||
}, 'getDirectoryHandle() when a file already exists with the same name');
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
await promise_rejects_js(
|
||||
t, TypeError, dir.getDirectory('', {create: true}));
|
||||
t, TypeError, dir.getDirectoryHandle('', {create: true}));
|
||||
await promise_rejects_js(
|
||||
t, TypeError, dir.getDirectory('', {create: false}));
|
||||
}, 'getDirectory() with empty name');
|
||||
t, TypeError, dir.getDirectoryHandle('', {create: false}));
|
||||
}, 'getDirectoryHandle() with empty name');
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
await promise_rejects_js(
|
||||
t, TypeError, dir.getDirectory(kCurrentDirectory));
|
||||
t, TypeError, dir.getDirectoryHandle(kCurrentDirectory));
|
||||
await promise_rejects_js(
|
||||
t, TypeError, dir.getDirectory(kCurrentDirectory, {create: true}));
|
||||
}, `getDirectory() with "${kCurrentDirectory}" name`);
|
||||
t, TypeError, dir.getDirectoryHandle(kCurrentDirectory, {create: true}));
|
||||
}, `getDirectoryHandle() with "${kCurrentDirectory}" name`);
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
const subdir = await createDirectory(t, 'subdir-name', /*parent=*/ dir);
|
||||
|
||||
await promise_rejects_js(
|
||||
t, TypeError, subdir.getDirectory(kParentDirectory));
|
||||
t, TypeError, subdir.getDirectoryHandle(kParentDirectory));
|
||||
await promise_rejects_js(
|
||||
t, TypeError,
|
||||
subdir.getDirectory(kParentDirectory, {create: true}));
|
||||
}, `getDirectory() with "${kParentDirectory}" name`);
|
||||
subdir.getDirectoryHandle(kParentDirectory, {create: true}));
|
||||
}, `getDirectoryHandle() with "${kParentDirectory}" name`);
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
const first_subdir_name = 'first-subdir-name';
|
||||
|
@ -91,10 +97,11 @@ directory_test(async (t, dir) => {
|
|||
const path_with_separator =
|
||||
`${first_subdir_name}${kPathSeparators[i]}${second_subdir_name}`;
|
||||
await promise_rejects_js(
|
||||
t, TypeError, dir.getDirectory(path_with_separator),
|
||||
`getDirectory() must reject names containing "${kPathSeparators[i]}"`);
|
||||
t, TypeError, dir.getDirectoryHandle(path_with_separator),
|
||||
`getDirectoryHandle() must reject names containing "${
|
||||
kPathSeparators[i]}"`);
|
||||
}
|
||||
}, 'getDirectory(create=false) with a path separator when the directory exists');
|
||||
}, 'getDirectoryHandle(create=false) with a path separator when the directory exists');
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
const subdir_name = 'subdir-name';
|
||||
|
@ -104,8 +111,8 @@ directory_test(async (t, dir) => {
|
|||
const path_with_separator = `${subdir_name}${kPathSeparators[i]}file_name`;
|
||||
await promise_rejects_js(
|
||||
t, TypeError,
|
||||
dir.getDirectory(path_with_separator, {create: true}),
|
||||
`getDirectory(true) must reject names containing "${
|
||||
dir.getDirectoryHandle(path_with_separator, {create: true}),
|
||||
`getDirectoryHandle(true) must reject names containing "${
|
||||
kPathSeparators[i]}"`);
|
||||
}
|
||||
}, 'getDirectory(create=true) with a path separator');
|
||||
}, 'getDirectoryHandle(create=true) with a path separator');
|
|
@ -1,9 +1,10 @@
|
|||
directory_test(async (t, dir) => {
|
||||
await promise_rejects_dom(t, 'NotFoundError', dir.getFile('non-existing-file'));
|
||||
}, 'getFile(create=false) rejects for non-existing files');
|
||||
await promise_rejects_dom(
|
||||
t, 'NotFoundError', dir.getFileHandle('non-existing-file'));
|
||||
}, 'getFileHandle(create=false) rejects for non-existing files');
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
const handle = await dir.getFile('non-existing-file', {create: true});
|
||||
const handle = await dir.getFileHandle('non-existing-file', {create: true});
|
||||
t.add_cleanup(() => dir.removeEntry('non-existing-file'));
|
||||
|
||||
assert_true(handle.isFile);
|
||||
|
@ -11,65 +12,68 @@ directory_test(async (t, dir) => {
|
|||
assert_equals(handle.name, 'non-existing-file');
|
||||
assert_equals(await getFileSize(handle), 0);
|
||||
assert_equals(await getFileContents(handle), '');
|
||||
}, 'getFile(create=true) creates an empty file for non-existing files');
|
||||
}, 'getFileHandle(create=true) creates an empty file for non-existing files');
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
const existing_handle = await createFileWithContents(
|
||||
t, 'existing-file', '1234567890', /*parent=*/ dir);
|
||||
const handle = await dir.getFile('existing-file');
|
||||
const handle = await dir.getFileHandle('existing-file');
|
||||
|
||||
assert_true(handle.isFile);
|
||||
assert_false(handle.isDirectory);
|
||||
assert_equals(handle.name, 'existing-file');
|
||||
assert_equals(await getFileSize(handle), 10);
|
||||
assert_equals(await getFileContents(handle), '1234567890');
|
||||
}, 'getFile(create=false) returns existing files');
|
||||
}, 'getFileHandle(create=false) returns existing files');
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
const existing_handle = await createFileWithContents(
|
||||
t, 'file-with-contents', '1234567890', /*parent=*/ dir);
|
||||
const handle = await dir.getFile('file-with-contents', {create: true});
|
||||
const handle = await dir.getFileHandle('file-with-contents', {create: true});
|
||||
|
||||
assert_true(handle.isFile);
|
||||
assert_false(handle.isDirectory);
|
||||
assert_equals(handle.name, 'file-with-contents');
|
||||
assert_equals(await getFileSize(handle), 10);
|
||||
assert_equals(await getFileContents(handle), '1234567890');
|
||||
}, 'getFile(create=true) returns existing files without erasing');
|
||||
}, 'getFileHandle(create=true) returns existing files without erasing');
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
const dir_handle = await dir.getDirectory('dir-name', {create: true});
|
||||
t.add_cleanup(() => dir.removeEntry('dir-name', {recursive: true}));
|
||||
|
||||
await promise_rejects_dom(t, 'TypeMismatchError', dir.getFile('dir-name'));
|
||||
}, 'getFile(create=false) when a directory already exists with the same name');
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
const dir_handle = await dir.getDirectory('dir-name', {create: true});
|
||||
const dir_handle = await dir.getDirectoryHandle('dir-name', {create: true});
|
||||
t.add_cleanup(() => dir.removeEntry('dir-name', {recursive: true}));
|
||||
|
||||
await promise_rejects_dom(
|
||||
t, 'TypeMismatchError', dir.getFile('dir-name', {create: true}));
|
||||
}, 'getFile(create=true) when a directory already exists with the same name');
|
||||
t, 'TypeMismatchError', dir.getFileHandle('dir-name'));
|
||||
}, 'getFileHandle(create=false) when a directory already exists with the same name');
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
await promise_rejects_js(t, TypeError, dir.getFile('', {create: true}));
|
||||
await promise_rejects_js(t, TypeError, dir.getFile('', {create: false}));
|
||||
}, 'getFile() with empty name');
|
||||
const dir_handle = await dir.getDirectoryHandle('dir-name', {create: true});
|
||||
t.add_cleanup(() => dir.removeEntry('dir-name', {recursive: true}));
|
||||
|
||||
await promise_rejects_dom(
|
||||
t, 'TypeMismatchError', dir.getFileHandle('dir-name', {create: true}));
|
||||
}, 'getFileHandle(create=true) when a directory already exists with the same name');
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
await promise_rejects_js(t, TypeError, dir.getFile(kCurrentDirectory));
|
||||
await promise_rejects_js(t, TypeError, dir.getFileHandle('', {create: true}));
|
||||
await promise_rejects_js(
|
||||
t, TypeError, dir.getFile(kCurrentDirectory, {create: true}));
|
||||
}, `getFile() with "${kCurrentDirectory}" name`);
|
||||
t, TypeError, dir.getFileHandle('', {create: false}));
|
||||
}, 'getFileHandle() with empty name');
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
await promise_rejects_js(t, TypeError, dir.getFileHandle(kCurrentDirectory));
|
||||
await promise_rejects_js(
|
||||
t, TypeError, dir.getFileHandle(kCurrentDirectory, {create: true}));
|
||||
}, `getFileHandle() with "${kCurrentDirectory}" name`);
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
const subdir = await createDirectory(t, 'subdir-name', /*parent=*/ dir);
|
||||
|
||||
await promise_rejects_js(t, TypeError, subdir.getFile(kParentDirectory));
|
||||
await promise_rejects_js(
|
||||
t, TypeError, subdir.getFile(kParentDirectory, {create: true}));
|
||||
}, `getFile() with "${kParentDirectory}" name`);
|
||||
t, TypeError, subdir.getFileHandle(kParentDirectory));
|
||||
await promise_rejects_js(
|
||||
t, TypeError, subdir.getFileHandle(kParentDirectory, {create: true}));
|
||||
}, `getFileHandle() with "${kParentDirectory}" name`);
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
const subdir_name = 'subdir-name';
|
||||
|
@ -82,10 +86,10 @@ directory_test(async (t, dir) => {
|
|||
const path_with_separator =
|
||||
`${subdir_name}${kPathSeparators[i]}${file_name}`;
|
||||
await promise_rejects_js(
|
||||
t, TypeError, dir.getFile(path_with_separator),
|
||||
`getFile() must reject names containing "${kPathSeparators[i]}"`);
|
||||
t, TypeError, dir.getFileHandle(path_with_separator),
|
||||
`getFileHandle() must reject names containing "${kPathSeparators[i]}"`);
|
||||
}
|
||||
}, 'getFile(create=false) with a path separator when the file exists.');
|
||||
}, 'getFileHandle(create=false) with a path separator when the file exists.');
|
||||
|
||||
directory_test(async (t, dir) => {
|
||||
const subdir_name = 'subdir-name';
|
||||
|
@ -94,7 +98,8 @@ directory_test(async (t, dir) => {
|
|||
for (let i = 0; i < kPathSeparators.length; ++i) {
|
||||
const path_with_separator = `${subdir_name}${kPathSeparators[i]}file_name`;
|
||||
await promise_rejects_js(
|
||||
t, TypeError, dir.getFile(path_with_separator, {create: true}),
|
||||
`getFile(true) must reject names containing "${kPathSeparators[i]}"`);
|
||||
t, TypeError, dir.getFileHandle(path_with_separator, {create: true}),
|
||||
`getFileHandle(create=true) must reject names containing "${
|
||||
kPathSeparators[i]}"`);
|
||||
}
|
||||
}, 'getFile(create=true) with a path separator');
|
||||
}, 'getFileHandle(create=true) with a path separator');
|
|
@ -18,7 +18,7 @@ directory_test(async (t, root) => {
|
|||
}, 'removeEntry() on an already removed file should fail');
|
||||
|
||||
directory_test(async (t, root) => {
|
||||
const dir = await root.getDirectory('dir-to-remove', {create: true});
|
||||
const dir = await root.getDirectoryHandle('dir-to-remove', {create: true});
|
||||
await createFileWithContents(t, 'file-to-keep', 'abc', root);
|
||||
await root.removeEntry('dir-to-remove');
|
||||
|
||||
|
@ -27,7 +27,7 @@ directory_test(async (t, root) => {
|
|||
}, 'removeEntry() to remove an empty directory');
|
||||
|
||||
directory_test(async (t, root) => {
|
||||
const dir = await root.getDirectory('dir-to-remove', {create: true});
|
||||
const dir = await root.getDirectoryHandle('dir-to-remove', {create: true});
|
||||
t.add_cleanup(() => root.removeEntry('dir-to-remove', {recursive: true}));
|
||||
await createEmptyFile(t, 'file-in-dir', dir);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче