From 553ab1a48e7d387b5d78f79444525376a931bb76 Mon Sep 17 00:00:00 2001 From: Stephen McGruer Date: Thu, 11 Jun 2020 18:05:53 -0400 Subject: [PATCH] Update interfaces/native-file-system.idl and test (#24121) Closes https://github.com/web-platform-tests/wpt/pull/22162 --- interfaces/native-file-system.idl | 46 +++++++++++++--------- native-file-system/idlharness.https.any.js | 2 +- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/interfaces/native-file-system.idl b/interfaces/native-file-system.idl index f4679175c46ec7..60a28f055ded93 100644 --- a/interfaces/native-file-system.idl +++ b/interfaces/native-file-system.idl @@ -13,18 +13,20 @@ interface FileSystemHandle { readonly attribute boolean isDirectory; readonly attribute USVString name; + Promise isSameEntry(FileSystemHandle other); + Promise queryPermission(optional FileSystemHandlePermissionDescriptor descriptor = {}); Promise requestPermission(optional FileSystemHandlePermissionDescriptor descriptor = {}); }; -dictionary FileSystemCreateWriterOptions { +dictionary FileSystemCreateWritableOptions { boolean keepExistingData = false; }; [Exposed=(Window,Worker), SecureContext, Serializable] interface FileSystemFileHandle : FileSystemHandle { Promise getFile(); - Promise createWriter(optional FileSystemCreateWriterOptions options = {}); + Promise createWritable(optional FileSystemCreateWritableOptions options = {}); }; dictionary FileSystemGetFileOptions { @@ -41,20 +43,36 @@ dictionary FileSystemRemoveOptions { [Exposed=(Window,Worker), SecureContext, Serializable] interface FileSystemDirectoryHandle : FileSystemHandle { + async iterable; + Promise getFile(USVString name, optional FileSystemGetFileOptions options = {}); Promise getDirectory(USVString name, optional FileSystemGetDirectoryOptions options = {}); - // This really returns an async iterable, but that is not yet expressable in WebIDL. - object getEntries(); - Promise removeEntry(USVString name, optional FileSystemRemoveOptions options = {}); + + Promise?> resolve(FileSystemHandle possibleDescendant); }; +enum WriteCommandType { + "write", + "seek", + "truncate", +}; + +dictionary WriteParams { + required WriteCommandType type; + unsigned long long? size; + unsigned long long? position; + (BufferSource or Blob or USVString)? data; +}; + +typedef (BufferSource or Blob or USVString or WriteParams) FileSystemWriteChunkType; + [Exposed=(Window,Worker), SecureContext] -interface FileSystemWriter { - Promise write(unsigned long long position, (BufferSource or Blob or USVString) data); +interface FileSystemWritableFileStream : WritableStream { + Promise write(FileSystemWriteChunkType data); + Promise seek(unsigned long long position); Promise truncate(unsigned long long size); - Promise close(); }; enum ChooseFileSystemEntriesType { "open-file", "save-file", "open-directory" }; @@ -78,15 +96,7 @@ partial interface Window { chooseFileSystemEntries(optional ChooseFileSystemEntriesOptions options = {}); }; -enum SystemDirectoryType { - "sandbox" -}; - -dictionary GetSystemDirectoryOptions { - required SystemDirectoryType type; -}; - [SecureContext] -partial interface FileSystemDirectoryHandle { - static Promise getSystemDirectory(GetSystemDirectoryOptions options); +partial interface mixin WindowOrWorkerGlobalScope { + Promise getOriginPrivateDirectory(); }; diff --git a/native-file-system/idlharness.https.any.js b/native-file-system/idlharness.https.any.js index 98b27fd9e38428..a9090baeee5a9a 100644 --- a/native-file-system/idlharness.https.any.js +++ b/native-file-system/idlharness.https.any.js @@ -6,7 +6,7 @@ idl_test( ['native-file-system'], - ['html', 'dom'], + ['streams', 'html', 'dom'], idl_array => { idl_array.add_objects({ // TODO: Add instances of FileSystemHandle, FileSystemFileHandle,