gecko-dev/testing/web-platform/tests/native-file-system/script-tests/FileSystemBaseHandle-isSameEntry.js
Marijn Kruisselbrink 2876aa5216 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
2020-03-13 16:46:37 +00:00

62 lines
2.5 KiB
JavaScript

'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');