add to apirequestcontext
This commit is contained in:
parent
feab17ed03
commit
b248cb7265
|
|
@ -909,3 +909,9 @@ Returns storage state for this request context, contains current cookies and loc
|
||||||
|
|
||||||
### option: APIRequestContext.storageState.path = %%-storagestate-option-path-%%
|
### option: APIRequestContext.storageState.path = %%-storagestate-option-path-%%
|
||||||
* since: v1.16
|
* since: v1.16
|
||||||
|
|
||||||
|
### option: APIRequestContext.storageState.indexedDB
|
||||||
|
* since: v1.51
|
||||||
|
- `indexedDB` ?<boolean>
|
||||||
|
|
||||||
|
Set to `false` to omit IndexedDB from snapshot.
|
||||||
|
|
|
||||||
|
|
@ -1545,7 +1545,7 @@ Returns storage state for this browser context, contains current cookies, local
|
||||||
* since: v1.51
|
* since: v1.51
|
||||||
- `indexedDB` ?<boolean>
|
- `indexedDB` ?<boolean>
|
||||||
|
|
||||||
Set to `false` to disable IndexedDB snapshot.
|
Set to `false` to omit IndexedDB from snapshot.
|
||||||
|
|
||||||
## property: BrowserContext.tracing
|
## property: BrowserContext.tracing
|
||||||
* since: v1.12
|
* since: v1.12
|
||||||
|
|
|
||||||
|
|
@ -260,8 +260,8 @@ export class APIRequestContext extends ChannelOwner<channels.APIRequestContextCh
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async storageState(options: { path?: string } = {}): Promise<StorageState> {
|
async storageState(options: { path?: string, indexedDB?: boolean } = {}): Promise<StorageState> {
|
||||||
const state = await this._channel.storageState();
|
const state = await this._channel.storageState({ indexedDB: options.indexedDB ?? true });
|
||||||
if (options.path) {
|
if (options.path) {
|
||||||
await mkdirIfNeeded(options.path);
|
await mkdirIfNeeded(options.path);
|
||||||
await fs.promises.writeFile(options.path, JSON.stringify(state, undefined, 2), 'utf8');
|
await fs.promises.writeFile(options.path, JSON.stringify(state, undefined, 2), 'utf8');
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,9 @@ scheme.APIRequestContextFetchLogParams = tObject({
|
||||||
scheme.APIRequestContextFetchLogResult = tObject({
|
scheme.APIRequestContextFetchLogResult = tObject({
|
||||||
log: tArray(tString),
|
log: tArray(tString),
|
||||||
});
|
});
|
||||||
scheme.APIRequestContextStorageStateParams = tOptional(tObject({}));
|
scheme.APIRequestContextStorageStateParams = tObject({
|
||||||
|
indexedDB: tBoolean,
|
||||||
|
});
|
||||||
scheme.APIRequestContextStorageStateResult = tObject({
|
scheme.APIRequestContextStorageStateResult = tObject({
|
||||||
cookies: tArray(tType('NetworkCookie')),
|
cookies: tArray(tType('NetworkCookie')),
|
||||||
origins: tArray(tType('OriginStorage')),
|
origins: tArray(tType('OriginStorage')),
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ export abstract class APIRequestContext extends SdkObject {
|
||||||
abstract _defaultOptions(): FetchRequestOptions;
|
abstract _defaultOptions(): FetchRequestOptions;
|
||||||
abstract _addCookies(cookies: channels.NetworkCookie[]): Promise<void>;
|
abstract _addCookies(cookies: channels.NetworkCookie[]): Promise<void>;
|
||||||
abstract _cookies(url: URL): Promise<channels.NetworkCookie[]>;
|
abstract _cookies(url: URL): Promise<channels.NetworkCookie[]>;
|
||||||
abstract storageState(): Promise<channels.APIRequestContextStorageStateResult>;
|
abstract storageState(indexedDB: boolean): Promise<channels.APIRequestContextStorageStateResult>;
|
||||||
|
|
||||||
private _storeResponseBody(body: Buffer): string {
|
private _storeResponseBody(body: Buffer): string {
|
||||||
const uid = createGuid();
|
const uid = createGuid();
|
||||||
|
|
@ -618,8 +618,8 @@ export class BrowserContextAPIRequestContext extends APIRequestContext {
|
||||||
return await this._context.cookies(url.toString());
|
return await this._context.cookies(url.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
override async storageState(): Promise<channels.APIRequestContextStorageStateResult> {
|
override async storageState(indexedDB: boolean): Promise<channels.APIRequestContextStorageStateResult> {
|
||||||
return this._context.storageState();
|
return this._context.storageState(indexedDB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -684,10 +684,10 @@ export class GlobalAPIRequestContext extends APIRequestContext {
|
||||||
return this._cookieStore.cookies(url);
|
return this._cookieStore.cookies(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async storageState(): Promise<channels.APIRequestContextStorageStateResult> {
|
override async storageState(indexedDB: boolean): Promise<channels.APIRequestContextStorageStateResult> {
|
||||||
return {
|
return {
|
||||||
cookies: this._cookieStore.allCookies(),
|
cookies: this._cookieStore.allCookies(),
|
||||||
origins: this._origins || []
|
origins: (this._origins || []).map(origin => ({ ...origin, indexedDB: indexedDB ? origin.indexedDB : [] })),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
7
packages/playwright-core/types/types.d.ts
vendored
7
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -9272,7 +9272,7 @@ export interface BrowserContext {
|
||||||
*/
|
*/
|
||||||
storageState(options?: {
|
storageState(options?: {
|
||||||
/**
|
/**
|
||||||
* Set to `false` to disable IndexedDB snapshot.
|
* Set to `false` to omit IndexedDB from snapshot.
|
||||||
*/
|
*/
|
||||||
indexedDB?: boolean;
|
indexedDB?: boolean;
|
||||||
|
|
||||||
|
|
@ -18536,6 +18536,11 @@ export interface APIRequestContext {
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
storageState(options?: {
|
storageState(options?: {
|
||||||
|
/**
|
||||||
|
* Set to `false` to omit IndexedDB from snapshot.
|
||||||
|
*/
|
||||||
|
indexedDB?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The file path to save the storage state to. If
|
* The file path to save the storage state to. If
|
||||||
* [`path`](https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-storage-state-option-path) is
|
* [`path`](https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-storage-state-option-path) is
|
||||||
|
|
|
||||||
10
packages/protocol/src/channels.d.ts
vendored
10
packages/protocol/src/channels.d.ts
vendored
|
|
@ -346,7 +346,7 @@ export interface APIRequestContextChannel extends APIRequestContextEventTarget,
|
||||||
fetch(params: APIRequestContextFetchParams, metadata?: CallMetadata): Promise<APIRequestContextFetchResult>;
|
fetch(params: APIRequestContextFetchParams, metadata?: CallMetadata): Promise<APIRequestContextFetchResult>;
|
||||||
fetchResponseBody(params: APIRequestContextFetchResponseBodyParams, metadata?: CallMetadata): Promise<APIRequestContextFetchResponseBodyResult>;
|
fetchResponseBody(params: APIRequestContextFetchResponseBodyParams, metadata?: CallMetadata): Promise<APIRequestContextFetchResponseBodyResult>;
|
||||||
fetchLog(params: APIRequestContextFetchLogParams, metadata?: CallMetadata): Promise<APIRequestContextFetchLogResult>;
|
fetchLog(params: APIRequestContextFetchLogParams, metadata?: CallMetadata): Promise<APIRequestContextFetchLogResult>;
|
||||||
storageState(params?: APIRequestContextStorageStateParams, metadata?: CallMetadata): Promise<APIRequestContextStorageStateResult>;
|
storageState(params: APIRequestContextStorageStateParams, metadata?: CallMetadata): Promise<APIRequestContextStorageStateResult>;
|
||||||
disposeAPIResponse(params: APIRequestContextDisposeAPIResponseParams, metadata?: CallMetadata): Promise<APIRequestContextDisposeAPIResponseResult>;
|
disposeAPIResponse(params: APIRequestContextDisposeAPIResponseParams, metadata?: CallMetadata): Promise<APIRequestContextDisposeAPIResponseResult>;
|
||||||
dispose(params: APIRequestContextDisposeParams, metadata?: CallMetadata): Promise<APIRequestContextDisposeResult>;
|
dispose(params: APIRequestContextDisposeParams, metadata?: CallMetadata): Promise<APIRequestContextDisposeResult>;
|
||||||
}
|
}
|
||||||
|
|
@ -402,8 +402,12 @@ export type APIRequestContextFetchLogOptions = {
|
||||||
export type APIRequestContextFetchLogResult = {
|
export type APIRequestContextFetchLogResult = {
|
||||||
log: string[],
|
log: string[],
|
||||||
};
|
};
|
||||||
export type APIRequestContextStorageStateParams = {};
|
export type APIRequestContextStorageStateParams = {
|
||||||
export type APIRequestContextStorageStateOptions = {};
|
indexedDB: boolean,
|
||||||
|
};
|
||||||
|
export type APIRequestContextStorageStateOptions = {
|
||||||
|
|
||||||
|
};
|
||||||
export type APIRequestContextStorageStateResult = {
|
export type APIRequestContextStorageStateResult = {
|
||||||
cookies: NetworkCookie[],
|
cookies: NetworkCookie[],
|
||||||
origins: OriginStorage[],
|
origins: OriginStorage[],
|
||||||
|
|
|
||||||
|
|
@ -376,6 +376,8 @@ APIRequestContext:
|
||||||
items: string
|
items: string
|
||||||
|
|
||||||
storageState:
|
storageState:
|
||||||
|
parameters:
|
||||||
|
indexedDB: boolean
|
||||||
returns:
|
returns:
|
||||||
cookies:
|
cookies:
|
||||||
type: array
|
type: array
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue