move default to server

This commit is contained in:
Simon Knott 2025-02-06 16:04:12 +01:00
parent 39bfa40983
commit c33f548e49
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
8 changed files with 16 additions and 16 deletions

View file

@ -426,7 +426,7 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>
}
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) {
await mkdirIfNeeded(options.path);
await fs.promises.writeFile(options.path, JSON.stringify(state, undefined, 2), 'utf8');

View file

@ -261,7 +261,7 @@ export class APIRequestContext extends ChannelOwner<channels.APIRequestContextCh
}
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) {
await mkdirIfNeeded(options.path);
await fs.promises.writeFile(options.path, JSON.stringify(state, undefined, 2), 'utf8');

View file

@ -235,7 +235,7 @@ scheme.APIRequestContextFetchLogResult = tObject({
log: tArray(tString),
});
scheme.APIRequestContextStorageStateParams = tObject({
indexedDB: tBoolean,
indexedDB: tOptional(tBoolean),
});
scheme.APIRequestContextStorageStateResult = tObject({
cookies: tArray(tType('NetworkCookie')),
@ -995,7 +995,7 @@ scheme.BrowserContextSetOfflineParams = tObject({
});
scheme.BrowserContextSetOfflineResult = tOptional(tObject({}));
scheme.BrowserContextStorageStateParams = tObject({
indexedDB: tBoolean,
indexedDB: tOptional(tBoolean),
});
scheme.BrowserContextStorageStateResult = tObject({
cookies: tArray(tType('NetworkCookie')),

View file

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

View file

@ -194,8 +194,8 @@ export class APIRequestContextDispatcher extends Dispatcher<APIRequestContext, c
this.adopt(tracing);
}
async storageState(): Promise<channels.APIRequestContextStorageStateResult> {
return this._object.storageState();
async storageState(params: channels.APIRequestContextStorageStateParams): Promise<channels.APIRequestContextStorageStateResult> {
return this._object.storageState(params.indexedDB);
}
async dispose(params: channels.APIRequestContextDisposeParams, metadata: CallMetadata): Promise<void> {

View file

@ -133,7 +133,7 @@ export abstract class APIRequestContext extends SdkObject {
abstract _defaultOptions(): FetchRequestOptions;
abstract _addCookies(cookies: channels.NetworkCookie[]): Promise<void>;
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 {
const uid = createGuid();
@ -618,7 +618,7 @@ export class BrowserContextAPIRequestContext extends APIRequestContext {
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);
}
}
@ -684,7 +684,7 @@ export class GlobalAPIRequestContext extends APIRequestContext {
return this._cookieStore.cookies(url);
}
override async storageState(indexedDB: boolean): Promise<channels.APIRequestContextStorageStateResult> {
override async storageState(indexedDB = true): Promise<channels.APIRequestContextStorageStateResult> {
return {
cookies: this._cookieStore.allCookies(),
origins: (this._origins || []).map(origin => ({ ...origin, indexedDB: indexedDB ? origin.indexedDB : [] })),

View file

@ -403,10 +403,10 @@ export type APIRequestContextFetchLogResult = {
log: string[],
};
export type APIRequestContextStorageStateParams = {
indexedDB: boolean,
indexedDB?: boolean,
};
export type APIRequestContextStorageStateOptions = {
indexedDB?: boolean,
};
export type APIRequestContextStorageStateResult = {
cookies: NetworkCookie[],
@ -1802,10 +1802,10 @@ export type BrowserContextSetOfflineOptions = {
};
export type BrowserContextSetOfflineResult = void;
export type BrowserContextStorageStateParams = {
indexedDB: boolean,
indexedDB?: boolean,
};
export type BrowserContextStorageStateOptions = {
indexedDB?: boolean,
};
export type BrowserContextStorageStateResult = {
cookies: NetworkCookie[],

View file

@ -377,7 +377,7 @@ APIRequestContext:
storageState:
parameters:
indexedDB: boolean
indexedDB: boolean?
returns:
cookies:
type: array
@ -1237,7 +1237,7 @@ BrowserContext:
storageState:
parameters:
indexedDB: boolean
indexedDB: boolean?
returns:
cookies:
type: array