Changeset 284814 in webkit
- Timestamp:
- Oct 25, 2021, 12:10:23 PM (5 years ago)
- Location:
- branches/safari-612-branch
- Files:
-
- 3 added
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-close.https.tentative.worker-expected.txt (modified) (1 diff)
-
LayoutTests/storage/filesystemaccess/resources/sync-access-handle-close.js (added)
-
LayoutTests/storage/filesystemaccess/sync-access-handle-close-worker-expected.txt (added)
-
LayoutTests/storage/filesystemaccess/sync-access-handle-close-worker.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/filesystemaccess/FileSystemFileHandle.cpp (modified) (1 diff)
-
Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp (modified) (7 diffs)
-
Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-612-branch/LayoutTests/ChangeLog
r284802 r284814 1 2021-10-25 Null <null@apple.com> 2 3 Cherry-pick r284652. rdar://problem/84517013 4 5 FileSystemSyncAccessHandle should close platform file handle on close() 6 https://bugs.webkit.org/show_bug.cgi?id=232067 7 <rdar://problem/84517013> 8 9 Reviewed by Youenn Fablet. 10 11 LayoutTests/imported/w3c: 12 13 * web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-close.https.tentative.worker-expected.txt: 14 15 Source/WebCore: 16 17 This patch also ensures no request is sent after close() is called. 18 19 Test: storage/filesystemaccess/sync-access-handle-close-worker.html 20 21 * Modules/filesystemaccess/FileSystemFileHandle.cpp: 22 (WebCore::FileSystemFileHandle::createSyncAccessHandle): 23 * Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp: 24 (WebCore::FileSystemSyncAccessHandle::FileSystemSyncAccessHandle): 25 (WebCore::FileSystemSyncAccessHandle::~FileSystemSyncAccessHandle): 26 (WebCore::FileSystemSyncAccessHandle::isClosingOrClosed const): 27 (WebCore::FileSystemSyncAccessHandle::truncate): 28 (WebCore::FileSystemSyncAccessHandle::getSize): 29 (WebCore::FileSystemSyncAccessHandle::flush): 30 (WebCore::FileSystemSyncAccessHandle::close): 31 (WebCore::FileSystemSyncAccessHandle::didClose): 32 (WebCore::FileSystemSyncAccessHandle::read): 33 (WebCore::FileSystemSyncAccessHandle::write): 34 * Modules/filesystemaccess/FileSystemSyncAccessHandle.h: 35 36 LayoutTests: 37 38 * storage/filesystemaccess/resources/sync-access-handle-close.js: Added. 39 (finishTest): 40 (async testFunctions): 41 (async test): 42 * storage/filesystemaccess/sync-access-handle-close-worker-expected.txt: Added. 43 * storage/filesystemaccess/sync-access-handle-close-worker.html: Added. 44 45 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284652 268f45cc-cd09-0410-ab3c-d52691b4dbfc 46 47 2021-10-21 Sihui Liu <sihui_liu@apple.com> 48 49 FileSystemSyncAccessHandle should close platform file handle on close() 50 https://bugs.webkit.org/show_bug.cgi?id=232067 51 <rdar://problem/84517013> 52 53 Reviewed by Youenn Fablet. 54 55 * storage/filesystemaccess/resources/sync-access-handle-close.js: Added. 56 (finishTest): 57 (async testFunctions): 58 (async test): 59 * storage/filesystemaccess/sync-access-handle-close-worker-expected.txt: Added. 60 * storage/filesystemaccess/sync-access-handle-close-worker.html: Added. 61 1 62 2021-10-25 Null <null@apple.com> 2 63 -
branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog
r284804 r284814 1 2021-10-25 Null <null@apple.com> 2 3 Cherry-pick r284652. rdar://problem/84517013 4 5 FileSystemSyncAccessHandle should close platform file handle on close() 6 https://bugs.webkit.org/show_bug.cgi?id=232067 7 <rdar://problem/84517013> 8 9 Reviewed by Youenn Fablet. 10 11 LayoutTests/imported/w3c: 12 13 * web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-close.https.tentative.worker-expected.txt: 14 15 Source/WebCore: 16 17 This patch also ensures no request is sent after close() is called. 18 19 Test: storage/filesystemaccess/sync-access-handle-close-worker.html 20 21 * Modules/filesystemaccess/FileSystemFileHandle.cpp: 22 (WebCore::FileSystemFileHandle::createSyncAccessHandle): 23 * Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp: 24 (WebCore::FileSystemSyncAccessHandle::FileSystemSyncAccessHandle): 25 (WebCore::FileSystemSyncAccessHandle::~FileSystemSyncAccessHandle): 26 (WebCore::FileSystemSyncAccessHandle::isClosingOrClosed const): 27 (WebCore::FileSystemSyncAccessHandle::truncate): 28 (WebCore::FileSystemSyncAccessHandle::getSize): 29 (WebCore::FileSystemSyncAccessHandle::flush): 30 (WebCore::FileSystemSyncAccessHandle::close): 31 (WebCore::FileSystemSyncAccessHandle::didClose): 32 (WebCore::FileSystemSyncAccessHandle::read): 33 (WebCore::FileSystemSyncAccessHandle::write): 34 * Modules/filesystemaccess/FileSystemSyncAccessHandle.h: 35 36 LayoutTests: 37 38 * storage/filesystemaccess/resources/sync-access-handle-close.js: Added. 39 (finishTest): 40 (async testFunctions): 41 (async test): 42 * storage/filesystemaccess/sync-access-handle-close-worker-expected.txt: Added. 43 * storage/filesystemaccess/sync-access-handle-close-worker.html: Added. 44 45 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284652 268f45cc-cd09-0410-ab3c-d52691b4dbfc 46 47 2021-10-21 Sihui Liu <sihui_liu@apple.com> 48 49 FileSystemSyncAccessHandle should close platform file handle on close() 50 https://bugs.webkit.org/show_bug.cgi?id=232067 51 <rdar://problem/84517013> 52 53 Reviewed by Youenn Fablet. 54 55 * web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-close.https.tentative.worker-expected.txt: 56 1 57 2021-10-25 Null <null@apple.com> 2 58 -
branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-close.https.tentative.worker-expected.txt
r284424 r284814 1 1 2 FAIL SyncAccessHandle.close is idempotent promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 3 FAIL SyncAccessHandle.close is idempotent when called immediately promise_test: Unhandled rejection with value: object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." 4 FAIL SyncAccessHandle.read fails after SyncAccessHandle.close settles promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 5 FAIL SyncAccessHandle.read fails immediately after calling SyncAccessHandle.close promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 6 FAIL SyncAccessHandle.write fails after SyncAccessHandle.close settles promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 7 FAIL SyncAccessHandle.write fails immediately after calling SyncAccessHandle.close promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 8 FAIL SyncAccessHandle.flush fails after SyncAccessHandle.close settles promise_rejects_dom: function "function () { throw e }" threw object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11 9 FAIL SyncAccessHandle.flush fails immediately after calling SyncAccessHandle.close promise_rejects_dom: function "function () { throw e }" threw object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11 10 FAIL SyncAccessHandle.getSize fails after SyncAccessHandle.close settles promise_rejects_dom: function "function () { throw e }" threw object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11 11 FAIL SyncAccessHandle.getSize fails immediately after calling SyncAccessHandle.close promise_rejects_dom: function "function () { throw e }" threw object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11 12 FAIL SyncAccessHandle.truncate fails after SyncAccessHandle.close settles promise_rejects_dom: function "function () { throw e }" threw object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11 13 FAIL SyncAccessHandle.truncate fails immediately after calling SyncAccessHandle.close promise_rejects_dom: function "function () { throw e }" threw object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11 2 PASS SyncAccessHandle.close is idempotent 3 PASS SyncAccessHandle.close is idempotent when called immediately 4 PASS SyncAccessHandle.read fails after SyncAccessHandle.close settles 5 PASS SyncAccessHandle.read fails immediately after calling SyncAccessHandle.close 6 PASS SyncAccessHandle.write fails after SyncAccessHandle.close settles 7 PASS SyncAccessHandle.write fails immediately after calling SyncAccessHandle.close 8 PASS SyncAccessHandle.flush fails after SyncAccessHandle.close settles 9 PASS SyncAccessHandle.flush fails immediately after calling SyncAccessHandle.close 10 PASS SyncAccessHandle.getSize fails after SyncAccessHandle.close settles 11 PASS SyncAccessHandle.getSize fails immediately after calling SyncAccessHandle.close 12 PASS SyncAccessHandle.truncate fails after SyncAccessHandle.close settles 13 PASS SyncAccessHandle.truncate fails immediately after calling SyncAccessHandle.close 14 14 -
branches/safari-612-branch/Source/WebCore/ChangeLog
r284804 r284814 1 2021-10-25 Null <null@apple.com> 2 3 Cherry-pick r284652. rdar://problem/84517013 4 5 FileSystemSyncAccessHandle should close platform file handle on close() 6 https://bugs.webkit.org/show_bug.cgi?id=232067 7 <rdar://problem/84517013> 8 9 Reviewed by Youenn Fablet. 10 11 LayoutTests/imported/w3c: 12 13 * web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-close.https.tentative.worker-expected.txt: 14 15 Source/WebCore: 16 17 This patch also ensures no request is sent after close() is called. 18 19 Test: storage/filesystemaccess/sync-access-handle-close-worker.html 20 21 * Modules/filesystemaccess/FileSystemFileHandle.cpp: 22 (WebCore::FileSystemFileHandle::createSyncAccessHandle): 23 * Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp: 24 (WebCore::FileSystemSyncAccessHandle::FileSystemSyncAccessHandle): 25 (WebCore::FileSystemSyncAccessHandle::~FileSystemSyncAccessHandle): 26 (WebCore::FileSystemSyncAccessHandle::isClosingOrClosed const): 27 (WebCore::FileSystemSyncAccessHandle::truncate): 28 (WebCore::FileSystemSyncAccessHandle::getSize): 29 (WebCore::FileSystemSyncAccessHandle::flush): 30 (WebCore::FileSystemSyncAccessHandle::close): 31 (WebCore::FileSystemSyncAccessHandle::didClose): 32 (WebCore::FileSystemSyncAccessHandle::read): 33 (WebCore::FileSystemSyncAccessHandle::write): 34 * Modules/filesystemaccess/FileSystemSyncAccessHandle.h: 35 36 LayoutTests: 37 38 * storage/filesystemaccess/resources/sync-access-handle-close.js: Added. 39 (finishTest): 40 (async testFunctions): 41 (async test): 42 * storage/filesystemaccess/sync-access-handle-close-worker-expected.txt: Added. 43 * storage/filesystemaccess/sync-access-handle-close-worker.html: Added. 44 45 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284652 268f45cc-cd09-0410-ab3c-d52691b4dbfc 46 47 2021-10-21 Sihui Liu <sihui_liu@apple.com> 48 49 FileSystemSyncAccessHandle should close platform file handle on close() 50 https://bugs.webkit.org/show_bug.cgi?id=232067 51 <rdar://problem/84517013> 52 53 Reviewed by Youenn Fablet. 54 55 This patch also ensures no request is sent after close() is called. 56 57 Test: storage/filesystemaccess/sync-access-handle-close-worker.html 58 59 * Modules/filesystemaccess/FileSystemFileHandle.cpp: 60 (WebCore::FileSystemFileHandle::createSyncAccessHandle): 61 * Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp: 62 (WebCore::FileSystemSyncAccessHandle::FileSystemSyncAccessHandle): 63 (WebCore::FileSystemSyncAccessHandle::~FileSystemSyncAccessHandle): 64 (WebCore::FileSystemSyncAccessHandle::isClosingOrClosed const): 65 (WebCore::FileSystemSyncAccessHandle::truncate): 66 (WebCore::FileSystemSyncAccessHandle::getSize): 67 (WebCore::FileSystemSyncAccessHandle::flush): 68 (WebCore::FileSystemSyncAccessHandle::close): 69 (WebCore::FileSystemSyncAccessHandle::didClose): 70 (WebCore::FileSystemSyncAccessHandle::read): 71 (WebCore::FileSystemSyncAccessHandle::write): 72 * Modules/filesystemaccess/FileSystemSyncAccessHandle.h: 73 1 74 2021-10-25 Null <null@apple.com> 2 75 -
branches/safari-612-branch/Source/WebCore/Modules/filesystemaccess/FileSystemFileHandle.cpp
r284424 r284814 59 59 60 60 auto resultValue = result.releaseReturnValue(); 61 if (resultValue.second == FileSystem::invalidPlatformFileHandle) 62 return promise.reject(Exception { UnknownError, "Invalid platform file handle"_s }); 63 61 64 promise.resolve(FileSystemSyncAccessHandle::create(protectedThis.get(), resultValue.first, resultValue.second)); 62 65 }); -
branches/safari-612-branch/Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp
r284424 r284814 28 28 29 29 #include "BufferSource.h" 30 #include "ExceptionOr.h"31 30 #include "FileSystemFileHandle.h" 32 31 #include "JSDOMPromiseDeferred.h" … … 45 44 , m_file(file) 46 45 { 46 ASSERT(m_file != FileSystem::invalidPlatformFileHandle); 47 47 } 48 48 49 49 FileSystemSyncAccessHandle::~FileSystemSyncAccessHandle() 50 50 { 51 if (!m_isClosed) 52 m_source->close(m_identifier, [](auto) { }); 51 if (m_closeResult) 52 return; 53 54 ASSERT(m_closePromises.isEmpty()); 55 m_source->close(m_identifier, [](auto) { }); 56 } 57 58 bool FileSystemSyncAccessHandle::isClosingOrClosed() const 59 { 60 return m_closeResult || !m_closePromises.isEmpty(); 53 61 } 54 62 55 63 void FileSystemSyncAccessHandle::truncate(unsigned long long size, DOMPromiseDeferred<void>&& promise) 56 64 { 65 if (isClosingOrClosed()) 66 return promise.reject(Exception { InvalidStateError, "AccessHandle is closing or closed"_s }); 67 57 68 m_pendingOperationCount++; 58 69 m_source->truncate(m_identifier, size, [weakThis = makeWeakPtr(*this), promise = WTFMove(promise)](auto result) mutable { … … 66 77 void FileSystemSyncAccessHandle::getSize(DOMPromiseDeferred<IDLUnsignedLongLong>&& promise) 67 78 { 79 if (isClosingOrClosed()) 80 return promise.reject(Exception { InvalidStateError, "AccessHandle is closing or closed"_s }); 81 68 82 m_pendingOperationCount++; 69 83 m_source->getSize(m_identifier, [weakThis = makeWeakPtr(*this), promise = WTFMove(promise)](auto result) mutable { … … 77 91 void FileSystemSyncAccessHandle::flush(DOMPromiseDeferred<void>&& promise) 78 92 { 93 if (isClosingOrClosed()) 94 return promise.reject(Exception { InvalidStateError, "AccessHandle is closing or closed"_s }); 95 79 96 m_pendingOperationCount++; 80 97 m_source->flush(m_identifier, [weakThis = makeWeakPtr(*this), promise = WTFMove(promise)](auto result) mutable { … … 88 105 void FileSystemSyncAccessHandle::close(DOMPromiseDeferred<void>&& promise) 89 106 { 90 if (m_isClosed) 91 return promise.reject(Exception { InvalidStateError }); 107 if (m_closeResult) 108 return promise.settle(ExceptionOr<void> { *m_closeResult }); 109 110 auto isClosing = !m_closePromises.isEmpty(); 111 m_closePromises.append(WTFMove(promise)); 112 if (isClosing) 113 return; 114 115 FileSystem::closeFile(m_file); 116 m_file = FileSystem::invalidPlatformFileHandle; 92 117 93 118 m_pendingOperationCount++; 94 m_source->close(m_identifier, [weakThis = makeWeakPtr(*this), promise = WTFMove(promise)](auto result) mutable { 95 if (weakThis) { 96 weakThis->m_pendingOperationCount--; 97 weakThis->didClose(); 98 } 99 100 promise.settle(WTFMove(result)); 119 m_source->close(m_identifier, [this, protectedThis = Ref { *this }](auto result) mutable { 120 m_pendingOperationCount--; 121 didClose(WTFMove(result)); 101 122 }); 102 123 } 103 124 104 void FileSystemSyncAccessHandle::didClose( )125 void FileSystemSyncAccessHandle::didClose(ExceptionOr<void>&& result) 105 126 { 106 m_isClosed = true; 127 m_closeResult = WTFMove(result); 128 129 auto promises = std::exchange(m_closePromises, { }); 130 for (auto promise : promises) 131 promise.settle(ExceptionOr<void> { *m_closeResult }); 107 132 } 108 133 … … 111 136 ASSERT(!isMainThread()); 112 137 113 if ( m_file == FileSystem::invalidPlatformFileHandle || m_isClosed)114 return Exception { InvalidStateError };138 if (isClosingOrClosed()) 139 return Exception { InvalidStateError, "AccessHandle is closing or closed"_s }; 115 140 116 141 if (m_pendingOperationCount) … … 132 157 ASSERT(!isMainThread()); 133 158 134 if ( m_file == FileSystem::invalidPlatformFileHandle || m_isClosed)135 return Exception { InvalidStateError };159 if (isClosingOrClosed()) 160 return Exception { InvalidStateError, "AccessHandle is closing or closed"_s }; 136 161 137 162 if (m_pendingOperationCount) -
branches/safari-612-branch/Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.h
r284424 r284814 27 27 28 28 #include "BufferSource.h" 29 #include "ExceptionOr.h" 29 30 #include "FileSystemSyncAccessHandleIdentifier.h" 30 31 #include "IDLTypes.h" … … 36 37 class FileSystemFileHandle; 37 38 template<typename> class DOMPromiseDeferred; 38 template<typename> class ExceptionOr;39 39 40 40 class FileSystemSyncAccessHandle : public RefCounted<FileSystemSyncAccessHandle>, public CanMakeWeakPtr<FileSystemSyncAccessHandle> { … … 51 51 void flush(DOMPromiseDeferred<void>&&); 52 52 void close(DOMPromiseDeferred<void>&&); 53 void didClose( );53 void didClose(ExceptionOr<void>&&); 54 54 ExceptionOr<unsigned long long> read(BufferSource&&, FilesystemReadWriteOptions); 55 55 ExceptionOr<unsigned long long> write(BufferSource&&, FilesystemReadWriteOptions); … … 57 57 private: 58 58 FileSystemSyncAccessHandle(FileSystemFileHandle&, FileSystemSyncAccessHandleIdentifier, FileSystem::PlatformFileHandle); 59 bool isClosingOrClosed() const; 59 60 60 61 Ref<FileSystemFileHandle> m_source; 61 62 FileSystemSyncAccessHandleIdentifier m_identifier; 62 bool m_isClosed { false };63 63 uint64_t m_pendingOperationCount { 0 }; 64 64 FileSystem::PlatformFileHandle m_file; 65 std::optional<ExceptionOr<void>> m_closeResult; 66 Vector<DOMPromiseDeferred<void>> m_closePromises; 65 67 }; 66 68
Note:
See TracChangeset
for help on using the changeset viewer.