FileSystemBaseHandle-isSameEntry.js (4592B)
1 'use strict'; 2 3 directory_test(async (t, root_dir) => { 4 assert_true(await root_dir.isSameEntry(root_dir)); 5 6 const subdir = await createDirectory('subdir-name', root_dir); 7 assert_true(await subdir.isSameEntry(subdir)); 8 }, 'isSameEntry for identical directory handles returns true'); 9 10 directory_test(async (t, root_dir) => { 11 const subdir = await createDirectory('subdir-name', root_dir); 12 13 assert_false(await root_dir.isSameEntry(subdir)); 14 assert_false(await subdir.isSameEntry(root_dir)); 15 }, 'isSameEntry for different directories returns false'); 16 17 directory_test(async (t, root_dir) => { 18 const subdir = await createDirectory('subdir-name', root_dir); 19 const subdir2 = await root_dir.getDirectoryHandle('subdir-name'); 20 21 assert_true(await subdir.isSameEntry(subdir2)); 22 assert_true(await subdir2.isSameEntry(subdir)); 23 }, 'isSameEntry for different handles for the same directory'); 24 25 directory_test(async (t, root_dir) => { 26 const handle = await createEmptyFile('mtime.txt', root_dir); 27 28 assert_true(await handle.isSameEntry(handle)); 29 }, 'isSameEntry for identical file handles returns true'); 30 31 directory_test(async (t, root_dir) => { 32 const handle1 = await createEmptyFile('mtime.txt', root_dir); 33 const handle2 = await createEmptyFile('foo.txt', root_dir); 34 35 assert_false(await handle1.isSameEntry(handle2)); 36 assert_false(await handle2.isSameEntry(handle1)); 37 }, 'isSameEntry for different files returns false'); 38 39 directory_test(async (t, root_dir) => { 40 const handle1 = await createEmptyFile('mtime.txt', root_dir); 41 const handle2 = await root_dir.getFileHandle('mtime.txt'); 42 43 assert_true(await handle1.isSameEntry(handle2)); 44 assert_true(await handle2.isSameEntry(handle1)); 45 }, 'isSameEntry for different handles for the same file'); 46 47 directory_test(async (t, root_dir) => { 48 const handle1 = await createEmptyFile('mtime.txt', root_dir); 49 const subdir = await createDirectory('subdir-name', root_dir); 50 const handle2 = await createEmptyFile('mtime.txt', subdir); 51 52 assert_false(await handle1.isSameEntry(handle2)); 53 assert_false(await handle2.isSameEntry(handle1)); 54 }, 'isSameEntry comparing a file to a file in a different directory returns false'); 55 56 directory_test(async (t, root_dir) => { 57 const handle1 = await createEmptyFile('mtime.txt', root_dir); 58 const handle2 = await createDirectory('subdir-name', root_dir); 59 60 assert_false(await handle1.isSameEntry(handle2)); 61 assert_false(await handle2.isSameEntry(handle1)); 62 }, 'isSameEntry comparing a file to a directory returns false'); 63 64 directory_test(async (t, root_dir) => { 65 const filename = 'foo'; 66 const handle1 = await createEmptyFile(filename, root_dir); 67 // Remove the file and create a new file of the same path. 68 await root_dir.removeEntry(filename); 69 const handle2 = await createEmptyFile(filename, root_dir); 70 71 assert_true( 72 await handle1.isSameEntry(handle2), 73 'two file handles pointing at the same path should be considered the same entry'); 74 assert_true( 75 await handle2.isSameEntry(handle1), 76 'two file handles pointing at the same path should be considered the same entry'); 77 }, 'isSameEntry comparing two files pointing to the same path returns true'); 78 79 directory_test(async (t, root_dir) => { 80 const filename = 'foo'; 81 const handle1 = await createDirectory(filename, root_dir); 82 // Remove the directory and create a new directory of the same path. 83 await root_dir.removeEntry(filename); 84 const handle2 = await createDirectory(filename, root_dir); 85 86 assert_true( 87 await handle1.isSameEntry(handle2), 88 'two directory handles pointing at the same path should be considered the same entry'); 89 assert_true( 90 await handle2.isSameEntry(handle1), 91 'two directory handles pointing at the same path should be considered the same entry'); 92 }, 'isSameEntry comparing two directories pointing to the same path returns true'); 93 94 directory_test(async (t, root_dir) => { 95 const filename = 'foo'; 96 const dir_handle = await createDirectory(filename, root_dir); 97 // Remove the directory and create a file of the same path. 98 await root_dir.removeEntry(filename); 99 const file_handle = await createEmptyFile(filename, root_dir); 100 101 assert_false( 102 await dir_handle.isSameEntry(file_handle), 103 'a file and directory handle pointing at the same path should not be considered the same entry'); 104 assert_false( 105 await file_handle.isSameEntry(dir_handle), 106 'a file and directory handle pointing at the same path should not be considered the same entry'); 107 }, 'isSameEntry comparing a file to a directory of the same path returns false');