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> { 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');

View file

@ -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');

View file

@ -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')),

View file

@ -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: []

View file

@ -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> {

View file

@ -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 : [] })),

View file

@ -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[],

View file

@ -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