Skip to content

Commit

Permalink
[FSA] Allow seeking past the end of a file
Browse files Browse the repository at this point in the history
Currently, we reject all attempts to write past the end of a file. This
change makes the API more consistent with the behavior of POSIX.

If writing at an offset past the end of a file, the null bytes between
the old end of the file and the offset will count towards the file's
quota.

Adds Quota tests to the SandboxFSW.

Bug: 1153385
Change-Id: Iec54acbccecb728f9375931825525ba2fbafd1ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593810
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Austin Sullivan <asully@chromium.org>
Cr-Commit-Position: refs/heads/master@{#850838}
  • Loading branch information
a-sully authored and chromium-wpt-export-bot committed Feb 4, 2021
1 parent 9378ceb commit 9376be0
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,12 @@ directory_test(async (t, root) => {
const handle = await createEmptyFile(t, 'bad_offset', root);
const stream = await handle.createWritable();

await promise_rejects_dom(
t, 'InvalidStateError', stream.write({type: 'write', position: 4, data: new Blob(['abc'])}));
await promise_rejects_js(
t, TypeError, stream.close(), 'stream is already closed');
await stream.write({type: 'write', position: 4, data: new Blob(['abc'])});
await stream.close();

assert_equals(await getFileContents(handle), '');
assert_equals(await getFileSize(handle), 0);
}, 'write() called with an invalid offset');
assert_equals(await getFileContents(handle), '\0\0\0\0abc');
assert_equals(await getFileSize(handle), 7);
}, 'write() called with an offset beyond the end of the file');

directory_test(async (t, root) => {
const handle = await createEmptyFile(t, 'empty_string', root);
Expand Down

0 comments on commit 9376be0

Please sign in to comment.