Title: [290765] trunk
Revision
290765
Author
[email protected]
Date
2022-03-02 21:05:11 -0800 (Wed, 02 Mar 2022)

Log Message

Throw proper exception on failed removeEntry() calls
https://bugs.webkit.org/show_bug.cgi?id=237382
<rdar://89232969>

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getDirectoryHandle.https.any-expected.txt:
* web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getDirectoryHandle.https.any.worker-expected.txt:
* web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getFileHandle.https.any-expected.txt:
* web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getFileHandle.https.any.worker-expected.txt:
* web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-removeEntry.https.any-expected.txt:
* web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-removeEntry.https.any.worker-expected.txt:

Source/WebKit:

Updated existing tests.

* NetworkProcess/storage/FileSystemStorageError.h:
(WebKit::convertToException):
* NetworkProcess/storage/FileSystemStorageHandle.cpp:
(WebKit::FileSystemStorageHandle::removeEntry):

LayoutTests:

* storage/filesystemaccess/handle-move-expected.txt:
* storage/filesystemaccess/handle-move-worker-expected.txt:
* storage/filesystemaccess/resources/handle-move.js:
(async test):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (290764 => 290765)


--- trunk/LayoutTests/ChangeLog	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/LayoutTests/ChangeLog	2022-03-03 05:05:11 UTC (rev 290765)
@@ -1,3 +1,16 @@
+2022-03-02  Sihui Liu  <[email protected]>
+
+        Throw proper exception on failed removeEntry() calls
+        https://bugs.webkit.org/show_bug.cgi?id=237382
+        <rdar://89232969>
+
+        Reviewed by Chris Dumez.
+
+        * storage/filesystemaccess/handle-move-expected.txt:
+        * storage/filesystemaccess/handle-move-worker-expected.txt:
+        * storage/filesystemaccess/resources/handle-move.js:
+        (async test):
+
 2022-03-02  Robert Jenner  <[email protected]>
 
         WindowServer returned not alive with context:,unresponsive work processor(s)

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (290764 => 290765)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-03 05:05:11 UTC (rev 290765)
@@ -1,3 +1,18 @@
+2022-03-02  Sihui Liu  <[email protected]>
+
+        Throw proper exception on failed removeEntry() calls
+        https://bugs.webkit.org/show_bug.cgi?id=237382
+        <rdar://89232969>
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getDirectoryHandle.https.any-expected.txt:
+        * web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getDirectoryHandle.https.any.worker-expected.txt:
+        * web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getFileHandle.https.any-expected.txt:
+        * web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getFileHandle.https.any.worker-expected.txt:
+        * web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-removeEntry.https.any-expected.txt:
+        * web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-removeEntry.https.any.worker-expected.txt:
+
 2022-03-02  Oriol Brufau  <[email protected]>
 
         [css] Implement 'text-decoration' as a shorthand.

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getDirectoryHandle.https.any-expected.txt (290764 => 290765)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getDirectoryHandle.https.any-expected.txt	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getDirectoryHandle.https.any-expected.txt	2022-03-03 05:05:11 UTC (rev 290765)
@@ -5,16 +5,8 @@
 PASS getDirectoryHandle(create=true) returns existing directories without erasing
 FAIL getDirectoryHandle() when a file already exists with the same name promise_rejects_dom: function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException TypeMismatchError: property "code" is equal to undefined, expected 17
 FAIL getDirectoryHandle() with empty name assert_unreached: Should have rejected: undefined Reached unreachable code
-FAIL getDirectoryHandle() with "." name promise_rejects_js: function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL getDirectoryHandle() with ".." name promise_rejects_js: function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL getDirectoryHandle(create=false) with a path separator when the directory exists promise_rejects_js: getDirectoryHandle() must reject names containing "/" function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL getDirectoryHandle(create=true) with a path separator promise_rejects_js: getDirectoryHandle(true) must reject names containing "/" function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
+PASS getDirectoryHandle() with "." name
+PASS getDirectoryHandle() with ".." name
+PASS getDirectoryHandle(create=false) with a path separator when the directory exists
+PASS getDirectoryHandle(create=true) with a path separator
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getDirectoryHandle.https.any.worker-expected.txt (290764 => 290765)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getDirectoryHandle.https.any.worker-expected.txt	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getDirectoryHandle.https.any.worker-expected.txt	2022-03-03 05:05:11 UTC (rev 290765)
@@ -5,16 +5,8 @@
 PASS getDirectoryHandle(create=true) returns existing directories without erasing
 FAIL getDirectoryHandle() when a file already exists with the same name promise_rejects_dom: function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException TypeMismatchError: property "code" is equal to undefined, expected 17
 FAIL getDirectoryHandle() with empty name assert_unreached: Should have rejected: undefined Reached unreachable code
-FAIL getDirectoryHandle() with "." name promise_rejects_js: function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL getDirectoryHandle() with ".." name promise_rejects_js: function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL getDirectoryHandle(create=false) with a path separator when the directory exists promise_rejects_js: getDirectoryHandle() must reject names containing "/" function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL getDirectoryHandle(create=true) with a path separator promise_rejects_js: getDirectoryHandle(true) must reject names containing "/" function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
+PASS getDirectoryHandle() with "." name
+PASS getDirectoryHandle() with ".." name
+PASS getDirectoryHandle(create=false) with a path separator when the directory exists
+PASS getDirectoryHandle(create=true) with a path separator
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getFileHandle.https.any-expected.txt (290764 => 290765)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getFileHandle.https.any-expected.txt	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getFileHandle.https.any-expected.txt	2022-03-03 05:05:11 UTC (rev 290765)
@@ -6,16 +6,8 @@
 FAIL getFileHandle(create=false) when a directory already exists with the same name promise_rejects_dom: function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException TypeMismatchError: property "code" is equal to undefined, expected 17
 FAIL getFileHandle(create=true) when a directory already exists with the same name promise_rejects_dom: function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException TypeMismatchError: property "code" is equal to undefined, expected 17
 PASS getFileHandle() with empty name
-FAIL getFileHandle() with "." name promise_rejects_js: function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL getFileHandle() with ".." name promise_rejects_js: function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL getFileHandle(create=false) with a path separator when the file exists. promise_rejects_js: getFileHandle() must reject names containing "/" function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL getFileHandle(create=true) with a path separator promise_rejects_js: getFileHandle(create=true) must reject names containing "/" function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
+PASS getFileHandle() with "." name
+PASS getFileHandle() with ".." name
+PASS getFileHandle(create=false) with a path separator when the file exists.
+PASS getFileHandle(create=true) with a path separator
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getFileHandle.https.any.worker-expected.txt (290764 => 290765)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getFileHandle.https.any.worker-expected.txt	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-getFileHandle.https.any.worker-expected.txt	2022-03-03 05:05:11 UTC (rev 290765)
@@ -6,16 +6,8 @@
 FAIL getFileHandle(create=false) when a directory already exists with the same name promise_rejects_dom: function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException TypeMismatchError: property "code" is equal to undefined, expected 17
 FAIL getFileHandle(create=true) when a directory already exists with the same name promise_rejects_dom: function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException TypeMismatchError: property "code" is equal to undefined, expected 17
 PASS getFileHandle() with empty name
-FAIL getFileHandle() with "." name promise_rejects_js: function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL getFileHandle() with ".." name promise_rejects_js: function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL getFileHandle(create=false) with a path separator when the file exists. promise_rejects_js: getFileHandle() must reject names containing "/" function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL getFileHandle(create=true) with a path separator promise_rejects_js: getFileHandle(create=true) must reject names containing "/" function "function () { throw e }" threw object "UnknownError: Name is invalid" ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
+PASS getFileHandle() with "." name
+PASS getFileHandle() with ".." name
+PASS getFileHandle(create=false) with a path separator when the file exists.
+PASS getFileHandle(create=true) with a path separator
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-removeEntry.https.any-expected.txt (290764 => 290765)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-removeEntry.https.any-expected.txt	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-removeEntry.https.any-expected.txt	2022-03-03 05:05:11 UTC (rev 290765)
@@ -5,11 +5,7 @@
 FAIL removeEntry() on a non-empty directory should fail 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 InvalidModificationError: property "code" is equal to 0, expected 13
 FAIL removeEntry() on a directory recursively should delete all sub-items promise_test: Unhandled rejection with value: object "TypeError: handle.createWritable is not a function. (In 'handle.createWritable()', 'handle.createWritable' is undefined)"
 FAIL removeEntry() with empty name should fail assert_unreached: Should have rejected: undefined Reached unreachable code
-FAIL removeEntry() with "." name should fail promise_rejects_js: function "function () { throw e }" threw object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL removeEntry() with ".." name should fail promise_rejects_js: function "function () { throw e }" threw object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL removeEntry() with a path separator should fail. assert_unreached: Should have rejected: removeEntry() must reject names containing "/" Reached unreachable code
+PASS removeEntry() with "." name should fail
+PASS removeEntry() with ".." name should fail
+PASS removeEntry() with a path separator should fail.
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-removeEntry.https.any.worker-expected.txt (290764 => 290765)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-removeEntry.https.any.worker-expected.txt	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemDirectoryHandle-removeEntry.https.any.worker-expected.txt	2022-03-03 05:05:11 UTC (rev 290765)
@@ -5,11 +5,7 @@
 FAIL removeEntry() on a non-empty directory should fail 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 InvalidModificationError: property "code" is equal to 0, expected 13
 FAIL removeEntry() on a directory recursively should delete all sub-items promise_test: Unhandled rejection with value: object "TypeError: handle.createWritable is not a function. (In 'handle.createWritable()', 'handle.createWritable' is undefined)"
 FAIL removeEntry() with empty name should fail assert_unreached: Should have rejected: undefined Reached unreachable code
-FAIL removeEntry() with "." name should fail promise_rejects_js: function "function () { throw e }" threw object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL removeEntry() with ".." name should fail promise_rejects_js: function "function () { throw e }" threw object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." ("UnknownError") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL removeEntry() with a path separator should fail. assert_unreached: Should have rejected: removeEntry() must reject names containing "/" Reached unreachable code
+PASS removeEntry() with "." name should fail
+PASS removeEntry() with ".." name should fail
+PASS removeEntry() with a path separator should fail.
 

Modified: trunk/LayoutTests/storage/filesystemaccess/handle-move-expected.txt (290764 => 290765)


--- trunk/LayoutTests/storage/filesystemaccess/handle-move-expected.txt	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/LayoutTests/storage/filesystemaccess/handle-move-expected.txt	2022-03-03 05:05:11 UTC (rev 290765)
@@ -14,8 +14,8 @@
 Test move to a destination with existing file:
 PASS moveFileError.toString() is "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)."
 Test move with an invalid name:
-PASS moveFileError.toString() is "UnknownError: Name is invalid"
-PASS moveFileError.toString() is "UnknownError: Name is invalid"
+PASS moveFileError.toString() is "TypeError: Name is invalid"
+PASS moveFileError.toString() is "TypeError: Name is invalid"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/storage/filesystemaccess/handle-move-worker-expected.txt (290764 => 290765)


--- trunk/LayoutTests/storage/filesystemaccess/handle-move-worker-expected.txt	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/LayoutTests/storage/filesystemaccess/handle-move-worker-expected.txt	2022-03-03 05:05:11 UTC (rev 290765)
@@ -15,8 +15,8 @@
 [Worker] Test move to a destination with existing file:
 PASS [Worker] moveFileError.toString() is "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)."
 [Worker] Test move with an invalid name:
