Skip to content

Commit

Permalink
Bug 1763185 [wpt PR 33516] - Revert "Add options parameter to createS…
Browse files Browse the repository at this point in the history
…yncAccessHandle()", a=testonly

Automatic update from web-platform-tests
Revert "Add options parameter to createSyncAccessHandle()"

This reverts commit ca2d8b837fca8a7bd3bd0ba1562c7cc090108374.

Reason for revert: To avoid compatibility issues with Safari (that has already shipped this API without the options param) and leave the design of the object fully open, we decided to remove the parameter. Further context in whatwg/fs#19.

Original change's description:
> Add options parameter to createSyncAccessHandle()
>
> For now the only accepted (and required) option is "mode: 'in-place'".
> Having this parameter allows us to later define a more appropriate
> default behavior for access handles than the one we currently implement.
> This is specially useful in the context of expanding access handle usage
> outside of OPFS.
>
> For more details check:
> https://github.com/WICG/file-system-access/blob/main/AccessHandle.md#exposing-accesshandles-on-all-filesystems
>
> Bug: 1218431
> Change-Id: I50d0a4acfd81874e17b6b28d1c2bf446b0397a4d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3110487
> Reviewed-by: Marijn Kruisselbrink <[email protected]>
> Commit-Queue: Emanuel Krivoy <[email protected]>
> Cr-Commit-Position: refs/heads/main@{#982209}

Bug: 1218431
Change-Id: I11dd5044b59e1fec8444242869628129efa5cf17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3572141
Reviewed-by: Austin Sullivan <[email protected]>
Commit-Queue: Emanuel Krivoy <[email protected]>
Cr-Commit-Position: refs/heads/main@{#989350}

--

wpt-commits: 9082234ee4b01d20a4e9eec0297155e2e5f6838f
wpt-pr: 33516
  • Loading branch information
fivedots authored and moz-wptsync-bot committed Apr 11, 2022
1 parent e8918c0 commit d75147b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ function add_message_event_handlers(receiver, target, target_origin) {
// success to the sender.
let success = true;
try {
const access_handle = await message_data.file_handle
.createSyncAccessHandle({mode: "in-place"});
const access_handle = await message_data.file_handle.createSyncAccessHandle();
await access_handle.close();
} catch (error) {
success = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ function sync_access_handle_test(test, description) {
await cleanupSandboxedFileSystem();
const dir = await navigator.storage.getDirectory();
const fileHandle = await dir.getFileHandle('OPFS.test', {create: true});
const syncHandle = await fileHandle
.createSyncAccessHandle({mode: "in-place"});
const syncHandle = await fileHandle.createSyncAccessHandle();
await test(t, syncHandle);
await syncHandle.close();
}, description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ importScripts('resources/sandboxed-fs-test-helpers.js');
directory_test(async (t, root_dir) => {
const fileHandle = await root_dir.getFileHandle('OPFS.test', {create: true});

const syncHandle1 = await fileHandle.createSyncAccessHandle({mode: "in-place"});
const syncHandle1 = await fileHandle.createSyncAccessHandle();
await promise_rejects_dom(
t, 'InvalidStateError', fileHandle.createSyncAccessHandle({mode: "in-place"}));
t, 'InvalidStateError', fileHandle.createSyncAccessHandle());

await syncHandle1.close();
const syncHandle2 = await fileHandle.createSyncAccessHandle({mode: "in-place"});
const syncHandle2 = await fileHandle.createSyncAccessHandle();
await syncHandle2.close();
}, 'There can only be one open access handle at any given time');

directory_test(async (t, root_dir) => {
const fooFileHandle = await root_dir.getFileHandle('foo.test', {create: true});
const barFileHandle = await root_dir.getFileHandle('bar.test', {create: true});

const fooSyncHandle = await fooFileHandle.createSyncAccessHandle({mode: "in-place"});
const fooSyncHandle = await fooFileHandle.createSyncAccessHandle();
t.add_cleanup(() => fooSyncHandle.close());

const barSyncHandle1 = await barFileHandle.createSyncAccessHandle({mode: "in-place"});
const barSyncHandle1 = await barFileHandle.createSyncAccessHandle();
await promise_rejects_dom(
t, 'InvalidStateError', barFileHandle.createSyncAccessHandle({mode: "in-place"}));
t, 'InvalidStateError', barFileHandle.createSyncAccessHandle());

await barSyncHandle1.close();
const barSyncHandle2 = await barFileHandle.createSyncAccessHandle({mode: "in-place"});
const barSyncHandle2 = await barFileHandle.createSyncAccessHandle();
await barSyncHandle2.close();
}, 'An access handle from one file does not interfere with the creation of an' +
' access handle on another file');
Expand All @@ -39,7 +39,7 @@ directory_test(async (t, root_dir) => {
const fooWritable = await fooFileHandle.createWritable();
t.add_cleanup(() => fooWritable.close());

const barSyncHandle = await barFileHandle.createSyncAccessHandle({mode: "in-place"});
const barSyncHandle = await barFileHandle.createSyncAccessHandle();
t.add_cleanup(() => barSyncHandle.close());
}, 'A writable stream from one file does not interfere with the creation of an' +
' access handle on another file');
Expand All @@ -48,7 +48,7 @@ directory_test(async (t, root_dir) => {
const fooFileHandle = await root_dir.getFileHandle('foo.test', {create: true});
const barFileHandle = await root_dir.getFileHandle('bar.test', {create: true});

const fooSyncHandle = await fooFileHandle.createSyncAccessHandle({mode: "in-place"});
const fooSyncHandle = await fooFileHandle.createSyncAccessHandle();
t.add_cleanup(() => fooSyncHandle.close());

const barWritable = await barFileHandle.createWritable();
Expand All @@ -59,7 +59,7 @@ directory_test(async (t, root_dir) => {
directory_test(async (t, root_dir) => {
const fileHandle = await root_dir.getFileHandle('OPFS.test', {create: true});

const syncHandle = await fileHandle.createSyncAccessHandle({mode: "in-place"});
const syncHandle = await fileHandle.createSyncAccessHandle();
await promise_rejects_dom(
t, 'InvalidStateError', fileHandle.createWritable());

Expand All @@ -74,14 +74,14 @@ directory_test(async (t, root_dir) => {
const writable1 = await fileHandle.createWritable();
const writable2 = await fileHandle.createWritable();
await promise_rejects_dom(
t, 'InvalidStateError', fileHandle.createSyncAccessHandle({mode: "in-place"}));
t, 'InvalidStateError', fileHandle.createSyncAccessHandle());

await writable1.close();
await promise_rejects_dom(
t, 'InvalidStateError', fileHandle.createSyncAccessHandle({mode: "in-place"}));
t, 'InvalidStateError', fileHandle.createSyncAccessHandle());

await writable2.close();
const syncHandle = await fileHandle.createSyncAccessHandle({mode: "in-place"});
const syncHandle = await fileHandle.createSyncAccessHandle();
await syncHandle.close();
}, 'Access handles cannot be created if there are open Writable streams');

Expand Down

0 comments on commit d75147b

Please sign in to comment.