Skip to content

Commit

Permalink
cherry-pick(#30342): Revert "fix(reuse): reset Origin Private File Sy…
Browse files Browse the repository at this point in the history
…stem API (#29921)" (#30344)

This PR cherry-picks the following commits:

- 96053ed

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
playwrightmachine and github-actions[bot] authored Apr 11, 2024
1 parent 5332639 commit 35468cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 45 deletions.
11 changes: 0 additions & 11 deletions packages/playwright-core/src/server/frames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1692,17 +1692,6 @@ export class Frame extends SdkObject {
if (db.name)
indexedDB.deleteDatabase(db.name!);
}

// Clean StorageManager
const root = await navigator.storage.getDirectory();
const entries = await (root as any).entries();
// Manual loop instead of for await because in Firefox's utility context instanceof AsyncIterable is not working.
let entry = await entries.next();
while (!entry.done) {
const [name] = entry.value;
await root.removeEntry(name, { recursive: true });
entry = await entries.next();
}
}, { ls: newStorage?.localStorage }).catch(() => {});
}

Expand Down
38 changes: 4 additions & 34 deletions tests/library/browsercontext-reuse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@
*/

import { browserTest, expect } from '../config/browserTest';
import type { BrowserContext, BrowserContextOptions } from '@playwright/test';
import type { BrowserContext } from '@playwright/test';

const test = browserTest.extend<{ reusedContext: (options?: BrowserContextOptions) => Promise<BrowserContext> }>({
const test = browserTest.extend<{ reusedContext: () => Promise<BrowserContext> }>({
reusedContext: async ({ browserType, browser }, use) => {
await use(async (options: BrowserContextOptions = {}) => {
await use(async () => {
const defaultContextOptions = (browserType as any)._defaultContextOptions;
const context = await (browser as any)._newContextForReuse({
...defaultContextOptions,
...options,
});
const context = await (browser as any)._newContextForReuse(defaultContextOptions);
return context;
});
},
Expand Down Expand Up @@ -238,33 +235,6 @@ test('should reset mouse position', async ({ reusedContext, browserName, platfor
await expect(page.locator('#two')).toHaveCSS('background-color', 'rgb(0, 0, 255)');
});

test('should reset Origin Private File System', async ({ reusedContext, httpsServer, browserName }) => {
test.skip(browserName === 'webkit', 'getDirectory is not supported in ephemeral context in WebKit https://github.com/microsoft/playwright/issues/18235#issuecomment-1289792576');
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/29901' });

let context = await reusedContext({ ignoreHTTPSErrors: true });
let page = await context.newPage();
await page.goto(httpsServer.EMPTY_PAGE);
await page.evaluate(async () => {
const root = await navigator.storage.getDirectory();
await root.getDirectoryHandle('someDirectoryName', { create: true });
await root.getFileHandle('foo.txt', { create: true });
});

context = await reusedContext({ ignoreHTTPSErrors: true });
page = await context.newPage();
await page.goto(httpsServer.EMPTY_PAGE);
const { directoryExits, fileExits } = await page.evaluate(async () => {
const root = await navigator.storage.getDirectory();
let directoryExits = true, fileExits = true;
await root.getDirectoryHandle('someDirectoryName').catch(() => { directoryExits = false; });
await root.getFileHandle('foo.txt').catch(() => { fileExits = false; });
return { directoryExits, fileExits };
});
expect(directoryExits).toBe(false);
expect(fileExits).toBe(false);
});

test('should reset tracing', async ({ reusedContext, trace }, testInfo) => {
test.skip(trace === 'on');

Expand Down

0 comments on commit 35468cf

Please sign in to comment.