forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dummy implementation of getUniqueId that allows for developers to start experimenting with this method behind a flag. The returned ID is not stable across browsing sessions. Bug: 1342961 Change-Id: I1938083ca801ec5f3db0264384625cf638523315 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3933798 Commit-Queue: Austin Sullivan <[email protected]> Reviewed-by: Nasko Oskov <[email protected]> Reviewed-by: Daseul Lee <[email protected]> Auto-Submit: Austin Sullivan <[email protected]> Cr-Commit-Position: refs/heads/main@{#1056133}
- Loading branch information
1 parent
dd09af7
commit f10830b
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
file-system-access/local_FileSystemBaseHandle-getUniqueId-manual.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/local-fs-test-helpers.js"></script> | ||
<script src="../fs/script-tests/FileSystemBaseHandle-getUniqueId.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// META: script=resources/test-helpers.js | ||
// META: script=resources/sandboxed-fs-test-helpers.js | ||
// META: script=script-tests/FileSystemBaseHandle-getUniqueId.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
'use strict'; | ||
|
||
directory_test(async (t, root_dir) => { | ||
assert_equals(await root_dir.getUniqueId(), await root_dir.getUniqueId()); | ||
|
||
const subdir = await createDirectory(t, 'subdir-name', root_dir); | ||
assert_equals(await subdir.getUniqueId(), await subdir.getUniqueId()); | ||
}, 'identical directory handles return the same ID'); | ||
|
||
directory_test(async (t, root_dir) => { | ||
const subdir = await createDirectory(t, 'subdir-name', root_dir); | ||
|
||
assert_not_equals(await root_dir.getUniqueId(), await subdir.getUniqueId()); | ||
}, 'different directories return different IDs'); | ||
|
||
directory_test(async (t, root_dir) => { | ||
const subdir = await createDirectory(t, 'subdir-name', root_dir); | ||
const subdir2 = await root_dir.getDirectoryHandle('subdir-name'); | ||
|
||
assert_equals(await subdir.getUniqueId(), await subdir2.getUniqueId()); | ||
}, 'different handles for the same directory return the same ID'); | ||
|
||
directory_test(async (t, root_dir) => { | ||
const handle = await createEmptyFile(t, 'foo.txt', root_dir); | ||
|
||
assert_equals(await handle.getUniqueId(), await handle.getUniqueId()); | ||
}, 'identical file handles return the same unique ID'); | ||
|
||
directory_test(async (t, root_dir) => { | ||
const handle1 = await createEmptyFile(t, 'foo.txt', root_dir); | ||
const handle2 = await createEmptyFile(t, 'bar.txt', root_dir); | ||
|
||
assert_not_equals(await handle1.getUniqueId(), await handle2.getUniqueId()); | ||
}, 'different files return different IDs'); | ||
|
||
directory_test(async (t, root_dir) => { | ||
const handle1 = await createEmptyFile(t, 'foo.txt', root_dir); | ||
const handle2 = await root_dir.getFileHandle('foo.txt'); | ||
|
||
assert_equals(await handle1.getUniqueId(), await handle2.getUniqueId()); | ||
}, 'different handles for the same file return the same ID'); | ||
|
||
directory_test(async (t, root_dir) => { | ||
const handle1 = await createEmptyFile(t, 'foo.txt', root_dir); | ||
const subdir = await createDirectory(t, 'subdir-name', root_dir); | ||
const handle2 = await createEmptyFile(t, 'foo.txt', subdir); | ||
|
||
assert_not_equals(await handle1.getUniqueId(), await handle2.getUniqueId()); | ||
}, 'two files of the same name in different directories return different IDs'); | ||
|
||
directory_test(async (t, root_dir) => { | ||
const handle1 = await createEmptyFile(t, 'foo.txt', root_dir); | ||
const handle2 = await createDirectory(t, 'subdir-name', root_dir); | ||
|
||
assert_not_equals(await handle1.getUniqueId(), await handle2.getUniqueId()); | ||
}, 'a file and a directory return different IDs'); | ||
|
||
directory_test(async (t, root_dir) => { | ||
const file_handle = await createEmptyFile(t, 'foo', root_dir); | ||
const file_id = await file_handle.getUniqueId(); | ||
|
||
// Remove the file. | ||
await root_dir.removeEntry('foo'); | ||
|
||
// Create a directory of the same name and path. | ||
const dir_handle = await createDirectory(t, 'foo', root_dir); | ||
assert_not_equals(await dir_handle.getUniqueId(), file_id); | ||
}, 'a file and a directory of the same path return different IDs'); | ||
|
||
directory_test(async (t, root_dir) => { | ||
const handle = await createEmptyFile(t, 'foo.txt', root_dir); | ||
const id_before = await handle.getUniqueId(); | ||
|
||
// Write to the file. The unique ID should not change. | ||
const writable = await handle.createWritable(); | ||
await writable.write("blah"); | ||
await writable.close(); | ||
|
||
assert_equals(await handle.getUniqueId(), id_before); | ||
}, 'unique ID of a file handle does not change after writes'); | ||
|
||
directory_test(async (t, root_dir) => { | ||
const subdir = await createDirectory(t, 'subdir-name', root_dir); | ||
|
||
const UUIDRegex = | ||
/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/ | ||
assert_true(UUIDRegex.test(await root_dir.getUniqueId())); | ||
assert_true(UUIDRegex.test(await subdir.getUniqueId())); | ||
}, 'unique ID is in GUID version 4 format'); |