Bug 1779118 [wpt PR 34775] - Move File System Access-specific code out of framed_test WPT helper., a=testonly

Automatic update from web-platform-tests
Move File System Access-specific code out of framed_test WPT helper.

This makes using this helper for other APIs cleaner. Current tests
have been updated to perform this clearing before every test, so this
should be a no-op.

Bug: 1322897

Change-Id: I8209e3875473bdce449ad90db007bc095cce2d8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3755310
Auto-Submit: Nathan Eliason <eliason@chromium.org>
Commit-Queue: Andrew Williams <awillia@chromium.org>
Reviewed-by: Andrew Williams <awillia@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1022900}

--

wpt-commits: 65d9152ec1a6c96df05214c4768feff4b2867f9e
wpt-pr: 34775
This commit is contained in:
Nathan Eliason 2022-07-14 04:09:25 +00:00 committed by moz-wptsync-bot
parent 88c62b8e8e
commit bba465e451
3 changed files with 26 additions and 8 deletions

View File

@ -58,10 +58,21 @@ const assertNoAccess = (done) => `
}
`;
// To be resilient against tests not cleaning up properly, cleanup before
// every test.
function clearDirectories() {
const directory = await directory_promise;
for await (let entry of directory.values()) {
await directory.removeEntry(
entry.name, {recursive: entry.kind === 'directory'});
}
}
// The following tests make use of helper framed_test to define promise tests
// that send assertion scripts to multiple executor subframes.
framed_test(async (t, sendTo) => {
clearDirectories();
// Ensure we have directory picker access in all child contexts.
await sendTo(childContexts, setUpChildFrame);
await sendTo(sameSiteContexts, assertNumEntries(0));
@ -74,6 +85,7 @@ framed_test(async (t, sendTo) => {
}, 'getDirectoryHandle can access handles across same-site contexts.');
framed_test(async (t, sendTo) => {
clearDirectories();
// Ensure we have directory picker access in all child contexts.
await sendTo(childContexts, setUpChildFrame);
await sendTo(sameSiteContexts, assertNumEntries(0));
@ -89,6 +101,7 @@ framed_test(async (t, sendTo) => {
}, 'Directory handles can be removed from other same-site contexts.');
framed_test(async (t, sendTo) => {
clearDirectories();
// Ensure we have directory picker access in all child contexts.
await sendTo(childContexts, setUpChildFrame);
// Assert that an error is raised when attempting to access

View File

@ -68,10 +68,21 @@ const assertNoAccess = (done) => `
}
`;
// To be resilient against tests not cleaning up properly, cleanup before
// every test.
function clearDirectories() {
const directory = await directory_promise;
for await (let entry of directory.values()) {
await directory.removeEntry(
entry.name, {recursive: entry.kind === 'directory'});
}
}
// The following tests make use of helper framed_test to define promise tests
// that send assertion scripts to multiple executor subframes.
framed_test(async (t, sendTo) => {
clearDirectories();
// Ensure we have directory picker access in all child contexts.
await sendTo(childContexts, setUpChildFrame);
await sendTo(sameSiteContexts, assertNumEntries(0));
@ -84,6 +95,7 @@ framed_test(async (t, sendTo) => {
}, 'getFileHandle can access handles across same-site contexts.');
framed_test(async (t, sendTo) => {
clearDirectories();
// Ensure we have directory picker access in all child frames.
await sendTo(childContexts, setUpChildFrame);
await sendTo(sameSiteContexts, assertNumEntries(0));
@ -99,6 +111,7 @@ framed_test(async (t, sendTo) => {
}, 'File handles can be removed from other same-site contexts.');
framed_test(async (t, sendTo) => {
clearDirectories();
// Ensure we have directory picker access in all child contexts.
await sendTo(childContexts, setUpChildFrame);
// Assert that an error is raised when attempting to access getFileHandle.

View File

@ -123,14 +123,6 @@ function framed_test(func, description) {
promise_test(async (t) => {
return new Promise(async (resolve, reject) => {
try {
const directory = await directory_promise;
// To be resilient against tests not cleaning up properly, cleanup before
// every test.
for await (let entry of directory.values()) {
await directory.removeEntry(
entry.name, {recursive: entry.kind === 'directory'});
}
// Set up handles to all third party frames.
const handles = [
null, // firstParty