chore: make indexeddb opt-in

This commit is contained in:
Simon Knott 2025-02-27 09:01:17 +01:00
parent 58db3f7e3f
commit df89d71826
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
8 changed files with 16 additions and 13 deletions

View file

@ -914,4 +914,4 @@ Returns storage state for this request context, contains current cookies and loc
* since: v1.51
- `indexedDB` ?<boolean>
Defaults to `true`. Set to `false` to omit IndexedDB from snapshot.
Set to `true` to include IndexedDB in the storage state snapshot.

View file

@ -1549,7 +1549,8 @@ IndexedDBs with typed arrays are currently not supported.
* since: v1.51
- `indexedDB` ?<boolean>
Defaults to `true`. Set to `false` to omit IndexedDB from snapshot.
Set to `true` to include IndexedDB in the storage state snapshot.
If your application uses IndexedDB to store authentication tokens, like Firebase Authentication, enable this.
## property: BrowserContext.tracing
* since: v1.12

View file

@ -9274,7 +9274,8 @@ export interface BrowserContext {
*/
storageState(options?: {
/**
* Defaults to `true`. Set to `false` to omit IndexedDB from snapshot.
* Set to `true` to include IndexedDB in the storage state snapshot. If your application uses IndexedDB to store
* authentication tokens, like Firebase Authentication, enable this.
*/
indexedDB?: boolean;
@ -18558,7 +18559,7 @@ export interface APIRequestContext {
*/
storageState(options?: {
/**
* Defaults to `true`. Set to `false` to omit IndexedDB from snapshot.
* Set to `true` to include IndexedDB in the storage state snapshot.
*/
indexedDB?: boolean;

View file

@ -511,7 +511,7 @@ export abstract class BrowserContext extends SdkObject {
this._origins.add(origin);
}
async storageState(indexedDB = true): Promise<channels.BrowserContextStorageStateResult> {
async storageState(indexedDB = false): Promise<channels.BrowserContextStorageStateResult> {
const result: channels.BrowserContextStorageStateResult = {
cookies: await this.cookies(),
origins: []

View file

@ -693,7 +693,7 @@ export class GlobalAPIRequestContext extends APIRequestContext {
return this._cookieStore.cookies(url);
}
override async storageState(indexedDB = true): Promise<channels.APIRequestContextStorageStateResult> {
override async storageState(indexedDB = false): Promise<channels.APIRequestContextStorageStateResult> {
return {
cookies: this._cookieStore.allCookies(),
origins: (this._origins || []).map(origin => ({ ...origin, indexedDB: indexedDB ? origin.indexedDB : [] })),

View file

@ -9274,7 +9274,8 @@ export interface BrowserContext {
*/
storageState(options?: {
/**
* Defaults to `true`. Set to `false` to omit IndexedDB from snapshot.
* Set to `true` to include IndexedDB in the storage state snapshot. If your application uses IndexedDB to store
* authentication tokens, like Firebase Authentication, enable this.
*/
indexedDB?: boolean;
@ -18558,7 +18559,7 @@ export interface APIRequestContext {
*/
storageState(options?: {
/**
* Defaults to `true`. Set to `false` to omit IndexedDB from snapshot.
* Set to `true` to include IndexedDB in the storage state snapshot.
*/
indexedDB?: boolean;

View file

@ -110,7 +110,7 @@ it('should round-trip through the file', async ({ contextFactory }, testInfo) =>
});
const path = testInfo.outputPath('storage-state.json');
const state = await context.storageState({ path });
const state = await context.storageState({ path, indexedDB: true });
const written = await fs.promises.readFile(path, 'utf8');
expect(JSON.stringify(state, undefined, 2)).toBe(written);
@ -365,7 +365,7 @@ it('should support IndexedDB', async ({ page, server, contextFactory }) => {
await page.getByLabel('Mins').fill('1');
await page.getByText('Add Task').click();
const storageState = await page.context().storageState();
const storageState = await page.context().storageState({ indexedDB: true });
expect(storageState.origins).toEqual([
{
origin: server.PREFIX,
@ -438,7 +438,7 @@ it('should support IndexedDB', async ({ page, server, contextFactory }) => {
]);
const context = await contextFactory({ storageState });
expect(await context.storageState()).toEqual(storageState);
expect(await context.storageState({ indexedDB: true })).toEqual(storageState);
const recreatedPage = await context.newPage();
await recreatedPage.goto(server.PREFIX + '/to-do-notifications/index.html');
@ -448,5 +448,5 @@ it('should support IndexedDB', async ({ page, server, contextFactory }) => {
- text: /Pet the cat/
`);
expect(await context.storageState({ indexedDB: false })).toEqual({ cookies: [], origins: [] });
expect(await context.storageState()).toEqual({ cookies: [], origins: [] });
});

View file

@ -376,7 +376,7 @@ it('should preserve local storage on import/export of storage state', async ({ p
};
const request = await playwright.request.newContext({ storageState });
await request.get(server.EMPTY_PAGE);
const exportedState = await request.storageState();
const exportedState = await request.storageState({ indexedDB: true });
expect(exportedState).toEqual(storageState);
await request.dispose();
});