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
  • Loading branch information
a-sully authored and chromium-wpt-export-bot committed Jan 26, 2021
1 parent 97e2f32 commit c3e5db3
Showing 1 changed file with 5 additions and 7 deletions.
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 c3e5db3

Please sign in to comment.