gecko-dev/testing/web-platform/tests/native-file-system/resources/sandboxed-fs-test-helpers.js
Marijn Kruisselbrink e7bdfd124a Bug 1579258 [wpt PR 18883] - [NativeFS] Refactor WPT tests to support native FS as well., a=testonly
Automatic update from web-platform-tests
[NativeFS] Refactor WPT tests to support native FS as well.

Also changes the sandboxed file system version of these tests to run in
both windows and workers.

The native file system version of these tests are currently manual tests.
In the future we can automate them. Also currently some of the writer
tests don't pass in the native file system version, because of things like
bug 998913.

Bug: 998917
Change-Id: I4aefee6e35008afd73c2cf316d16ea189717bd4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787869
Reviewed-by: Olivier Yiptong <oyiptong@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699539}

--

wpt-commits: e7b232f535cf1ebd0026bd66d1ff3bf096744862
wpt-pr: 18883
2019-09-26 20:26:24 +00:00

25 lines
970 B
JavaScript

// This file defines a directory_test() function that can be used to define
// tests that require a FileSystemDirectoryHandle. The implementation of that
// function in this file will return an empty directory in the sandboxed file
// system.
//
// Another implementation of this function exists in native-fs-test-helpers.js,
// where that version uses the native file system instead.
async function cleanupSandboxedFileSystem() {
const dir =
await FileSystemDirectoryHandle.getSystemDirectory({type: 'sandbox'});
for await (let entry of dir.getEntries())
await dir.removeEntry(entry.name, {recursive: entry.isDirectory});
}
function directory_test(func, description) {
promise_test(async t => {
// To be extra resilient against bad tests, cleanup before every test.
await cleanupSandboxedFileSystem();
const dir =
await FileSystemDirectoryHandle.getSystemDirectory({type: 'sandbox'});
await func(t, dir);
}, description);
}