FSA: Add WPTs for isSameEntry on handles pointing to the same path

Handles of the same type pointing to the same path should be considered
the same handle, even if the underlying entry of the original handle was
at one point removed.

It's impossible for a file and directory of the same path to exist on
disk simultaneously, but it IS possible for a FileSystemFileHandle and
FileSystemDirectoryHandle of the same path to exist simultaneously,
since handles are still valid even if their backing store is removed.

Change-Id: If0deb9e6ea64e228b3c54e14711c58a9e378142c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3771038
Auto-Submit: Austin Sullivan <asully@chromium.org>
Reviewed-by: Joshua Bell <jsbell@chromium.org>
Commit-Queue: Joshua Bell <jsbell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1026308}
diff --git a/fs/script-tests/FileSystemBaseHandle-isSameEntry.js b/fs/script-tests/FileSystemBaseHandle-isSameEntry.js
index 8c0b352..e3b6d18 100644
--- a/fs/script-tests/FileSystemBaseHandle-isSameEntry.js
+++ b/fs/script-tests/FileSystemBaseHandle-isSameEntry.js
@@ -60,3 +60,48 @@
   assert_false(await handle1.isSameEntry(handle2));
   assert_false(await handle2.isSameEntry(handle1));
 }, 'isSameEntry comparing a file to a directory returns false');
+
+directory_test(async (t, root_dir) => {
+  const filename = 'foo';
+  const handle1 = await createEmptyFile(t, filename, root_dir);
+  // Remove the file and create a new file of the same path.
+  await root_dir.removeEntry(filename);
+  const handle2 = await createEmptyFile(t, filename, root_dir);
+
+  assert_true(
+      await handle1.isSameEntry(handle2),
+      'two file handles pointing at the same path should be considered the same entry');
+  assert_true(
+      await handle2.isSameEntry(handle1),
+      'two file handles pointing at the same path should be considered the same entry');
+}, 'isSameEntry comparing two files pointing to the same path returns true');
+
+directory_test(async (t, root_dir) => {
+  const filename = 'foo';
+  const handle1 = await createDirectory(t, filename, root_dir);
+  // Remove the directory and create a new directory of the same path.
+  await root_dir.removeEntry(filename);
+  const handle2 = await createDirectory(t, filename, root_dir);
+
+  assert_true(
+      await handle1.isSameEntry(handle2),
+      'two directory handles pointing at the same path should be considered the same entry');
+  assert_true(
+      await handle2.isSameEntry(handle1),
+      'two directory handles pointing at the same path should be considered the same entry');
+}, 'isSameEntry comparing two directories pointing to the same path returns true');
+
+directory_test(async (t, root_dir) => {
+  const filename = 'foo';
+  const dir_handle = await createDirectory(t, filename, root_dir);
+  // Remove the directory and create a file of the same path.
+  await root_dir.removeEntry(filename);
+  const file_handle = await createEmptyFile(t, filename, root_dir);
+
+  assert_false(
+      await dir_handle.isSameEntry(file_handle),
+      'a file and directory handle pointing at the same path should not be considered the same entry');
+  assert_false(
+      await file_handle.isSameEntry(dir_handle),
+      'a file and directory handle pointing at the same path should not be considered the same entry');
+}, 'isSameEntry comparing a file to a directory of the same path returns false');