move default to server
This commit is contained in:
parent
39bfa40983
commit
c33f548e49
|
|
@ -426,7 +426,7 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>
|
||||||
}
|
}
|
||||||
|
|
||||||
async storageState(options: { path?: string, indexedDB?: boolean } = {}): Promise<StorageState> {
|
async storageState(options: { path?: string, indexedDB?: boolean } = {}): Promise<StorageState> {
|
||||||
const state = await this._channel.storageState({ indexedDB: options.indexedDB ?? true });
|
const state = await this._channel.storageState({ indexedDB: options.indexedDB });
|
||||||
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');
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ export class APIRequestContext extends ChannelOwner<channels.APIRequestContextCh
|
||||||
}
|
}
|
||||||
|
|
||||||
async storageState(options: { path?: string, indexedDB?: boolean } = {}): Promise<StorageState> {
|
async storageState(options: { path?: string, indexedDB?: boolean } = {}): Promise<StorageState> {
|
||||||
const state = await this._channel.storageState({ indexedDB: options.indexedDB ?? true });
|
const state = await this._channel.storageState({ indexedDB: options.indexedDB });
|
||||||
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');
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ scheme.APIRequestContextFetchLogResult = tObject({
|
||||||
log: tArray(tString),
|
log: tArray(tString),
|
||||||
});
|
});
|
||||||
scheme.APIRequestContextStorageStateParams = tObject({
|
scheme.APIRequestContextStorageStateParams = tObject({
|
||||||
indexedDB: tBoolean,
|
indexedDB: tOptional(tBoolean),
|
||||||
});
|
});
|
||||||
scheme.APIRequestContextStorageStateResult = tObject({
|
scheme.APIRequestContextStorageStateResult = tObject({
|
||||||
cookies: tArray(tType('NetworkCookie')),
|
cookies: tArray(tType('NetworkCookie')),
|
||||||
|
|
@ -995,7 +995,7 @@ scheme.BrowserContextSetOfflineParams = tObject({
|
||||||
});
|
});
|
||||||
scheme.BrowserContextSetOfflineResult = tOptional(tObject({}));
|
scheme.BrowserContextSetOfflineResult = tOptional(tObject({}));
|
||||||
scheme.BrowserContextStorageStateParams = tObject({
|
scheme.BrowserContextStorageStateParams = tObject({
|
||||||
indexedDB: tBoolean,
|
indexedDB: tOptional(tBoolean),
|
||||||
});
|
});
|
||||||
scheme.BrowserContextStorageStateResult = tObject({
|
scheme.BrowserContextStorageStateResult = tObject({
|
||||||
cookies: tArray(tType('NetworkCookie')),
|
cookies: tArray(tType('NetworkCookie')),
|
||||||
|
|
|
||||||
|
|
@ -508,7 +508,7 @@ export abstract class BrowserContext extends SdkObject {
|
||||||
this._origins.add(origin);
|
this._origins.add(origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
async storageState(indexedDB: boolean): Promise<channels.BrowserContextStorageStateResult> {
|
async storageState(indexedDB = true): Promise<channels.BrowserContextStorageStateResult> {
|
||||||
const result: channels.BrowserContextStorageStateResult = {
|
const result: channels.BrowserContextStorageStateResult = {
|
||||||
cookies: await this.cookies(),
|
cookies: await this.cookies(),
|
||||||
origins: []
|
origins: []
|
||||||
|
|
|
||||||
|
|
@ -194,8 +194,8 @@ export class APIRequestContextDispatcher extends Dispatcher<APIRequestContext, c
|
||||||
this.adopt(tracing);
|
this.adopt(tracing);
|
||||||
}
|
}
|
||||||
|
|
||||||
async storageState(): Promise<channels.APIRequestContextStorageStateResult> {
|
async storageState(params: channels.APIRequestContextStorageStateParams): Promise<channels.APIRequestContextStorageStateResult> {
|
||||||
return this._object.storageState();
|
return this._object.storageState(params.indexedDB);
|
||||||
}
|
}
|
||||||
|
|
||||||
async dispose(params: channels.APIRequestContextDisposeParams, metadata: CallMetadata): Promise<void> {
|
async dispose(params: channels.APIRequestContextDisposeParams, metadata: CallMetadata): Promise<void> {
|
||||||
|
|
|
||||||
|
|
@ -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(indexedDB: boolean): 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,7 +618,7 @@ export class BrowserContextAPIRequestContext extends APIRequestContext {
|
||||||
return await this._context.cookies(url.toString());
|
return await this._context.cookies(url.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
override async storageState(indexedDB: boolean): Promise<channels.APIRequestContextStorageStateResult> {
|
override async storageState(indexedDB?: boolean): Promise<channels.APIRequestContextStorageStateResult> {
|
||||||
return this._context.storageState(indexedDB);
|
return this._context.storageState(indexedDB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -684,7 +684,7 @@ export class GlobalAPIRequestContext extends APIRequestContext {
|
||||||
return this._cookieStore.cookies(url);
|
return this._cookieStore.cookies(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async storageState(indexedDB: boolean): Promise<channels.APIRequestContextStorageStateResult> {
|
override async storageState(indexedDB = true): Promise<channels.APIRequestContextStorageStateResult> {
|
||||||
return {
|
return {
|
||||||
cookies: this._cookieStore.allCookies(),
|
cookies: this._cookieStore.allCookies(),
|
||||||
origins: (this._origins || []).map(origin => ({ ...origin, indexedDB: indexedDB ? origin.indexedDB : [] })),
|
origins: (this._origins || []).map(origin => ({ ...origin, indexedDB: indexedDB ? origin.indexedDB : [] })),
|
||||||
|
|
|
||||||
8
packages/protocol/src/channels.d.ts
vendored
8
packages/protocol/src/channels.d.ts
vendored
|
|
@ -403,10 +403,10 @@ export type APIRequestContextFetchLogResult = {
|
||||||
log: string[],
|
log: string[],
|
||||||
};
|
};
|
||||||
export type APIRequestContextStorageStateParams = {
|
export type APIRequestContextStorageStateParams = {
|
||||||
indexedDB: boolean,
|
indexedDB?: boolean,
|
||||||
};
|
};
|
||||||
export type APIRequestContextStorageStateOptions = {
|
export type APIRequestContextStorageStateOptions = {
|
||||||
|
indexedDB?: boolean,
|
||||||
};
|
};
|
||||||
export type APIRequestContextStorageStateResult = {
|
export type APIRequestContextStorageStateResult = {
|
||||||
cookies: NetworkCookie[],
|
cookies: NetworkCookie[],
|
||||||
|
|
@ -1802,10 +1802,10 @@ export type BrowserContextSetOfflineOptions = {
|
||||||
};
|
};
|
||||||
export type BrowserContextSetOfflineResult = void;
|
export type BrowserContextSetOfflineResult = void;
|
||||||
export type BrowserContextStorageStateParams = {
|
export type BrowserContextStorageStateParams = {
|
||||||
indexedDB: boolean,
|
indexedDB?: boolean,
|
||||||
};
|
};
|
||||||
export type BrowserContextStorageStateOptions = {
|
export type BrowserContextStorageStateOptions = {
|
||||||
|
indexedDB?: boolean,
|
||||||
};
|
};
|
||||||
export type BrowserContextStorageStateResult = {
|
export type BrowserContextStorageStateResult = {
|
||||||
cookies: NetworkCookie[],
|
cookies: NetworkCookie[],
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,7 @@ APIRequestContext:
|
||||||
|
|
||||||
storageState:
|
storageState:
|
||||||
parameters:
|
parameters:
|
||||||
indexedDB: boolean
|
indexedDB: boolean?
|
||||||
returns:
|
returns:
|
||||||
cookies:
|
cookies:
|
||||||
type: array
|
type: array
|
||||||
|
|
@ -1237,7 +1237,7 @@ BrowserContext:
|
||||||
|
|
||||||
storageState:
|
storageState:
|
||||||
parameters:
|
parameters:
|
||||||
indexedDB: boolean
|
indexedDB: boolean?
|
||||||
returns:
|
returns:
|
||||||
cookies:
|
cookies:
|
||||||
type: array
|
type: array
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue