-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
Depends on D150663 Differential Revision: https://phabricator.services.mozilla.com/D157643 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1791384 gecko-commit: e0355ac9047673122eb9bc6876a06d4c5ddcd79d gecko-reviewers: dom-storage-reviewers, jari
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,10 +86,11 @@ directory_test(async (t, root) => { | |
await promise_rejects_dom( | ||
t, 'NoModificationAllowedError', handle.move('file-after')); | ||
|
||
// Can move handle once the writable is closed. | ||
// Can't move handle once the writable is closed. | ||
await stream.close(); | ||
await handle.move('file-after'); | ||
assert_array_equals(await getSortedDirectoryEntries(root), ['file-after']); | ||
await promise_rejects_dom( | ||
t, 'NoModificationAllowedError', handle.move('file-after')); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
a-sully
Contributor
|
||
assert_array_equals(await getSortedDirectoryEntries(root), ['file-before']); | ||
This comment has been minimized.
Sorry, something went wrong.
a-sully
Contributor
|
||
}, 'move(name) while the destination file has an open writable fails'); | ||
|
||
|
||
|
@@ -308,15 +309,11 @@ directory_test(async (t, root) => { | |
// Assert the file is still in the source directory. | ||
assert_array_equals(await getSortedDirectoryEntries(dir_src), ['file']); | ||
|
||
// Can move handle once the writable is closed. | ||
// Can't move handle once the writable is closed. | ||
await stream.close(); | ||
await file.move(dir_dest); | ||
assert_array_equals( | ||
await getSortedDirectoryEntries(root), ['dir-dest/', 'dir-src/']); | ||
assert_array_equals(await getSortedDirectoryEntries(dir_src), []); | ||
assert_array_equals(await getSortedDirectoryEntries(dir_dest), ['file']); | ||
This comment has been minimized.
Sorry, something went wrong.
a-sully
Contributor
|
||
assert_equals(await getFileContents(file), 'abc'); | ||
assert_equals(await getFileSize(file), 3); | ||
await promise_rejects_dom( | ||
t, 'NoModificationAllowedError', file.move(dir_dest)); | ||
assert_array_equals(await getSortedDirectoryEntries(dir_src), ['file']); | ||
}, 'move(dir) while the destination file has an open writable fails'); | ||
|
||
directory_test(async (t, root) => { | ||
|
@@ -336,13 +333,12 @@ directory_test(async (t, root) => { | |
// Assert the file is still in the source directory. | ||
assert_array_equals(await getSortedDirectoryEntries(dir_src), ['file-src']); | ||
|
||
// Can move handle once the writable is closed. | ||
// Can't move handle once the writable is closed. | ||
await stream.close(); | ||
await file.move(dir_dest, 'file-dest'); | ||
assert_array_equals( | ||
await getSortedDirectoryEntries(root), ['dir-dest/', 'dir-src/']); | ||
assert_array_equals(await getSortedDirectoryEntries(dir_src), []); | ||
assert_array_equals(await getSortedDirectoryEntries(dir_dest), ['file-dest']); | ||
await promise_rejects_dom( | ||
t, 'NoModificationAllowedError', file.move(dir_dest, 'file-dest')); | ||
// Assert the file is still in the source directory. | ||
assert_array_equals(await getSortedDirectoryEntries(dir_src), ['file-src']); | ||
assert_equals(await getFileContents(file), 'abc'); | ||
assert_equals(await getFileSize(file), 3); | ||
}, 'move(dir, name) while the destination file has an open writable fails'); |
3 comments
on commit b20e834
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jesup could you please test the "don't allow overwrite on move" behavior in separate tests? It's unclear from the test names (moving with an open writable) that the issue is not allowing overwrites
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My next update should handle that; and remove the destination-has-a-writable tests since they're irrelevant if you don't allow overwrites
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My next update should handle that; and remove the destination-has-a-writable tests since they're irrelevant if you don't allow overwrites
Any updates on this?
Can we make this
InvalidModifcationError
?NoModificationAllowedError
currently maps exclusively to file locking errors (at least within the OPFS) and it would be nice to provide that guarantee to developers.InvalidModifcationError
is more accurate anyways. According to the DOMException:NoModificationAllowedError
: The object cannot be modifiedInvalidModifcationError
: The object cannot be modified in this wayThe issue isn't that the file can't be moved, but that it can't be moved there