1
0
Fork 0
firefox/testing/web-platform/tests/fs/resources/sync-access-handle-test.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

17 lines
689 B
JavaScript

async function cleanupSandboxedFileSystem() {
const dir = await navigator.storage.getDirectory();
for await (let entry of dir.values())
await dir.removeEntry(entry.name, {recursive: entry.kind === 'directory'});
}
function sync_access_handle_test(test, description) {
promise_test(async t => {
// To be extra resilient against bad tests, cleanup before every test.
await cleanupSandboxedFileSystem();
const dir = await navigator.storage.getDirectory();
const fileHandle = await dir.getFileHandle('OPFS.test', {create: true});
const syncHandle = await fileHandle.createSyncAccessHandle();
test(t, syncHandle);
syncHandle.close();
}, description);
}