-PASS [Worker] moveFileError.toString() is "UnknownError: Name is invalid"
-PASS [Worker] moveFileError.toString() is "UnknownError: Name is invalid"
+PASS [Worker] moveFileError.toString() is "TypeError: Name is invalid"
+PASS [Worker] moveFileError.toString() is "TypeError: Name is invalid"
 [Worker] Test move with open access handle:
 PASS [Worker] moveFileError.toString() is "InvalidStateError: Some AccessHandle is active"
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/storage/filesystemaccess/resources/handle-move.js (290764 => 290765)


--- trunk/LayoutTests/storage/filesystemaccess/resources/handle-move.js	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/LayoutTests/storage/filesystemaccess/resources/handle-move.js	2022-03-03 05:05:11 UTC (rev 290765)
@@ -72,7 +72,7 @@
             testError =  "Moved file to dirHandle1 with invalid name unexpectedly";
         }, (error) => {
             moveFileError = error;
-            shouldBeEqualToString("moveFileError.toString()", "UnknownError: Name is invalid");
+            shouldBeEqualToString("moveFileError.toString()", "TypeError: Name is invalid");
         });
 
         if (testError) {
@@ -83,7 +83,7 @@
             testError =  "Moved file to dirHandle1 with invalid name unexpectedly";
         }, (error) => {
             moveFileError = error;
-            shouldBeEqualToString("moveFileError.toString()", "UnknownError: Name is invalid");
+            shouldBeEqualToString("moveFileError.toString()", "TypeError: Name is invalid");
         });
 
         if (testError) {

Modified: trunk/Source/WebKit/ChangeLog (290764 => 290765)


--- trunk/Source/WebKit/ChangeLog	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/Source/WebKit/ChangeLog	2022-03-03 05:05:11 UTC (rev 290765)
@@ -1,3 +1,18 @@
+2022-03-02  Sihui Liu  <[email protected]>
+
+        Throw proper exception on failed removeEntry() calls
+        https://bugs.webkit.org/show_bug.cgi?id=237382
+        <rdar://89232969>
+
+        Reviewed by Chris Dumez.
+
+        Updated existing tests.
+
+        * NetworkProcess/storage/FileSystemStorageError.h:
+        (WebKit::convertToException):
+        * NetworkProcess/storage/FileSystemStorageHandle.cpp:
+        (WebKit::FileSystemStorageHandle::removeEntry):
+
 2022-03-02  Dan Glastonbury  <[email protected]>
 
         [WebGPU] Implement GPUDeviceDescriptor.requiredLimits

Modified: trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageError.h (290764 => 290765)


--- trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageError.h	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageError.h	2022-03-03 05:05:11 UTC (rev 290765)
@@ -53,7 +53,7 @@
     case FileSystemStorageError::InvalidModification:
         return WebCore::Exception { WebCore::InvalidModificationError };
     case FileSystemStorageError::InvalidName:
-        return WebCore::Exception { WebCore::UnknownError, "Name is invalid"_s };
+        return WebCore::Exception { WebCore::TypeError, "Name is invalid"_s };
     case FileSystemStorageError::InvalidState:
         return WebCore::Exception { WebCore::InvalidStateError };
     case FileSystemStorageError::TypeMismatch:

Modified: trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp (290764 => 290765)


--- trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp	2022-03-03 02:56:14 UTC (rev 290764)
+++ trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp	2022-03-03 05:05:11 UTC (rev 290765)
@@ -118,7 +118,13 @@
     if (m_type != Type::Directory)
         return FileSystemStorageError::TypeMismatch;
 
+    if (!isValidFileName(name))
+        return FileSystemStorageError::InvalidName;
+
     auto path = FileSystem::pathByAppendingComponent(m_path, name);
+    if (!FileSystem::fileExists(path))
+        return FileSystemStorageError::FileNotFound;
+
     auto type = FileSystem::fileType(path);
     if (!type)
         return FileSystemStorageError::TypeMismatch;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to