Skip to content

Commit

Permalink
Bug 1686537 [wpt PR 27146] - [FSA] Allow seeking past the end of a fi…
Browse files Browse the repository at this point in the history
…le, a=testonly

Automatic update from web-platform-tests
[FSA] Allow seeking past the end of a file

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 <[email protected]>
Commit-Queue: Austin Sullivan <[email protected]>
Cr-Commit-Position: refs/heads/master@{#850838}

--

wpt-commits: 9376be061ac2dabc2f60d54a525d2ca81a60589a
wpt-pr: 27146
  • Loading branch information
a-sully authored and moz-wptsync-bot committed Feb 9, 2021
1 parent f9d8af7 commit 5dfb3e9
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 5dfb3e9

Please sign in to comment.