Bug 1620475 [wpt PR 22110] - [NativeFS] Implement resolve and isSameEntry., a=testonly

Automatic update from web-platform-tests
[NativeFS] Implement resolve and isSameEntry.

These methods let you compare if two handles represent the same entry, and
get the relative path of an entry inside a directory.

Bug: 1021351, 955184
Change-Id: I00f5be46b13c24973e9ad107f885047483656580
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2089955
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Olivier Yiptong <oyiptong@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748485}

--

wpt-commits: ea00820737f30eeb9ef8fad5ed769c1a8863e600
wpt-pr: 22110
This commit is contained in:
Marijn Kruisselbrink 2020-03-12 12:10:16 +00:00 коммит произвёл moz-wptsync-bot
Родитель a472f724f7
Коммит 2876aa5216
6 изменённых файлов: 115 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,10 @@
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<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/FileSystemBaseHandle-isSameEntry.js"></script>

Просмотреть файл

@ -0,0 +1,10 @@
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<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-resolve.js"></script>

Просмотреть файл

@ -0,0 +1,3 @@
// META: script=resources/test-helpers.js
// META: script=resources/sandboxed-fs-test-helpers.js
// META: script=script-tests/FileSystemBaseHandle-isSameEntry.js

Просмотреть файл

@ -0,0 +1,3 @@
// META: script=resources/test-helpers.js
// META: script=resources/sandboxed-fs-test-helpers.js
// META: script=script-tests/FileSystemDirectoryHandle-resolve.js

Просмотреть файл

@ -0,0 +1,62 @@
'use strict';
directory_test(async (t, root_dir) => {
assert_true(await root_dir.isSameEntry(root_dir));
const subdir = await createDirectory(t, 'subdir-name', root_dir);
assert_true(await subdir.isSameEntry(subdir));
}, 'isSameEntry for identical directory handles returns true');
directory_test(async (t, root_dir) => {
const subdir = await createDirectory(t, 'subdir-name', root_dir);
assert_false(await root_dir.isSameEntry(subdir));
assert_false(await subdir.isSameEntry(root_dir));
}, 'isSameEntry for different directories returns false');
directory_test(async (t, root_dir) => {
const subdir = await createDirectory(t, 'subdir-name', root_dir);
const subdir2 = await root_dir.getDirectory('subdir-name');
assert_true(await subdir.isSameEntry(subdir2));
assert_true(await subdir2.isSameEntry(subdir));
}, 'isSameEntry for different handles for the same directory');
directory_test(async (t, root_dir) => {
const handle = await createEmptyFile(t, 'mtime.txt', root_dir);
assert_true(await handle.isSameEntry(handle));
}, 'isSameEntry for identical file handles returns true');
directory_test(async (t, root_dir) => {
const handle1 = await createEmptyFile(t, 'mtime.txt', root_dir);
const handle2 = await createEmptyFile(t, 'foo.txt', root_dir);
assert_false(await handle1.isSameEntry(handle2));
assert_false(await handle2.isSameEntry(handle1));
}, 'isSameEntry for different files returns false');
directory_test(async (t, root_dir) => {
const handle1 = await createEmptyFile(t, 'mtime.txt', root_dir);
const handle2 = await root_dir.getFile('mtime.txt');
assert_true(await handle1.isSameEntry(handle2));
assert_true(await handle2.isSameEntry(handle1));
}, 'isSameEntry for different handles for the same file');
directory_test(async (t, root_dir) => {
const handle1 = await createEmptyFile(t, 'mtime.txt', root_dir);
const subdir = await createDirectory(t, 'subdir-name', root_dir);
const handle2 = await createEmptyFile(t, 'mtime.txt', subdir);
assert_false(await handle1.isSameEntry(handle2));
assert_false(await handle2.isSameEntry(handle1));
}, 'isSameEntry comparing a file to a file in a different directory returns false');
directory_test(async (t, root_dir) => {
const handle1 = await createEmptyFile(t, 'mtime.txt', root_dir);
const handle2 = await createDirectory(t, 'subdir-name', root_dir);
assert_false(await handle1.isSameEntry(handle2));
assert_false(await handle2.isSameEntry(handle1));
}, 'isSameEntry comparing a file to a directory returns false');

Просмотреть файл

@ -0,0 +1,27 @@
'use strict';
directory_test(async (t, root_dir) => {
assert_array_equals(await root_dir.resolve(root_dir), []);
}, 'Resolve returns empty array for same directory');
directory_test(async (t, root_dir) => {
const subdir = await createDirectory(t, 'subdir-name', root_dir);
const file = await createEmptyFile(t, 'file-name', subdir);
assert_array_equals(await root_dir.resolve(file), ['subdir-name', 'file-name']);
}, 'Resolve returns correct path');
directory_test(async (t, root_dir) => {
const subdir = await createDirectory(t, 'subdir😊', root_dir);
const file = await createEmptyFile(t, 'file-name', subdir);
assert_array_equals(await root_dir.resolve(file), ['subdir😊', 'file-name']);
assert_array_equals(await root_dir.resolve(subdir), ['subdir😊']);
}, 'Resolve returns correct path with non-ascii characters');
directory_test(async (t, root_dir) => {
const subdir = await createDirectory(t, 'subdir-name', root_dir);
const file = await createEmptyFile(t, 'file-name', root_dir);
assert_equals(await subdir.resolve(file), null);
}, 'Resolve returns null when entry is not a child');