diff --git a/packages/playwright-core/src/client/android.ts b/packages/playwright-core/src/client/android.ts index 62db6ef1cde40..b97dfb0d7b91e 100644 --- a/packages/playwright-core/src/client/android.ts +++ b/packages/playwright-core/src/client/android.ts @@ -57,7 +57,7 @@ export class Android extends ChannelOwner implements ap } async devices(options: { port?: number } = {}): Promise { - const { devices } = await this._channel.devices(options, undefined); + const { devices } = await this._channel.devices(options, { signal: undefined, timeout: 0 }); return devices.map(d => AndroidDevice.from(d)); } @@ -71,8 +71,8 @@ export class Android extends ChannelOwner implements ap return await this._wrapApiCall(async () => { const deadline = options.timeout ? monotonicTime() + options.timeout : 0; const headers = { 'x-playwright-browser': 'android', ...options.headers }; - const connectParams: channels.LocalUtilsConnectParams = { endpoint, headers, slowMo: options.slowMo, timeout: options.timeout || 0 }; - const connection = await connectToEndpoint(this._connection, connectParams); + const connectParams: channels.LocalUtilsConnectParams = { endpoint, headers, slowMo: options.slowMo }; + const connection = await connectToEndpoint(this._connection, connectParams, options.timeout || 0); let device: AndroidDevice; connection.on('close', () => { @@ -139,6 +139,10 @@ export class AndroidDevice extends ChannelOwner i this._timeoutSettings.setDefaultTimeout(timeout); } + _timeout(options?: types.TimeoutOptions): channels.CommandOptions { + return { signal: options?.signal, timeout: this._timeoutSettings.timeout(options || {}) }; + } + serial(): string { return this._initializer.serial; } @@ -166,11 +170,11 @@ export class AndroidDevice extends ChannelOwner i } async wait(selector: api.AndroidSelector, options: { state?: 'gone' } & types.TimeoutOptions = {}) { - await this._channel.wait({ androidSelector: toSelectorChannel(selector), ...options, timeout: this._timeoutSettings.timeout(options) }, options.signal); + await this._channel.wait({ androidSelector: toSelectorChannel(selector), ...options }, this._timeout(options)); } async fill(selector: api.AndroidSelector, text: string, options: types.TimeoutOptions = {}) { - await this._channel.fill({ androidSelector: toSelectorChannel(selector), text, ...options, timeout: this._timeoutSettings.timeout(options) }, options.signal); + await this._channel.fill({ androidSelector: toSelectorChannel(selector), text, ...options }, this._timeout(options)); } async press(selector: api.AndroidSelector, key: api.AndroidKey, options: types.TimeoutOptions = {}) { @@ -179,43 +183,43 @@ export class AndroidDevice extends ChannelOwner i } async tap(selector: api.AndroidSelector, options: { duration?: number } & types.TimeoutOptions = {}) { - await this._channel.tap({ androidSelector: toSelectorChannel(selector), ...options, timeout: this._timeoutSettings.timeout(options) }, options.signal); + await this._channel.tap({ androidSelector: toSelectorChannel(selector), ...options }, this._timeout(options)); } async drag(selector: api.AndroidSelector, dest: types.Point, options: SpeedOptions & types.TimeoutOptions = {}) { - await this._channel.drag({ androidSelector: toSelectorChannel(selector), dest, ...options, timeout: this._timeoutSettings.timeout(options) }, options.signal); + await this._channel.drag({ androidSelector: toSelectorChannel(selector), dest, ...options }, this._timeout(options)); } async fling(selector: api.AndroidSelector, direction: Direction, options: SpeedOptions & types.TimeoutOptions = {}) { - await this._channel.fling({ androidSelector: toSelectorChannel(selector), direction, ...options, timeout: this._timeoutSettings.timeout(options) }, options.signal); + await this._channel.fling({ androidSelector: toSelectorChannel(selector), direction, ...options }, this._timeout(options)); } async longTap(selector: api.AndroidSelector, options: types.TimeoutOptions = {}) { - await this._channel.longTap({ androidSelector: toSelectorChannel(selector), ...options, timeout: this._timeoutSettings.timeout(options) }, options.signal); + await this._channel.longTap({ androidSelector: toSelectorChannel(selector), ...options }, this._timeout(options)); } async pinchClose(selector: api.AndroidSelector, percent: number, options: SpeedOptions & types.TimeoutOptions = {}) { - await this._channel.pinchClose({ androidSelector: toSelectorChannel(selector), percent, ...options, timeout: this._timeoutSettings.timeout(options) }, options.signal); + await this._channel.pinchClose({ androidSelector: toSelectorChannel(selector), percent, ...options }, this._timeout(options)); } async pinchOpen(selector: api.AndroidSelector, percent: number, options: SpeedOptions & types.TimeoutOptions = {}) { - await this._channel.pinchOpen({ androidSelector: toSelectorChannel(selector), percent, ...options, timeout: this._timeoutSettings.timeout(options) }, options.signal); + await this._channel.pinchOpen({ androidSelector: toSelectorChannel(selector), percent, ...options }, this._timeout(options)); } async scroll(selector: api.AndroidSelector, direction: Direction, percent: number, options: SpeedOptions & types.TimeoutOptions = {}) { - await this._channel.scroll({ androidSelector: toSelectorChannel(selector), direction, percent, ...options, timeout: this._timeoutSettings.timeout(options) }, options.signal); + await this._channel.scroll({ androidSelector: toSelectorChannel(selector), direction, percent, ...options }, this._timeout(options)); } async swipe(selector: api.AndroidSelector, direction: Direction, percent: number, options: SpeedOptions & types.TimeoutOptions = {}) { - await this._channel.swipe({ androidSelector: toSelectorChannel(selector), direction, percent, ...options, timeout: this._timeoutSettings.timeout(options) }, options.signal); + await this._channel.swipe({ androidSelector: toSelectorChannel(selector), direction, percent, ...options }, this._timeout(options)); } async info(selector: api.AndroidSelector): Promise { - return (await this._channel.info({ androidSelector: toSelectorChannel(selector) }, undefined)).info; + return (await this._channel.info({ androidSelector: toSelectorChannel(selector) }, { signal: undefined, timeout: 0 })).info; } async screenshot(options: { path?: string } = {}): Promise { - const { binary } = await this._channel.screenshot({}, undefined); + const { binary } = await this._channel.screenshot({}, { signal: undefined, timeout: 0 }); if (options.path) await fs.promises.writeFile(options.path, binary); return binary; @@ -230,7 +234,7 @@ export class AndroidDevice extends ChannelOwner i if (this._shouldCloseConnectionOnClose) this._connection.close(); else - await this._channel.close({}, undefined); + await this._channel.close({}, { signal: undefined, timeout: 0 }); } catch (e) { if (isTargetClosedError(e)) return; @@ -243,25 +247,25 @@ export class AndroidDevice extends ChannelOwner i } async shell(command: string): Promise { - const { result } = await this._channel.shell({ command }, undefined); + const { result } = await this._channel.shell({ command }, { signal: undefined, timeout: 0 }); return result; } async open(command: string): Promise { - return AndroidSocket.from((await this._channel.open({ command }, undefined)).socket); + return AndroidSocket.from((await this._channel.open({ command }, { signal: undefined, timeout: 0 })).socket); } async installApk(file: string | Buffer, options?: { args: string[] }): Promise { - await this._channel.installApk({ file: await loadFile(file), args: options && options.args }, undefined); + await this._channel.installApk({ file: await loadFile(file), args: options && options.args }, { signal: undefined, timeout: 0 }); } async push(file: string | Buffer, path: string, options?: { mode: number }): Promise { - await this._channel.push({ file: await loadFile(file), path, mode: options ? options.mode : undefined }, undefined); + await this._channel.push({ file: await loadFile(file), path, mode: options ? options.mode : undefined }, { signal: undefined, timeout: 0 }); } async launchBrowser(options: types.BrowserContextOptions & { pkg?: string } = {}): Promise { const contextOptions = await prepareBrowserContextParams(options); - const result = await this._channel.launchBrowser(contextOptions, undefined); + const result = await this._channel.launchBrowser(contextOptions, { signal: undefined, timeout: 0 }); const context = BrowserContext.from(result.context); const selectors = this._android._playwright.selectors; selectors._contextsForSelectors.add(context); @@ -299,11 +303,11 @@ export class AndroidSocket extends ChannelOwner i } async write(data: Buffer): Promise { - await this._channel.write({ data }, undefined); + await this._channel.write({ data }, { signal: undefined, timeout: 0 }); } async close(): Promise { - await this._channel.close({}, undefined); + await this._channel.close({}, { signal: undefined, timeout: 0 }); } async [Symbol.asyncDispose]() { @@ -325,23 +329,23 @@ export class AndroidInput implements api.AndroidInput { } async type(text: string) { - await this._device._channel.inputType({ text }, undefined); + await this._device._channel.inputType({ text }, { signal: undefined, timeout: 0 }); } async press(key: api.AndroidKey) { - await this._device._channel.inputPress({ key }, undefined); + await this._device._channel.inputPress({ key }, { signal: undefined, timeout: 0 }); } async tap(point: types.Point) { - await this._device._channel.inputTap({ point }, undefined); + await this._device._channel.inputTap({ point }, { signal: undefined, timeout: 0 }); } async swipe(from: types.Point, segments: types.Point[], steps: number) { - await this._device._channel.inputSwipe({ segments, steps }, undefined); + await this._device._channel.inputSwipe({ segments, steps }, { signal: undefined, timeout: 0 }); } async drag(from: types.Point, to: types.Point, steps: number) { - await this._device._channel.inputDrag({ from, to, steps }, undefined); + await this._device._channel.inputDrag({ from, to, steps }, { signal: undefined, timeout: 0 }); } } @@ -425,7 +429,7 @@ export class AndroidWebView extends EventEmitter implements api.AndroidWebView { } private async _fetchPage(): Promise { - const { context } = await this._device._channel.connectToWebView({ socketName: this._data.socketName }, undefined); + const { context } = await this._device._channel.connectToWebView({ socketName: this._data.socketName }, { signal: undefined, timeout: 0 }); return BrowserContext.from(context).pages()[0]; } } diff --git a/packages/playwright-core/src/client/artifact.ts b/packages/playwright-core/src/client/artifact.ts index add07a472e551..f4e500a5f7e39 100644 --- a/packages/playwright-core/src/client/artifact.ts +++ b/packages/playwright-core/src/client/artifact.ts @@ -31,16 +31,16 @@ export class Artifact extends ChannelOwner { async pathAfterFinished(): Promise { if (this._connection.isRemote()) throw new Error(`Path is not available when connecting remotely. Use saveAs() to save a local copy.`); - return (await this._channel.pathAfterFinished({}, undefined)).value; + return (await this._channel.pathAfterFinished({}, { signal: undefined, timeout: 0 })).value; } async saveAs(path: string): Promise { if (!this._connection.isRemote()) { - await this._channel.saveAs({ path }, undefined); + await this._channel.saveAs({ path }, { signal: undefined, timeout: 0 }); return; } - const result = await this._channel.saveAsStream({}, undefined); + const result = await this._channel.saveAsStream({}, { signal: undefined, timeout: 0 }); const stream = Stream.from(result.stream); await mkdirIfNeeded(path); await new Promise((resolve, reject) => { @@ -51,11 +51,11 @@ export class Artifact extends ChannelOwner { } async failure(): Promise { - return (await this._channel.failure({}, undefined)).error || null; + return (await this._channel.failure({}, { signal: undefined, timeout: 0 })).error || null; } async createReadStream(): Promise { - const result = await this._channel.stream({}, undefined); + const result = await this._channel.stream({}, { signal: undefined, timeout: 0 }); const stream = Stream.from(result.stream); return stream.stream(); } @@ -75,10 +75,10 @@ export class Artifact extends ChannelOwner { } async cancel(): Promise { - return await this._channel.cancel({}, undefined); + return await this._channel.cancel({}, { signal: undefined, timeout: 0 }); } async delete(): Promise { - return await this._channel.delete({}, undefined); + return await this._channel.delete({}, { signal: undefined, timeout: 0 }); } } diff --git a/packages/playwright-core/src/client/browser.ts b/packages/playwright-core/src/client/browser.ts index 803a53f969bda..832b11c69fb96 100644 --- a/packages/playwright-core/src/client/browser.ts +++ b/packages/playwright-core/src/client/browser.ts @@ -75,14 +75,14 @@ export class Browser extends ChannelOwner implements ap for (const page of context.pages()) page._onClose(); context._onClose(); - await this._channel.disconnectFromReusedContext({ reason }, undefined); + await this._channel.disconnectFromReusedContext({ reason }, { signal: undefined, timeout: 0 }); } async _innerNewContext(userOptions: BrowserContextOptions = {}, forReuse: boolean): Promise { const options = this._browserType._playwright.selectors._withSelectorOptions(userOptions); await this._instrumentation.runBeforeCreateBrowserContext(options); const contextOptions = await prepareBrowserContextParams(options); - const response = forReuse ? await this._channel.newContextForReuse(contextOptions, undefined) : await this._channel.newContext(contextOptions, undefined); + const response = forReuse ? await this._channel.newContextForReuse(contextOptions, { signal: undefined, timeout: 0 }) : await this._channel.newContext(contextOptions, { signal: undefined, timeout: 0 }); const context = BrowserContext.from(response.context); if (forReuse) context._forReuse = true; @@ -132,12 +132,12 @@ export class Browser extends ChannelOwner implements ap } async bind(title: string, options: { workspaceDir?: string, metadata?: Record, host?: string, port?: number } = {}): Promise<{ endpoint: string }> { - const { endpoint } = await this._channel.startServer({ title, ...options }, undefined); + const { endpoint } = await this._channel.startServer({ title, ...options }, { signal: undefined, timeout: 0 }); return { endpoint }; } async unbind(): Promise { - await this._channel.stopServer({}, undefined); + await this._channel.stopServer({}, { signal: undefined, timeout: 0 }); } async newPage(options: BrowserContextOptions = {}): Promise { @@ -155,16 +155,16 @@ export class Browser extends ChannelOwner implements ap } async newBrowserCDPSession(): Promise { - return CDPSession.from((await this._channel.newBrowserCDPSession({}, undefined)).session); + return CDPSession.from((await this._channel.newBrowserCDPSession({}, { signal: undefined, timeout: 0 })).session); } async startTracing(page?: Page, options: { path?: string; screenshots?: boolean; categories?: string[]; } = {}) { this._path = options.path; - await this._channel.startTracing({ ...options, page: page ? page._channel : undefined }, undefined); + await this._channel.startTracing({ ...options, page: page ? page._channel : undefined }, { signal: undefined, timeout: 0 }); } async stopTracing(): Promise { - const artifact = Artifact.from((await this._channel.stopTracing({}, undefined)).artifact); + const artifact = Artifact.from((await this._channel.stopTracing({}, { signal: undefined, timeout: 0 })).artifact); const buffer = await artifact.readIntoBuffer(); await artifact.delete(); if (this._path) { @@ -185,7 +185,7 @@ export class Browser extends ChannelOwner implements ap if (this._shouldCloseConnectionOnClose) this._connection.close(); else - await this._channel.close(options, undefined); + await this._channel.close(options, { signal: undefined, timeout: 0 }); await this._closedPromise; } catch (e) { if (isTargetClosedError(e)) diff --git a/packages/playwright-core/src/client/browserContext.ts b/packages/playwright-core/src/client/browserContext.ts index 70ada2e326876..73c25b847fdea 100644 --- a/packages/playwright-core/src/client/browserContext.ts +++ b/packages/playwright-core/src/client/browserContext.ts @@ -149,9 +149,9 @@ export class BrowserContext extends ChannelOwner // a) removing "dialog" listener subscription (client->server) // b) actual "dialog" event (server->client) if (dialogObject.type() === 'beforeunload') - dialog.accept({}, undefined).catch(() => {}); + dialog.accept({}, { signal: undefined, timeout: 0 }).catch(() => {}); else - dialog.dismiss({}, undefined).catch(() => {}); + dialog.dismiss({}, { signal: undefined, timeout: 0 }).catch(() => {}); } }); this._channel.on('request', ({ request, page }) => this._onRequest(network.Request.from(request), Page.fromNullable(page))); @@ -304,7 +304,7 @@ export class BrowserContext extends ChannelOwner async newPage(): Promise { if (this._ownerPage) throw new Error('Please use browser.newContext()'); - return Page.from((await this._channel.newPage({}, undefined)).page); + return Page.from((await this._channel.newPage({}, { signal: undefined, timeout: 0 })).page); } async cookies(urls?: string | string[]): Promise { @@ -312,11 +312,11 @@ export class BrowserContext extends ChannelOwner urls = []; if (urls && typeof urls === 'string') urls = [urls]; - return (await this._channel.cookies({ urls: urls as string[] }, undefined)).cookies; + return (await this._channel.cookies({ urls: urls as string[] }, { signal: undefined, timeout: 0 })).cookies; } async addCookies(cookies: network.SetNetworkCookieParam[]): Promise { - await this._channel.addCookies({ cookies }, undefined); + await this._channel.addCookies({ cookies }, { signal: undefined, timeout: 0 }); } async clearCookies(options: network.ClearNetworkCookieOptions = {}): Promise { @@ -330,47 +330,47 @@ export class BrowserContext extends ChannelOwner path: isString(options.path) ? options.path : undefined, pathRegexSource: isRegExp(options.path) ? options.path.source : undefined, pathRegexFlags: isRegExp(options.path) ? options.path.flags : undefined, - }, undefined); + }, { signal: undefined, timeout: 0 }); } async grantPermissions(permissions: string[], options?: { origin?: string }): Promise { - await this._channel.grantPermissions({ permissions, ...options }, undefined); + await this._channel.grantPermissions({ permissions, ...options }, { signal: undefined, timeout: 0 }); } async clearPermissions(): Promise { - await this._channel.clearPermissions({}, undefined); + await this._channel.clearPermissions({}, { signal: undefined, timeout: 0 }); } async setGeolocation(geolocation: { longitude: number, latitude: number, accuracy?: number } | null): Promise { - await this._channel.setGeolocation({ geolocation: geolocation || undefined }, undefined); + await this._channel.setGeolocation({ geolocation: geolocation || undefined }, { signal: undefined, timeout: 0 }); } async setExtraHTTPHeaders(headers: Headers): Promise { network.validateHeaders(headers); - await this._channel.setExtraHTTPHeaders({ headers: headersObjectToArray(headers) }, undefined); + await this._channel.setExtraHTTPHeaders({ headers: headersObjectToArray(headers) }, { signal: undefined, timeout: 0 }); } async setOffline(offline: boolean): Promise { - await this._channel.setOffline({ offline }, undefined); + await this._channel.setOffline({ offline }, { signal: undefined, timeout: 0 }); } async setHTTPCredentials(httpCredentials: { username: string, password: string } | null): Promise { - await this._channel.setHTTPCredentials({ httpCredentials: httpCredentials || undefined }, undefined); + await this._channel.setHTTPCredentials({ httpCredentials: httpCredentials || undefined }, { signal: undefined, timeout: 0 }); } async addInitScript(script: Function | string | { path?: string, content?: string }, arg?: any) { const source = await evaluationScript(script, arg); - return DisposableObject.from((await this._channel.addInitScript({ source }, undefined)).disposable); + return DisposableObject.from((await this._channel.addInitScript({ source }, { signal: undefined, timeout: 0 })).disposable); } async exposeBinding(name: string, callback: (source: structs.BindingSource, ...args: any[]) => any): Promise { - const result = await this._channel.exposeBinding({ name }, undefined); + const result = await this._channel.exposeBinding({ name }, { signal: undefined, timeout: 0 }); this._bindings.set(name, callback); return DisposableObject.from(result.disposable); } async exposeFunction(name: string, callback: Function): Promise { - const result = await this._channel.exposeBinding({ name }, undefined); + const result = await this._channel.exposeBinding({ name }, { signal: undefined, timeout: 0 }); const binding = (source: structs.BindingSource, ...args: any[]) => callback(...args); this._bindings.set(name, binding); return DisposableObject.from(result.disposable); @@ -435,12 +435,12 @@ export class BrowserContext extends ChannelOwner private async _updateInterceptionPatterns(options: { internal: true } | { title: string }) { const patterns = network.RouteHandler.prepareInterceptionPatterns(this._routes); - await this._wrapApiCall(() => this._channel.setNetworkInterceptionPatterns({ patterns }, undefined), options); + await this._wrapApiCall(() => this._channel.setNetworkInterceptionPatterns({ patterns }, { signal: undefined, timeout: 0 }), options); } private async _updateWebSocketInterceptionPatterns(options: { internal: true } | { title: string }) { const patterns = network.WebSocketRouteHandler.prepareInterceptionPatterns(this._webSocketRoutes); - await this._wrapApiCall(() => this._channel.setWebSocketInterceptionPatterns({ patterns }, undefined), options); + await this._wrapApiCall(() => this._channel.setWebSocketInterceptionPatterns({ patterns }, { signal: undefined, timeout: 0 }), options); } _effectiveCloseReason(): string | undefined { @@ -464,7 +464,7 @@ export class BrowserContext extends ChannelOwner } async storageState(options: { path?: string, indexedDB?: boolean, credentials?: boolean } = {}): Promise { - const state = await this._channel.storageState({ indexedDB: options.indexedDB, credentials: options.credentials }, undefined); + const state = await this._channel.storageState({ indexedDB: options.indexedDB, credentials: options.credentials }, { signal: undefined, timeout: 0 }); if (options.path) { await mkdirIfNeeded(options.path); await fs.promises.writeFile(options.path, JSON.stringify(state, undefined, 2), 'utf8'); @@ -474,7 +474,7 @@ export class BrowserContext extends ChannelOwner async setStorageState(storageState: string | SetStorageState): Promise { const state = await prepareStorageState(storageState); - await this._channel.setStorageState({ storageState: state }, undefined); + await this._channel.setStorageState({ storageState: state }, { signal: undefined, timeout: 0 }); } backgroundPages(): Page[] { @@ -489,7 +489,7 @@ export class BrowserContext extends ChannelOwner // channelOwner.ts's validation messages don't handle the pseudo-union type, so we're explicit here if (!(page instanceof Page) && !(page instanceof Frame)) throw new Error('page: expected Page or Frame'); - const result = await this._channel.newCDPSession(page instanceof Page ? { page: page._channel } : { frame: page._channel }, undefined); + const result = await this._channel.newCDPSession(page instanceof Page ? { page: page._channel } : { frame: page._channel }, { signal: undefined, timeout: 0 }); return CDPSession.from(result.session); } @@ -515,23 +515,23 @@ export class BrowserContext extends ChannelOwner await this.request.dispose(options); await this._instrumentation.runBeforeCloseBrowserContext(this); await this.tracing._exportAllHars(); - await this._channel.close(options, undefined); + await this._channel.close(options, { signal: undefined, timeout: 0 }); await this._closedPromise; } async _enableRecorder(params: channels.BrowserContextEnableRecorderParams, eventSink?: RecorderEventSink) { if (eventSink) this._onRecorderEventSink = eventSink; - await this._channel.enableRecorder(params, undefined); + await this._channel.enableRecorder(params, { signal: undefined, timeout: 0 }); } async _disableRecorder() { this._onRecorderEventSink = undefined; - await this._channel.disableRecorder({}, undefined); + await this._channel.disableRecorder({}, { signal: undefined, timeout: 0 }); } async _exposeConsoleApi() { - await this._channel.exposeConsoleApi({}, undefined); + await this._channel.exposeConsoleApi({}, { signal: undefined, timeout: 0 }); } } diff --git a/packages/playwright-core/src/client/browserType.ts b/packages/playwright-core/src/client/browserType.ts index 9b6d42cc6b7e6..6bd55a2d29629 100644 --- a/packages/playwright-core/src/client/browserType.ts +++ b/packages/playwright-core/src/client/browserType.ts @@ -74,10 +74,9 @@ export class BrowserType extends ChannelOwner imple ignoreDefaultArgs: Array.isArray(options.ignoreDefaultArgs) ? options.ignoreDefaultArgs : undefined, ignoreAllDefaultArgs: !!options.ignoreDefaultArgs && !Array.isArray(options.ignoreDefaultArgs), env: options.env ? envObjectToArray(options.env) : undefined, - timeout: new TimeoutSettings().launchTimeout(options), }; return await this._wrapApiCall(async () => { - const browser = Browser.from((await this._channel.launch(launchOptions, options.signal)).browser); + const browser = Browser.from((await this._channel.launch(launchOptions, { signal: options.signal, timeout: new TimeoutSettings().launchTimeout(options) })).browser); browser._connectToBrowserType(this, options, logger); return browser; }); @@ -107,10 +106,9 @@ export class BrowserType extends ChannelOwner imple env: options.env ? envObjectToArray(options.env) : undefined, channel: options.channel, userDataDir: (path.isAbsolute(userDataDir) || !userDataDir) ? userDataDir : path.resolve(userDataDir), - timeout: new TimeoutSettings().launchTimeout(options), }; const context = await this._wrapApiCall(async () => { - const result = await this._channel.launchPersistentContext(persistentParams, options.signal); + const result = await this._channel.launchPersistentContext(persistentParams, { signal: options.signal, timeout: new TimeoutSettings().launchTimeout(options) }); const browser = Browser.from(result.browser); browser._connectToBrowserType(this, options, logger); const context = BrowserContext.from(result.context); @@ -168,11 +166,10 @@ export class BrowserType extends ChannelOwner imple transport: transport as any, headers: params.headers ? headersObjectToArray(params.headers) : undefined, slowMo: params.slowMo, - timeout: new TimeoutSettings().timeout(params), isLocal: params.isLocal, noDefaults: params.noDefaults, artifactsDir: params.artifactsDir, - }, undefined); + }, { signal: undefined, timeout: new TimeoutSettings().timeout(params) }); return await this._browserFromConnectResult(result); } @@ -189,8 +186,7 @@ export class BrowserType extends ChannelOwner imple throw new Error('Connecting to workers is only supported in Chromium.'); const result = await this._channel.connectToWorker({ endpoint, - timeout: new TimeoutSettings().timeout(options), - }, undefined); + }, { signal: undefined, timeout: new TimeoutSettings().timeout(options) }); return Worker.from(result.worker); } } diff --git a/packages/playwright-core/src/client/cdpSession.ts b/packages/playwright-core/src/client/cdpSession.ts index 0353411054341..3441d31e0c4a8 100644 --- a/packages/playwright-core/src/client/cdpSession.ts +++ b/packages/playwright-core/src/client/cdpSession.ts @@ -48,11 +48,11 @@ export class CDPSession extends ChannelOwner impleme method: T, params?: Protocol.CommandParameters[T] ): Promise { - const result = await this._channel.send({ method, params }, undefined); + const result = await this._channel.send({ method, params }, { signal: undefined, timeout: 0 }); return result.result as Protocol.CommandReturnValues[T]; } async detach() { - return await this._channel.detach({}, undefined); + return await this._channel.detach({}, { signal: undefined, timeout: 0 }); } } diff --git a/packages/playwright-core/src/client/channelOwner.ts b/packages/playwright-core/src/client/channelOwner.ts index 18d1e7ddc793c..e2f2856b53558 100644 --- a/packages/playwright-core/src/client/channelOwner.ts +++ b/packages/playwright-core/src/client/channelOwner.ts @@ -151,19 +151,20 @@ export abstract class ChannelOwner { + return async (params: any, options: { signal?: AbortSignal, timeout?: number } = {}) => { return await this._wrapApiCall(async apiZone => { const validatedParams = validator(params, '', this._validatorToWireContext()); + const { signal, timeout = 0 } = options; if (!apiZone.internal && !apiZone.reported) { // Reporting/tracing/logging this api call for the first time. apiZone.reported = true; this._instrumentation.onApiCallBegin(apiZone, { type: this._type, method: prop, params }); logApiCall(this._logger, `=> ${apiZone.apiName} started`); - return await this._connection.sendMessageToServer(this, prop, validatedParams, { ...apiZone, signal }); + return await this._connection.sendMessageToServer(this, prop, validatedParams, { ...apiZone, signal, timeout }); } // Since this api call is either internal, or has already been reported/traced once, // passing as internal. - return await this._connection.sendMessageToServer(this, prop, validatedParams, { internal: true, signal }); + return await this._connection.sendMessageToServer(this, prop, validatedParams, { internal: true, signal, timeout }); }, { internal }); }; } diff --git a/packages/playwright-core/src/client/channels.d.ts b/packages/playwright-core/src/client/channels.d.ts index 6a2902e0f5982..bd8b9059ddab0 100644 --- a/packages/playwright-core/src/client/channels.d.ts +++ b/packages/playwright-core/src/client/channels.d.ts @@ -18,6 +18,8 @@ import type { Binary, Channel, AndroidWebView, AndroidSelector, AndroidElementInfo, APIResponse, Metadata, ClientSideCallMetadata, SDKLanguage, WaitInfo, SetNetworkCookie, NetworkCookie, ResourceTiming, SecurityDetails, RequestSizes, RemoteAddr, ExpectedTextValue, SelectorEngine, FormField, LifecycleEvent, ConsoleMessagesFilter, RecorderSource, IndexedDBDatabase, SetOriginStorage, OriginStorage, RecordHarOptions, SerializedValue, SerializedArgument, SerializedError, StackFrame, VirtualCredential, Point, Rect, URLPattern, NameValue } from '@protocol/structs'; export type { Binary, Channel, AndroidWebView, AndroidSelector, AndroidElementInfo, APIResponse, Metadata, ClientSideCallMetadata, SDKLanguage, WaitInfo, SetNetworkCookie, NetworkCookie, ResourceTiming, SecurityDetails, RequestSizes, RemoteAddr, ExpectedTextValue, SelectorEngine, FormField, LifecycleEvent, ConsoleMessagesFilter, RecorderSource, IndexedDBDatabase, SetOriginStorage, OriginStorage, RecordHarOptions, SerializedValue, SerializedArgument, SerializedError, StackFrame, VirtualCredential, Point, Rect, URLPattern, NameValue } from '@protocol/structs'; +export type CommandOptions = { signal: AbortSignal | undefined, timeout: number }; + // ----------- Initializer Traits ----------- export type InitializerTraits = T extends ElementHandleChannel ? ElementHandleInitializer : @@ -138,7 +140,7 @@ export interface AndroidEventTarget { } export interface AndroidChannel extends AndroidEventTarget, Channel { _type_Android: boolean; - devices(params: AndroidDevicesParams, signal: AbortSignal | undefined): Promise; + devices(params: AndroidDevicesParams, options: CommandOptions): Promise; } export type AndroidDevicesParams = { host?: string, @@ -165,8 +167,8 @@ export interface AndroidSocketEventTarget { } export interface AndroidSocketChannel extends AndroidSocketEventTarget, Channel { _type_AndroidSocket: boolean; - write(params: AndroidSocketWriteParams, signal: AbortSignal | undefined): Promise; - close(params: AndroidSocketCloseParams, signal: AbortSignal | undefined): Promise; + write(params: AndroidSocketWriteParams, options: CommandOptions): Promise; + close(params: AndroidSocketCloseParams, options: CommandOptions): Promise; } export type AndroidSocketDataEvent = { data: Binary, @@ -200,30 +202,30 @@ export interface AndroidDeviceEventTarget { } export interface AndroidDeviceChannel extends AndroidDeviceEventTarget, Channel { _type_AndroidDevice: boolean; - wait(params: AndroidDeviceWaitParams, signal: AbortSignal | undefined): Promise; - fill(params: AndroidDeviceFillParams, signal: AbortSignal | undefined): Promise; - tap(params: AndroidDeviceTapParams, signal: AbortSignal | undefined): Promise; - drag(params: AndroidDeviceDragParams, signal: AbortSignal | undefined): Promise; - fling(params: AndroidDeviceFlingParams, signal: AbortSignal | undefined): Promise; - longTap(params: AndroidDeviceLongTapParams, signal: AbortSignal | undefined): Promise; - pinchClose(params: AndroidDevicePinchCloseParams, signal: AbortSignal | undefined): Promise; - pinchOpen(params: AndroidDevicePinchOpenParams, signal: AbortSignal | undefined): Promise; - scroll(params: AndroidDeviceScrollParams, signal: AbortSignal | undefined): Promise; - swipe(params: AndroidDeviceSwipeParams, signal: AbortSignal | undefined): Promise; - info(params: AndroidDeviceInfoParams, signal: AbortSignal | undefined): Promise; - screenshot(params: AndroidDeviceScreenshotParams, signal: AbortSignal | undefined): Promise; - inputType(params: AndroidDeviceInputTypeParams, signal: AbortSignal | undefined): Promise; - inputPress(params: AndroidDeviceInputPressParams, signal: AbortSignal | undefined): Promise; - inputTap(params: AndroidDeviceInputTapParams, signal: AbortSignal | undefined): Promise; - inputSwipe(params: AndroidDeviceInputSwipeParams, signal: AbortSignal | undefined): Promise; - inputDrag(params: AndroidDeviceInputDragParams, signal: AbortSignal | undefined): Promise; - launchBrowser(params: AndroidDeviceLaunchBrowserParams, signal: AbortSignal | undefined): Promise; - open(params: AndroidDeviceOpenParams, signal: AbortSignal | undefined): Promise; - shell(params: AndroidDeviceShellParams, signal: AbortSignal | undefined): Promise; - installApk(params: AndroidDeviceInstallApkParams, signal: AbortSignal | undefined): Promise; - push(params: AndroidDevicePushParams, signal: AbortSignal | undefined): Promise; - connectToWebView(params: AndroidDeviceConnectToWebViewParams, signal: AbortSignal | undefined): Promise; - close(params: AndroidDeviceCloseParams, signal: AbortSignal | undefined): Promise; + wait(params: AndroidDeviceWaitParams, options: CommandOptions): Promise; + fill(params: AndroidDeviceFillParams, options: CommandOptions): Promise; + tap(params: AndroidDeviceTapParams, options: CommandOptions): Promise; + drag(params: AndroidDeviceDragParams, options: CommandOptions): Promise; + fling(params: AndroidDeviceFlingParams, options: CommandOptions): Promise; + longTap(params: AndroidDeviceLongTapParams, options: CommandOptions): Promise; + pinchClose(params: AndroidDevicePinchCloseParams, options: CommandOptions): Promise; + pinchOpen(params: AndroidDevicePinchOpenParams, options: CommandOptions): Promise; + scroll(params: AndroidDeviceScrollParams, options: CommandOptions): Promise; + swipe(params: AndroidDeviceSwipeParams, options: CommandOptions): Promise; + info(params: AndroidDeviceInfoParams, options: CommandOptions): Promise; + screenshot(params: AndroidDeviceScreenshotParams, options: CommandOptions): Promise; + inputType(params: AndroidDeviceInputTypeParams, options: CommandOptions): Promise; + inputPress(params: AndroidDeviceInputPressParams, options: CommandOptions): Promise; + inputTap(params: AndroidDeviceInputTapParams, options: CommandOptions): Promise; + inputSwipe(params: AndroidDeviceInputSwipeParams, options: CommandOptions): Promise; + inputDrag(params: AndroidDeviceInputDragParams, options: CommandOptions): Promise; + launchBrowser(params: AndroidDeviceLaunchBrowserParams, options: CommandOptions): Promise; + open(params: AndroidDeviceOpenParams, options: CommandOptions): Promise; + shell(params: AndroidDeviceShellParams, options: CommandOptions): Promise; + installApk(params: AndroidDeviceInstallApkParams, options: CommandOptions): Promise; + push(params: AndroidDevicePushParams, options: CommandOptions): Promise; + connectToWebView(params: AndroidDeviceConnectToWebViewParams, options: CommandOptions): Promise; + close(params: AndroidDeviceCloseParams, options: CommandOptions): Promise; } export type AndroidDeviceCloseEvent = {}; export type AndroidDeviceWebViewAddedEvent = { @@ -235,7 +237,6 @@ export type AndroidDeviceWebViewRemovedEvent = { export type AndroidDeviceWaitParams = { androidSelector: AndroidSelector, state?: 'gone', - timeout: number, }; export type AndroidDeviceWaitOptions = { state?: 'gone', @@ -244,7 +245,6 @@ export type AndroidDeviceWaitResult = void; export type AndroidDeviceFillParams = { androidSelector: AndroidSelector, text: string, - timeout: number, }; export type AndroidDeviceFillOptions = { @@ -253,7 +253,6 @@ export type AndroidDeviceFillResult = void; export type AndroidDeviceTapParams = { androidSelector: AndroidSelector, duration?: number, - timeout: number, }; export type AndroidDeviceTapOptions = { duration?: number, @@ -263,7 +262,6 @@ export type AndroidDeviceDragParams = { androidSelector: AndroidSelector, dest: Point, speed?: number, - timeout: number, }; export type AndroidDeviceDragOptions = { speed?: number, @@ -273,7 +271,6 @@ export type AndroidDeviceFlingParams = { androidSelector: AndroidSelector, direction: 'up' | 'down' | 'left' | 'right', speed?: number, - timeout: number, }; export type AndroidDeviceFlingOptions = { speed?: number, @@ -281,7 +278,6 @@ export type AndroidDeviceFlingOptions = { export type AndroidDeviceFlingResult = void; export type AndroidDeviceLongTapParams = { androidSelector: AndroidSelector, - timeout: number, }; export type AndroidDeviceLongTapOptions = { @@ -291,7 +287,6 @@ export type AndroidDevicePinchCloseParams = { androidSelector: AndroidSelector, percent: number, speed?: number, - timeout: number, }; export type AndroidDevicePinchCloseOptions = { speed?: number, @@ -301,7 +296,6 @@ export type AndroidDevicePinchOpenParams = { androidSelector: AndroidSelector, percent: number, speed?: number, - timeout: number, }; export type AndroidDevicePinchOpenOptions = { speed?: number, @@ -312,7 +306,6 @@ export type AndroidDeviceScrollParams = { direction: 'up' | 'down' | 'left' | 'right', percent: number, speed?: number, - timeout: number, }; export type AndroidDeviceScrollOptions = { speed?: number, @@ -323,7 +316,6 @@ export type AndroidDeviceSwipeParams = { direction: 'up' | 'down' | 'left' | 'right', percent: number, speed?: number, - timeout: number, }; export type AndroidDeviceSwipeOptions = { speed?: number, @@ -590,12 +582,12 @@ export interface APIRequestContextEventTarget { } export interface APIRequestContextChannel extends APIRequestContextEventTarget, Channel { _type_APIRequestContext: boolean; - fetch(params: APIRequestContextFetchParams, signal: AbortSignal | undefined): Promise; - fetchResponseBody(params: APIRequestContextFetchResponseBodyParams, signal: AbortSignal | undefined): Promise; - fetchLog(params: APIRequestContextFetchLogParams, signal: AbortSignal | undefined): Promise; - storageState(params: APIRequestContextStorageStateParams, signal: AbortSignal | undefined): Promise; - disposeAPIResponse(params: APIRequestContextDisposeAPIResponseParams, signal: AbortSignal | undefined): Promise; - dispose(params: APIRequestContextDisposeParams, signal: AbortSignal | undefined): Promise; + fetch(params: APIRequestContextFetchParams, options: CommandOptions): Promise; + fetchResponseBody(params: APIRequestContextFetchResponseBodyParams, options: CommandOptions): Promise; + fetchLog(params: APIRequestContextFetchLogParams, options: CommandOptions): Promise; + storageState(params: APIRequestContextStorageStateParams, options: CommandOptions): Promise; + disposeAPIResponse(params: APIRequestContextDisposeAPIResponseParams, options: CommandOptions): Promise; + dispose(params: APIRequestContextDisposeParams, options: CommandOptions): Promise; } export type APIRequestContextFetchParams = { url: string, @@ -607,7 +599,6 @@ export type APIRequestContextFetchParams = { jsonData?: string, formData?: NameValue[], multipartData?: FormField[], - timeout: number, failOnStatusCode?: boolean, ignoreHTTPSErrors?: boolean, maxRedirects?: number, @@ -684,13 +675,13 @@ export interface ArtifactEventTarget { } export interface ArtifactChannel extends ArtifactEventTarget, Channel { _type_Artifact: boolean; - pathAfterFinished(params: ArtifactPathAfterFinishedParams, signal: AbortSignal | undefined): Promise; - saveAs(params: ArtifactSaveAsParams, signal: AbortSignal | undefined): Promise; - saveAsStream(params: ArtifactSaveAsStreamParams, signal: AbortSignal | undefined): Promise; - failure(params: ArtifactFailureParams, signal: AbortSignal | undefined): Promise; - stream(params: ArtifactStreamParams, signal: AbortSignal | undefined): Promise; - cancel(params: ArtifactCancelParams, signal: AbortSignal | undefined): Promise; - delete(params: ArtifactDeleteParams, signal: AbortSignal | undefined): Promise; + pathAfterFinished(params: ArtifactPathAfterFinishedParams, options: CommandOptions): Promise; + saveAs(params: ArtifactSaveAsParams, options: CommandOptions): Promise; + saveAsStream(params: ArtifactSaveAsStreamParams, options: CommandOptions): Promise; + failure(params: ArtifactFailureParams, options: CommandOptions): Promise; + stream(params: ArtifactStreamParams, options: CommandOptions): Promise; + cancel(params: ArtifactCancelParams, options: CommandOptions): Promise; + delete(params: ArtifactDeleteParams, options: CommandOptions): Promise; } export type ArtifactPathAfterFinishedParams = {}; export type ArtifactPathAfterFinishedOptions = {}; @@ -735,8 +726,8 @@ export interface StreamEventTarget { } export interface StreamChannel extends StreamEventTarget, Channel { _type_Stream: boolean; - read(params: StreamReadParams, signal: AbortSignal | undefined): Promise; - close(params: StreamCloseParams, signal: AbortSignal | undefined): Promise; + read(params: StreamReadParams, options: CommandOptions): Promise; + close(params: StreamCloseParams, options: CommandOptions): Promise; } export type StreamReadParams = { size?: number, @@ -760,8 +751,8 @@ export interface WritableStreamEventTarget { } export interface WritableStreamChannel extends WritableStreamEventTarget, Channel { _type_WritableStream: boolean; - write(params: WritableStreamWriteParams, signal: AbortSignal | undefined): Promise; - close(params: WritableStreamCloseParams, signal: AbortSignal | undefined): Promise; + write(params: WritableStreamWriteParams, options: CommandOptions): Promise; + close(params: WritableStreamCloseParams, options: CommandOptions): Promise; } export type WritableStreamWriteParams = { binary: Binary, @@ -789,17 +780,17 @@ export interface BrowserEventTarget { } export interface BrowserChannel extends BrowserEventTarget, Channel { _type_Browser: boolean; - startServer(params: BrowserStartServerParams, signal: AbortSignal | undefined): Promise; - stopServer(params: BrowserStopServerParams, signal: AbortSignal | undefined): Promise; - close(params: BrowserCloseParams, signal: AbortSignal | undefined): Promise; - killForTests(params: BrowserKillForTestsParams, signal: AbortSignal | undefined): Promise; - defaultUserAgentForTest(params: BrowserDefaultUserAgentForTestParams, signal: AbortSignal | undefined): Promise; - newContext(params: BrowserNewContextParams, signal: AbortSignal | undefined): Promise; - newContextForReuse(params: BrowserNewContextForReuseParams, signal: AbortSignal | undefined): Promise; - disconnectFromReusedContext(params: BrowserDisconnectFromReusedContextParams, signal: AbortSignal | undefined): Promise; - newBrowserCDPSession(params: BrowserNewBrowserCDPSessionParams, signal: AbortSignal | undefined): Promise; - startTracing(params: BrowserStartTracingParams, signal: AbortSignal | undefined): Promise; - stopTracing(params: BrowserStopTracingParams, signal: AbortSignal | undefined): Promise; + startServer(params: BrowserStartServerParams, options: CommandOptions): Promise; + stopServer(params: BrowserStopServerParams, options: CommandOptions): Promise; + close(params: BrowserCloseParams, options: CommandOptions): Promise; + killForTests(params: BrowserKillForTestsParams, options: CommandOptions): Promise; + defaultUserAgentForTest(params: BrowserDefaultUserAgentForTestParams, options: CommandOptions): Promise; + newContext(params: BrowserNewContextParams, options: CommandOptions): Promise; + newContextForReuse(params: BrowserNewContextForReuseParams, options: CommandOptions): Promise; + disconnectFromReusedContext(params: BrowserDisconnectFromReusedContextParams, options: CommandOptions): Promise; + newBrowserCDPSession(params: BrowserNewBrowserCDPSessionParams, options: CommandOptions): Promise; + startTracing(params: BrowserStartTracingParams, options: CommandOptions): Promise; + stopTracing(params: BrowserStopTracingParams, options: CommandOptions): Promise; } export type BrowserContextEvent = { context: BrowserContextChannel, @@ -1267,45 +1258,45 @@ export interface BrowserContextEventTarget { } export interface BrowserContextChannel extends BrowserContextEventTarget, Channel { _type_BrowserContext: boolean; - addCookies(params: BrowserContextAddCookiesParams, signal: AbortSignal | undefined): Promise; - addInitScript(params: BrowserContextAddInitScriptParams, signal: AbortSignal | undefined): Promise; - clearCookies(params: BrowserContextClearCookiesParams, signal: AbortSignal | undefined): Promise; - clearPermissions(params: BrowserContextClearPermissionsParams, signal: AbortSignal | undefined): Promise; - close(params: BrowserContextCloseParams, signal: AbortSignal | undefined): Promise; - cookies(params: BrowserContextCookiesParams, signal: AbortSignal | undefined): Promise; - exposeBinding(params: BrowserContextExposeBindingParams, signal: AbortSignal | undefined): Promise; - grantPermissions(params: BrowserContextGrantPermissionsParams, signal: AbortSignal | undefined): Promise; - newPage(params: BrowserContextNewPageParams, signal: AbortSignal | undefined): Promise; - registerSelectorEngine(params: BrowserContextRegisterSelectorEngineParams, signal: AbortSignal | undefined): Promise; - setTestIdAttributeName(params: BrowserContextSetTestIdAttributeNameParams, signal: AbortSignal | undefined): Promise; - setExtraHTTPHeaders(params: BrowserContextSetExtraHTTPHeadersParams, signal: AbortSignal | undefined): Promise; - setGeolocation(params: BrowserContextSetGeolocationParams, signal: AbortSignal | undefined): Promise; - setHTTPCredentials(params: BrowserContextSetHTTPCredentialsParams, signal: AbortSignal | undefined): Promise; - setNetworkInterceptionPatterns(params: BrowserContextSetNetworkInterceptionPatternsParams, signal: AbortSignal | undefined): Promise; - routeAPIRequestsFromHar(params: BrowserContextRouteAPIRequestsFromHarParams, signal: AbortSignal | undefined): Promise; - unrouteAPIRequestsFromHar(params: BrowserContextUnrouteAPIRequestsFromHarParams, signal: AbortSignal | undefined): Promise; - setWebSocketInterceptionPatterns(params: BrowserContextSetWebSocketInterceptionPatternsParams, signal: AbortSignal | undefined): Promise; - setOffline(params: BrowserContextSetOfflineParams, signal: AbortSignal | undefined): Promise; - storageState(params: BrowserContextStorageStateParams, signal: AbortSignal | undefined): Promise; - setStorageState(params: BrowserContextSetStorageStateParams, signal: AbortSignal | undefined): Promise; - pause(params: BrowserContextPauseParams, signal: AbortSignal | undefined): Promise; - enableRecorder(params: BrowserContextEnableRecorderParams, signal: AbortSignal | undefined): Promise; - disableRecorder(params: BrowserContextDisableRecorderParams, signal: AbortSignal | undefined): Promise; - exposeConsoleApi(params: BrowserContextExposeConsoleApiParams, signal: AbortSignal | undefined): Promise; - newCDPSession(params: BrowserContextNewCDPSessionParams, signal: AbortSignal | undefined): Promise; - createTempFiles(params: BrowserContextCreateTempFilesParams, signal: AbortSignal | undefined): Promise; - updateSubscription(params: BrowserContextUpdateSubscriptionParams, signal: AbortSignal | undefined): Promise; - clockFastForward(params: BrowserContextClockFastForwardParams, signal: AbortSignal | undefined): Promise; - clockInstall(params: BrowserContextClockInstallParams, signal: AbortSignal | undefined): Promise; - clockPauseAt(params: BrowserContextClockPauseAtParams, signal: AbortSignal | undefined): Promise; - clockResume(params: BrowserContextClockResumeParams, signal: AbortSignal | undefined): Promise; - clockRunFor(params: BrowserContextClockRunForParams, signal: AbortSignal | undefined): Promise; - clockSetFixedTime(params: BrowserContextClockSetFixedTimeParams, signal: AbortSignal | undefined): Promise; - clockSetSystemTime(params: BrowserContextClockSetSystemTimeParams, signal: AbortSignal | undefined): Promise; - credentialsInstall(params: BrowserContextCredentialsInstallParams, signal: AbortSignal | undefined): Promise; - credentialsCreate(params: BrowserContextCredentialsCreateParams, signal: AbortSignal | undefined): Promise; - credentialsGet(params: BrowserContextCredentialsGetParams, signal: AbortSignal | undefined): Promise; - credentialsDelete(params: BrowserContextCredentialsDeleteParams, signal: AbortSignal | undefined): Promise; + addCookies(params: BrowserContextAddCookiesParams, options: CommandOptions): Promise; + addInitScript(params: BrowserContextAddInitScriptParams, options: CommandOptions): Promise; + clearCookies(params: BrowserContextClearCookiesParams, options: CommandOptions): Promise; + clearPermissions(params: BrowserContextClearPermissionsParams, options: CommandOptions): Promise; + close(params: BrowserContextCloseParams, options: CommandOptions): Promise; + cookies(params: BrowserContextCookiesParams, options: CommandOptions): Promise; + exposeBinding(params: BrowserContextExposeBindingParams, options: CommandOptions): Promise; + grantPermissions(params: BrowserContextGrantPermissionsParams, options: CommandOptions): Promise; + newPage(params: BrowserContextNewPageParams, options: CommandOptions): Promise; + registerSelectorEngine(params: BrowserContextRegisterSelectorEngineParams, options: CommandOptions): Promise; + setTestIdAttributeName(params: BrowserContextSetTestIdAttributeNameParams, options: CommandOptions): Promise; + setExtraHTTPHeaders(params: BrowserContextSetExtraHTTPHeadersParams, options: CommandOptions): Promise; + setGeolocation(params: BrowserContextSetGeolocationParams, options: CommandOptions): Promise; + setHTTPCredentials(params: BrowserContextSetHTTPCredentialsParams, options: CommandOptions): Promise; + setNetworkInterceptionPatterns(params: BrowserContextSetNetworkInterceptionPatternsParams, options: CommandOptions): Promise; + routeAPIRequestsFromHar(params: BrowserContextRouteAPIRequestsFromHarParams, options: CommandOptions): Promise; + unrouteAPIRequestsFromHar(params: BrowserContextUnrouteAPIRequestsFromHarParams, options: CommandOptions): Promise; + setWebSocketInterceptionPatterns(params: BrowserContextSetWebSocketInterceptionPatternsParams, options: CommandOptions): Promise; + setOffline(params: BrowserContextSetOfflineParams, options: CommandOptions): Promise; + storageState(params: BrowserContextStorageStateParams, options: CommandOptions): Promise; + setStorageState(params: BrowserContextSetStorageStateParams, options: CommandOptions): Promise; + pause(params: BrowserContextPauseParams, options: CommandOptions): Promise; + enableRecorder(params: BrowserContextEnableRecorderParams, options: CommandOptions): Promise; + disableRecorder(params: BrowserContextDisableRecorderParams, options: CommandOptions): Promise; + exposeConsoleApi(params: BrowserContextExposeConsoleApiParams, options: CommandOptions): Promise; + newCDPSession(params: BrowserContextNewCDPSessionParams, options: CommandOptions): Promise; + createTempFiles(params: BrowserContextCreateTempFilesParams, options: CommandOptions): Promise; + updateSubscription(params: BrowserContextUpdateSubscriptionParams, options: CommandOptions): Promise; + clockFastForward(params: BrowserContextClockFastForwardParams, options: CommandOptions): Promise; + clockInstall(params: BrowserContextClockInstallParams, options: CommandOptions): Promise; + clockPauseAt(params: BrowserContextClockPauseAtParams, options: CommandOptions): Promise; + clockResume(params: BrowserContextClockResumeParams, options: CommandOptions): Promise; + clockRunFor(params: BrowserContextClockRunForParams, options: CommandOptions): Promise; + clockSetFixedTime(params: BrowserContextClockSetFixedTimeParams, options: CommandOptions): Promise; + clockSetSystemTime(params: BrowserContextClockSetSystemTimeParams, options: CommandOptions): Promise; + credentialsInstall(params: BrowserContextCredentialsInstallParams, options: CommandOptions): Promise; + credentialsCreate(params: BrowserContextCredentialsCreateParams, options: CommandOptions): Promise; + credentialsGet(params: BrowserContextCredentialsGetParams, options: CommandOptions): Promise; + credentialsDelete(params: BrowserContextCredentialsDeleteParams, options: CommandOptions): Promise; } export type BrowserContextBindingCallEvent = { binding: BindingCallChannel, @@ -1778,10 +1769,10 @@ export interface BrowserTypeEventTarget { } export interface BrowserTypeChannel extends BrowserTypeEventTarget, Channel { _type_BrowserType: boolean; - launch(params: BrowserTypeLaunchParams, signal: AbortSignal | undefined): Promise; - launchPersistentContext(params: BrowserTypeLaunchPersistentContextParams, signal: AbortSignal | undefined): Promise; - connectOverCDP(params: BrowserTypeConnectOverCDPParams, signal: AbortSignal | undefined): Promise; - connectToWorker(params: BrowserTypeConnectToWorkerParams, signal: AbortSignal | undefined): Promise; + launch(params: BrowserTypeLaunchParams, options: CommandOptions): Promise; + launchPersistentContext(params: BrowserTypeLaunchPersistentContextParams, options: CommandOptions): Promise; + connectOverCDP(params: BrowserTypeConnectOverCDPParams, options: CommandOptions): Promise; + connectToWorker(params: BrowserTypeConnectToWorkerParams, options: CommandOptions): Promise; } export type BrowserTypeLaunchParams = { channel?: string, @@ -1792,7 +1783,6 @@ export type BrowserTypeLaunchParams = { handleSIGINT?: boolean, handleSIGTERM?: boolean, handleSIGHUP?: boolean, - timeout: number, env?: NameValue[], headless?: boolean, proxy?: { @@ -1846,7 +1836,6 @@ export type BrowserTypeLaunchPersistentContextParams = { handleSIGINT?: boolean, handleSIGTERM?: boolean, handleSIGHUP?: boolean, - timeout: number, env?: NameValue[], headless?: boolean, proxy?: { @@ -2021,7 +2010,6 @@ export type BrowserTypeConnectOverCDPParams = { endpointURL?: string, headers?: NameValue[], slowMo?: number, - timeout: number, isLocal?: boolean, noDefaults?: boolean, artifactsDir?: string, @@ -2042,7 +2030,6 @@ export type BrowserTypeConnectOverCDPResult = { }; export type BrowserTypeConnectToWorkerParams = { endpoint: string, - timeout: number, }; export type BrowserTypeConnectToWorkerOptions = { @@ -2060,7 +2047,7 @@ export interface DisposableEventTarget { } export interface DisposableChannel extends DisposableEventTarget, Channel { _type_Disposable: boolean; - dispose(params: DisposableDisposeParams, signal: AbortSignal | undefined): Promise; + dispose(params: DisposableDisposeParams, options: CommandOptions): Promise; } export type DisposableDisposeParams = {}; export type DisposableDisposeOptions = {}; @@ -2075,7 +2062,7 @@ export interface ElectronEventTarget { } export interface ElectronChannel extends ElectronEventTarget, Channel { _type_Electron: boolean; - launch(params: ElectronLaunchParams, signal: AbortSignal | undefined): Promise; + launch(params: ElectronLaunchParams, options: CommandOptions): Promise; } export type ElectronLaunchParams = { executablePath?: string, @@ -2083,7 +2070,6 @@ export type ElectronLaunchParams = { chromiumSandbox?: boolean, cwd?: string, env?: NameValue[], - timeout: number, acceptDownloads?: 'accept' | 'deny' | 'internal-browser-default', bypassCSP?: boolean, colorScheme?: 'dark' | 'light' | 'no-preference' | 'no-override', @@ -2181,10 +2167,10 @@ export interface ElectronApplicationEventTarget { } export interface ElectronApplicationChannel extends ElectronApplicationEventTarget, Channel { _type_ElectronApplication: boolean; - browserWindow(params: ElectronApplicationBrowserWindowParams, signal: AbortSignal | undefined): Promise; - evaluateExpression(params: ElectronApplicationEvaluateExpressionParams, signal: AbortSignal | undefined): Promise; - evaluateExpressionHandle(params: ElectronApplicationEvaluateExpressionHandleParams, signal: AbortSignal | undefined): Promise; - updateSubscription(params: ElectronApplicationUpdateSubscriptionParams, signal: AbortSignal | undefined): Promise; + browserWindow(params: ElectronApplicationBrowserWindowParams, options: CommandOptions): Promise; + evaluateExpression(params: ElectronApplicationEvaluateExpressionParams, options: CommandOptions): Promise; + evaluateExpressionHandle(params: ElectronApplicationEvaluateExpressionHandleParams, options: CommandOptions): Promise; + updateSubscription(params: ElectronApplicationUpdateSubscriptionParams, options: CommandOptions): Promise; } export type ElectronApplicationCloseEvent = {}; export type ElectronApplicationConsoleEvent = { @@ -2256,55 +2242,55 @@ export interface FrameEventTarget { } export interface FrameChannel extends FrameEventTarget, Channel { _type_Frame: boolean; - evalOnSelector(params: FrameEvalOnSelectorParams, signal: AbortSignal | undefined): Promise; - evalOnSelectorAll(params: FrameEvalOnSelectorAllParams, signal: AbortSignal | undefined): Promise; - addScriptTag(params: FrameAddScriptTagParams, signal: AbortSignal | undefined): Promise; - addStyleTag(params: FrameAddStyleTagParams, signal: AbortSignal | undefined): Promise; - ariaSnapshot(params: FrameAriaSnapshotParams, signal: AbortSignal | undefined): Promise; - blur(params: FrameBlurParams, signal: AbortSignal | undefined): Promise; - check(params: FrameCheckParams, signal: AbortSignal | undefined): Promise; - click(params: FrameClickParams, signal: AbortSignal | undefined): Promise; - content(params: FrameContentParams, signal: AbortSignal | undefined): Promise; - dragAndDrop(params: FrameDragAndDropParams, signal: AbortSignal | undefined): Promise; - drop(params: FrameDropParams, signal: AbortSignal | undefined): Promise; - dblclick(params: FrameDblclickParams, signal: AbortSignal | undefined): Promise; - dispatchEvent(params: FrameDispatchEventParams, signal: AbortSignal | undefined): Promise; - evaluateExpression(params: FrameEvaluateExpressionParams, signal: AbortSignal | undefined): Promise; - evaluateExpressionHandle(params: FrameEvaluateExpressionHandleParams, signal: AbortSignal | undefined): Promise; - fill(params: FrameFillParams, signal: AbortSignal | undefined): Promise; - focus(params: FrameFocusParams, signal: AbortSignal | undefined): Promise; - frameElement(params: FrameFrameElementParams, signal: AbortSignal | undefined): Promise; - resolveSelector(params: FrameResolveSelectorParams, signal: AbortSignal | undefined): Promise; - highlight(params: FrameHighlightParams, signal: AbortSignal | undefined): Promise; - hideHighlight(params: FrameHideHighlightParams, signal: AbortSignal | undefined): Promise; - getAttribute(params: FrameGetAttributeParams, signal: AbortSignal | undefined): Promise; - goto(params: FrameGotoParams, signal: AbortSignal | undefined): Promise; - hover(params: FrameHoverParams, signal: AbortSignal | undefined): Promise; - innerHTML(params: FrameInnerHTMLParams, signal: AbortSignal | undefined): Promise; - innerText(params: FrameInnerTextParams, signal: AbortSignal | undefined): Promise; - inputValue(params: FrameInputValueParams, signal: AbortSignal | undefined): Promise; - isChecked(params: FrameIsCheckedParams, signal: AbortSignal | undefined): Promise; - isDisabled(params: FrameIsDisabledParams, signal: AbortSignal | undefined): Promise; - isEnabled(params: FrameIsEnabledParams, signal: AbortSignal | undefined): Promise; - isHidden(params: FrameIsHiddenParams, signal: AbortSignal | undefined): Promise; - isVisible(params: FrameIsVisibleParams, signal: AbortSignal | undefined): Promise; - isEditable(params: FrameIsEditableParams, signal: AbortSignal | undefined): Promise; - press(params: FramePressParams, signal: AbortSignal | undefined): Promise; - querySelector(params: FrameQuerySelectorParams, signal: AbortSignal | undefined): Promise; - querySelectorAll(params: FrameQuerySelectorAllParams, signal: AbortSignal | undefined): Promise; - queryCount(params: FrameQueryCountParams, signal: AbortSignal | undefined): Promise; - selectOption(params: FrameSelectOptionParams, signal: AbortSignal | undefined): Promise; - setContent(params: FrameSetContentParams, signal: AbortSignal | undefined): Promise; - setInputFiles(params: FrameSetInputFilesParams, signal: AbortSignal | undefined): Promise; - tap(params: FrameTapParams, signal: AbortSignal | undefined): Promise; - textContent(params: FrameTextContentParams, signal: AbortSignal | undefined): Promise; - title(params: FrameTitleParams, signal: AbortSignal | undefined): Promise; - type(params: FrameTypeParams, signal: AbortSignal | undefined): Promise; - uncheck(params: FrameUncheckParams, signal: AbortSignal | undefined): Promise; - waitForTimeout(params: FrameWaitForTimeoutParams, signal: AbortSignal | undefined): Promise; - waitForFunction(params: FrameWaitForFunctionParams, signal: AbortSignal | undefined): Promise; - waitForSelector(params: FrameWaitForSelectorParams, signal: AbortSignal | undefined): Promise; - expect(params: FrameExpectParams, signal: AbortSignal | undefined): Promise; + evalOnSelector(params: FrameEvalOnSelectorParams, options: CommandOptions): Promise; + evalOnSelectorAll(params: FrameEvalOnSelectorAllParams, options: CommandOptions): Promise; + addScriptTag(params: FrameAddScriptTagParams, options: CommandOptions): Promise; + addStyleTag(params: FrameAddStyleTagParams, options: CommandOptions): Promise; + ariaSnapshot(params: FrameAriaSnapshotParams, options: CommandOptions): Promise; + blur(params: FrameBlurParams, options: CommandOptions): Promise; + check(params: FrameCheckParams, options: CommandOptions): Promise; + click(params: FrameClickParams, options: CommandOptions): Promise; + content(params: FrameContentParams, options: CommandOptions): Promise; + dragAndDrop(params: FrameDragAndDropParams, options: CommandOptions): Promise; + drop(params: FrameDropParams, options: CommandOptions): Promise; + dblclick(params: FrameDblclickParams, options: CommandOptions): Promise; + dispatchEvent(params: FrameDispatchEventParams, options: CommandOptions): Promise; + evaluateExpression(params: FrameEvaluateExpressionParams, options: CommandOptions): Promise; + evaluateExpressionHandle(params: FrameEvaluateExpressionHandleParams, options: CommandOptions): Promise; + fill(params: FrameFillParams, options: CommandOptions): Promise; + focus(params: FrameFocusParams, options: CommandOptions): Promise; + frameElement(params: FrameFrameElementParams, options: CommandOptions): Promise; + resolveSelector(params: FrameResolveSelectorParams, options: CommandOptions): Promise; + highlight(params: FrameHighlightParams, options: CommandOptions): Promise; + hideHighlight(params: FrameHideHighlightParams, options: CommandOptions): Promise; + getAttribute(params: FrameGetAttributeParams, options: CommandOptions): Promise; + goto(params: FrameGotoParams, options: CommandOptions): Promise; + hover(params: FrameHoverParams, options: CommandOptions): Promise; + innerHTML(params: FrameInnerHTMLParams, options: CommandOptions): Promise; + innerText(params: FrameInnerTextParams, options: CommandOptions): Promise; + inputValue(params: FrameInputValueParams, options: CommandOptions): Promise; + isChecked(params: FrameIsCheckedParams, options: CommandOptions): Promise; + isDisabled(params: FrameIsDisabledParams, options: CommandOptions): Promise; + isEnabled(params: FrameIsEnabledParams, options: CommandOptions): Promise; + isHidden(params: FrameIsHiddenParams, options: CommandOptions): Promise; + isVisible(params: FrameIsVisibleParams, options: CommandOptions): Promise; + isEditable(params: FrameIsEditableParams, options: CommandOptions): Promise; + press(params: FramePressParams, options: CommandOptions): Promise; + querySelector(params: FrameQuerySelectorParams, options: CommandOptions): Promise; + querySelectorAll(params: FrameQuerySelectorAllParams, options: CommandOptions): Promise; + queryCount(params: FrameQueryCountParams, options: CommandOptions): Promise; + selectOption(params: FrameSelectOptionParams, options: CommandOptions): Promise; + setContent(params: FrameSetContentParams, options: CommandOptions): Promise; + setInputFiles(params: FrameSetInputFilesParams, options: CommandOptions): Promise; + tap(params: FrameTapParams, options: CommandOptions): Promise; + textContent(params: FrameTextContentParams, options: CommandOptions): Promise; + title(params: FrameTitleParams, options: CommandOptions): Promise; + type(params: FrameTypeParams, options: CommandOptions): Promise; + uncheck(params: FrameUncheckParams, options: CommandOptions): Promise; + waitForTimeout(params: FrameWaitForTimeoutParams, options: CommandOptions): Promise; + waitForFunction(params: FrameWaitForFunctionParams, options: CommandOptions): Promise; + waitForSelector(params: FrameWaitForSelectorParams, options: CommandOptions): Promise; + expect(params: FrameExpectParams, options: CommandOptions): Promise; } export type FrameLoadstateEvent = { add?: LifecycleEvent, @@ -2373,7 +2359,6 @@ export type FrameAriaSnapshotParams = { selector?: string, depth?: number, boxes?: boolean, - timeout: number, }; export type FrameAriaSnapshotOptions = { mode?: 'ai' | 'default', @@ -2387,7 +2372,6 @@ export type FrameAriaSnapshotResult = { export type FrameBlurParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameBlurOptions = { strict?: boolean, @@ -2399,7 +2383,6 @@ export type FrameCheckParams = { force?: boolean, scroll?: 'auto' | 'none', position?: Point, - timeout: number, trial?: boolean, }; export type FrameCheckOptions = { @@ -2421,7 +2404,6 @@ export type FrameClickParams = { delay?: number, button?: 'left' | 'right' | 'middle', clickCount?: number, - timeout: number, trial?: boolean, steps?: number, }; @@ -2449,7 +2431,6 @@ export type FrameDragAndDropParams = { target: string, force?: boolean, scroll?: 'auto' | 'none', - timeout: number, trial?: boolean, sourcePosition?: Point, targetPosition?: Point, @@ -2481,7 +2462,6 @@ export type FrameDropParams = { mimeType: string, value: string, }[], - timeout: number, }; export type FrameDropOptions = { strict?: boolean, @@ -2508,7 +2488,6 @@ export type FrameDblclickParams = { position?: Point, delay?: number, button?: 'left' | 'right' | 'middle', - timeout: number, trial?: boolean, steps?: number, }; @@ -2529,7 +2508,6 @@ export type FrameDispatchEventParams = { strict?: boolean, type: string, eventInit: SerializedArgument, - timeout: number, }; export type FrameDispatchEventOptions = { strict?: boolean, @@ -2562,7 +2540,6 @@ export type FrameFillParams = { strict?: boolean, value: string, force?: boolean, - timeout: number, }; export type FrameFillOptions = { strict?: boolean, @@ -2572,7 +2549,6 @@ export type FrameFillResult = void; export type FrameFocusParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameFocusOptions = { strict?: boolean, @@ -2611,7 +2587,6 @@ export type FrameGetAttributeParams = { selector: string, strict?: boolean, name: string, - timeout: number, }; export type FrameGetAttributeOptions = { strict?: boolean, @@ -2621,7 +2596,6 @@ export type FrameGetAttributeResult = { }; export type FrameGotoParams = { url: string, - timeout: number, waitUntil?: LifecycleEvent, referer?: string, }; @@ -2639,7 +2613,6 @@ export type FrameHoverParams = { scroll?: 'auto' | 'none', modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[], position?: Point, - timeout: number, trial?: boolean, }; export type FrameHoverOptions = { @@ -2654,7 +2627,6 @@ export type FrameHoverResult = void; export type FrameInnerHTMLParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameInnerHTMLOptions = { strict?: boolean, @@ -2665,7 +2637,6 @@ export type FrameInnerHTMLResult = { export type FrameInnerTextParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameInnerTextOptions = { strict?: boolean, @@ -2676,7 +2647,6 @@ export type FrameInnerTextResult = { export type FrameInputValueParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameInputValueOptions = { strict?: boolean, @@ -2687,7 +2657,6 @@ export type FrameInputValueResult = { export type FrameIsCheckedParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameIsCheckedOptions = { strict?: boolean, @@ -2698,7 +2667,6 @@ export type FrameIsCheckedResult = { export type FrameIsDisabledParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameIsDisabledOptions = { strict?: boolean, @@ -2709,7 +2677,6 @@ export type FrameIsDisabledResult = { export type FrameIsEnabledParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameIsEnabledOptions = { strict?: boolean, @@ -2740,7 +2707,6 @@ export type FrameIsVisibleResult = { export type FrameIsEditableParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameIsEditableOptions = { strict?: boolean, @@ -2754,7 +2720,6 @@ export type FramePressParams = { key: string, delay?: number, noWaitAfter?: boolean, - timeout: number, }; export type FramePressOptions = { strict?: boolean, @@ -2801,7 +2766,6 @@ export type FrameSelectOptionParams = { index?: number, }[], force?: boolean, - timeout: number, }; export type FrameSelectOptionOptions = { strict?: boolean, @@ -2819,7 +2783,6 @@ export type FrameSelectOptionResult = { }; export type FrameSetContentParams = { html: string, - timeout: number, waitUntil?: LifecycleEvent, }; export type FrameSetContentOptions = { @@ -2838,7 +2801,6 @@ export type FrameSetInputFilesParams = { directoryStream?: WritableStreamChannel, localPaths?: string[], streams?: WritableStreamChannel[], - timeout: number, }; export type FrameSetInputFilesOptions = { strict?: boolean, @@ -2860,7 +2822,6 @@ export type FrameTapParams = { scroll?: 'auto' | 'none', modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[], position?: Point, - timeout: number, trial?: boolean, }; export type FrameTapOptions = { @@ -2875,7 +2836,6 @@ export type FrameTapResult = void; export type FrameTextContentParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameTextContentOptions = { strict?: boolean, @@ -2893,7 +2853,6 @@ export type FrameTypeParams = { strict?: boolean, text: string, delay?: number, - timeout: number, }; export type FrameTypeOptions = { strict?: boolean, @@ -2906,7 +2865,6 @@ export type FrameUncheckParams = { force?: boolean, scroll?: 'auto' | 'none', position?: Point, - timeout: number, trial?: boolean, }; export type FrameUncheckOptions = { @@ -2928,7 +2886,6 @@ export type FrameWaitForFunctionParams = { expression: string, isFunction?: boolean, arg: SerializedArgument, - timeout: number, pollingInterval?: number, selector?: string, strict?: boolean, @@ -2945,7 +2902,6 @@ export type FrameWaitForFunctionResult = { export type FrameWaitForSelectorParams = { selector: string, strict?: boolean, - timeout: number, state?: 'attached' | 'detached' | 'visible' | 'hidden', omitReturnValue?: boolean, }; @@ -2967,7 +2923,6 @@ export type FrameExpectParams = { expectedValue?: SerializedArgument, useInnerText?: boolean, isNot: boolean, - timeout: number, }; export type FrameExpectOptions = { selector?: string, @@ -3002,12 +2957,12 @@ export interface JSHandleEventTarget { } export interface JSHandleChannel extends JSHandleEventTarget, Channel { _type_JSHandle: boolean; - dispose(params: JSHandleDisposeParams, signal: AbortSignal | undefined): Promise; - evaluateExpression(params: JSHandleEvaluateExpressionParams, signal: AbortSignal | undefined): Promise; - evaluateExpressionHandle(params: JSHandleEvaluateExpressionHandleParams, signal: AbortSignal | undefined): Promise; - getPropertyList(params: JSHandleGetPropertyListParams, signal: AbortSignal | undefined): Promise; - getProperty(params: JSHandleGetPropertyParams, signal: AbortSignal | undefined): Promise; - jsonValue(params: JSHandleJsonValueParams, signal: AbortSignal | undefined): Promise; + dispose(params: JSHandleDisposeParams, options: CommandOptions): Promise; + evaluateExpression(params: JSHandleEvaluateExpressionParams, options: CommandOptions): Promise; + evaluateExpressionHandle(params: JSHandleEvaluateExpressionHandleParams, options: CommandOptions): Promise; + getPropertyList(params: JSHandleGetPropertyListParams, options: CommandOptions): Promise; + getProperty(params: JSHandleGetPropertyParams, options: CommandOptions): Promise; + jsonValue(params: JSHandleJsonValueParams, options: CommandOptions): Promise; } export type JSHandlePreviewUpdatedEvent = { preview: string, @@ -3070,42 +3025,42 @@ export interface ElementHandleEventTarget { } export interface ElementHandleChannel extends ElementHandleEventTarget, JSHandleChannel { _type_ElementHandle: boolean; - evalOnSelector(params: ElementHandleEvalOnSelectorParams, signal: AbortSignal | undefined): Promise; - evalOnSelectorAll(params: ElementHandleEvalOnSelectorAllParams, signal: AbortSignal | undefined): Promise; - boundingBox(params: ElementHandleBoundingBoxParams, signal: AbortSignal | undefined): Promise; - check(params: ElementHandleCheckParams, signal: AbortSignal | undefined): Promise; - click(params: ElementHandleClickParams, signal: AbortSignal | undefined): Promise; - contentFrame(params: ElementHandleContentFrameParams, signal: AbortSignal | undefined): Promise; - dblclick(params: ElementHandleDblclickParams, signal: AbortSignal | undefined): Promise; - dispatchEvent(params: ElementHandleDispatchEventParams, signal: AbortSignal | undefined): Promise; - fill(params: ElementHandleFillParams, signal: AbortSignal | undefined): Promise; - focus(params: ElementHandleFocusParams, signal: AbortSignal | undefined): Promise; - getAttribute(params: ElementHandleGetAttributeParams, signal: AbortSignal | undefined): Promise; - hover(params: ElementHandleHoverParams, signal: AbortSignal | undefined): Promise; - innerHTML(params: ElementHandleInnerHTMLParams, signal: AbortSignal | undefined): Promise; - innerText(params: ElementHandleInnerTextParams, signal: AbortSignal | undefined): Promise; - inputValue(params: ElementHandleInputValueParams, signal: AbortSignal | undefined): Promise; - isChecked(params: ElementHandleIsCheckedParams, signal: AbortSignal | undefined): Promise; - isDisabled(params: ElementHandleIsDisabledParams, signal: AbortSignal | undefined): Promise; - isEditable(params: ElementHandleIsEditableParams, signal: AbortSignal | undefined): Promise; - isEnabled(params: ElementHandleIsEnabledParams, signal: AbortSignal | undefined): Promise; - isHidden(params: ElementHandleIsHiddenParams, signal: AbortSignal | undefined): Promise; - isVisible(params: ElementHandleIsVisibleParams, signal: AbortSignal | undefined): Promise; - ownerFrame(params: ElementHandleOwnerFrameParams, signal: AbortSignal | undefined): Promise; - press(params: ElementHandlePressParams, signal: AbortSignal | undefined): Promise; - querySelector(params: ElementHandleQuerySelectorParams, signal: AbortSignal | undefined): Promise; - querySelectorAll(params: ElementHandleQuerySelectorAllParams, signal: AbortSignal | undefined): Promise; - screenshot(params: ElementHandleScreenshotParams, signal: AbortSignal | undefined): Promise; - scrollIntoViewIfNeeded(params: ElementHandleScrollIntoViewIfNeededParams, signal: AbortSignal | undefined): Promise; - selectOption(params: ElementHandleSelectOptionParams, signal: AbortSignal | undefined): Promise; - selectText(params: ElementHandleSelectTextParams, signal: AbortSignal | undefined): Promise; - setInputFiles(params: ElementHandleSetInputFilesParams, signal: AbortSignal | undefined): Promise; - tap(params: ElementHandleTapParams, signal: AbortSignal | undefined): Promise; - textContent(params: ElementHandleTextContentParams, signal: AbortSignal | undefined): Promise; - type(params: ElementHandleTypeParams, signal: AbortSignal | undefined): Promise; - uncheck(params: ElementHandleUncheckParams, signal: AbortSignal | undefined): Promise; - waitForElementState(params: ElementHandleWaitForElementStateParams, signal: AbortSignal | undefined): Promise; - waitForSelector(params: ElementHandleWaitForSelectorParams, signal: AbortSignal | undefined): Promise; + evalOnSelector(params: ElementHandleEvalOnSelectorParams, options: CommandOptions): Promise; + evalOnSelectorAll(params: ElementHandleEvalOnSelectorAllParams, options: CommandOptions): Promise; + boundingBox(params: ElementHandleBoundingBoxParams, options: CommandOptions): Promise; + check(params: ElementHandleCheckParams, options: CommandOptions): Promise; + click(params: ElementHandleClickParams, options: CommandOptions): Promise; + contentFrame(params: ElementHandleContentFrameParams, options: CommandOptions): Promise; + dblclick(params: ElementHandleDblclickParams, options: CommandOptions): Promise; + dispatchEvent(params: ElementHandleDispatchEventParams, options: CommandOptions): Promise; + fill(params: ElementHandleFillParams, options: CommandOptions): Promise; + focus(params: ElementHandleFocusParams, options: CommandOptions): Promise; + getAttribute(params: ElementHandleGetAttributeParams, options: CommandOptions): Promise; + hover(params: ElementHandleHoverParams, options: CommandOptions): Promise; + innerHTML(params: ElementHandleInnerHTMLParams, options: CommandOptions): Promise; + innerText(params: ElementHandleInnerTextParams, options: CommandOptions): Promise; + inputValue(params: ElementHandleInputValueParams, options: CommandOptions): Promise; + isChecked(params: ElementHandleIsCheckedParams, options: CommandOptions): Promise; + isDisabled(params: ElementHandleIsDisabledParams, options: CommandOptions): Promise; + isEditable(params: ElementHandleIsEditableParams, options: CommandOptions): Promise; + isEnabled(params: ElementHandleIsEnabledParams, options: CommandOptions): Promise; + isHidden(params: ElementHandleIsHiddenParams, options: CommandOptions): Promise; + isVisible(params: ElementHandleIsVisibleParams, options: CommandOptions): Promise; + ownerFrame(params: ElementHandleOwnerFrameParams, options: CommandOptions): Promise; + press(params: ElementHandlePressParams, options: CommandOptions): Promise; + querySelector(params: ElementHandleQuerySelectorParams, options: CommandOptions): Promise; + querySelectorAll(params: ElementHandleQuerySelectorAllParams, options: CommandOptions): Promise; + screenshot(params: ElementHandleScreenshotParams, options: CommandOptions): Promise; + scrollIntoViewIfNeeded(params: ElementHandleScrollIntoViewIfNeededParams, options: CommandOptions): Promise; + selectOption(params: ElementHandleSelectOptionParams, options: CommandOptions): Promise; + selectText(params: ElementHandleSelectTextParams, options: CommandOptions): Promise; + setInputFiles(params: ElementHandleSetInputFilesParams, options: CommandOptions): Promise; + tap(params: ElementHandleTapParams, options: CommandOptions): Promise; + textContent(params: ElementHandleTextContentParams, options: CommandOptions): Promise; + type(params: ElementHandleTypeParams, options: CommandOptions): Promise; + uncheck(params: ElementHandleUncheckParams, options: CommandOptions): Promise; + waitForElementState(params: ElementHandleWaitForElementStateParams, options: CommandOptions): Promise; + waitForSelector(params: ElementHandleWaitForSelectorParams, options: CommandOptions): Promise; } export type ElementHandleEvalOnSelectorParams = { selector: string, @@ -3142,7 +3097,6 @@ export type ElementHandleCheckParams = { force?: boolean, scroll?: 'auto' | 'none', position?: Point, - timeout: number, trial?: boolean, }; export type ElementHandleCheckOptions = { @@ -3161,7 +3115,6 @@ export type ElementHandleClickParams = { delay?: number, button?: 'left' | 'right' | 'middle', clickCount?: number, - timeout: number, trial?: boolean, steps?: number, }; @@ -3190,7 +3143,6 @@ export type ElementHandleDblclickParams = { position?: Point, delay?: number, button?: 'left' | 'right' | 'middle', - timeout: number, trial?: boolean, steps?: number, }; @@ -3216,7 +3168,6 @@ export type ElementHandleDispatchEventResult = void; export type ElementHandleFillParams = { value: string, force?: boolean, - timeout: number, }; export type ElementHandleFillOptions = { force?: boolean, @@ -3239,7 +3190,6 @@ export type ElementHandleHoverParams = { scroll?: 'auto' | 'none', modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[], position?: Point, - timeout: number, trial?: boolean, }; export type ElementHandleHoverOptions = { @@ -3303,7 +3253,6 @@ export type ElementHandleOwnerFrameResult = { export type ElementHandlePressParams = { key: string, delay?: number, - timeout: number, noWaitAfter?: boolean, }; export type ElementHandlePressOptions = { @@ -3331,7 +3280,6 @@ export type ElementHandleQuerySelectorAllResult = { elements: ElementHandleChannel[], }; export type ElementHandleScreenshotParams = { - timeout: number, type?: 'png' | 'jpeg' | 'webp', quality?: number, omitBackground?: boolean, @@ -3362,12 +3310,8 @@ export type ElementHandleScreenshotOptions = { export type ElementHandleScreenshotResult = { binary: Binary, }; -export type ElementHandleScrollIntoViewIfNeededParams = { - timeout: number, -}; -export type ElementHandleScrollIntoViewIfNeededOptions = { - -}; +export type ElementHandleScrollIntoViewIfNeededParams = {}; +export type ElementHandleScrollIntoViewIfNeededOptions = {}; export type ElementHandleScrollIntoViewIfNeededResult = void; export type ElementHandleSelectOptionParams = { elements?: ElementHandleChannel[], @@ -3378,7 +3322,6 @@ export type ElementHandleSelectOptionParams = { index?: number, }[], force?: boolean, - timeout: number, }; export type ElementHandleSelectOptionOptions = { elements?: ElementHandleChannel[], @@ -3395,7 +3338,6 @@ export type ElementHandleSelectOptionResult = { }; export type ElementHandleSelectTextParams = { force?: boolean, - timeout: number, }; export type ElementHandleSelectTextOptions = { force?: boolean, @@ -3411,7 +3353,6 @@ export type ElementHandleSetInputFilesParams = { directoryStream?: WritableStreamChannel, localPaths?: string[], streams?: WritableStreamChannel[], - timeout: number, }; export type ElementHandleSetInputFilesOptions = { payloads?: { @@ -3430,7 +3371,6 @@ export type ElementHandleTapParams = { scroll?: 'auto' | 'none', modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[], position?: Point, - timeout: number, trial?: boolean, }; export type ElementHandleTapOptions = { @@ -3449,7 +3389,6 @@ export type ElementHandleTextContentResult = { export type ElementHandleTypeParams = { text: string, delay?: number, - timeout: number, }; export type ElementHandleTypeOptions = { delay?: number, @@ -3459,7 +3398,6 @@ export type ElementHandleUncheckParams = { force?: boolean, scroll?: 'auto' | 'none', position?: Point, - timeout: number, trial?: boolean, }; export type ElementHandleUncheckOptions = { @@ -3471,7 +3409,6 @@ export type ElementHandleUncheckOptions = { export type ElementHandleUncheckResult = void; export type ElementHandleWaitForElementStateParams = { state: 'visible' | 'hidden' | 'stable' | 'enabled' | 'disabled' | 'editable', - timeout: number, }; export type ElementHandleWaitForElementStateOptions = { @@ -3480,7 +3417,6 @@ export type ElementHandleWaitForElementStateResult = void; export type ElementHandleWaitForSelectorParams = { selector: string, strict?: boolean, - timeout: number, state?: 'attached' | 'detached' | 'visible' | 'hidden', }; export type ElementHandleWaitForSelectorOptions = { @@ -3519,16 +3455,16 @@ export interface LocalUtilsEventTarget { } export interface LocalUtilsChannel extends LocalUtilsEventTarget, Channel { _type_LocalUtils: boolean; - zip(params: LocalUtilsZipParams, signal: AbortSignal | undefined): Promise; - harOpen(params: LocalUtilsHarOpenParams, signal: AbortSignal | undefined): Promise; - harLookup(params: LocalUtilsHarLookupParams, signal: AbortSignal | undefined): Promise; - harClose(params: LocalUtilsHarCloseParams, signal: AbortSignal | undefined): Promise; - harUnzip(params: LocalUtilsHarUnzipParams, signal: AbortSignal | undefined): Promise; - connect(params: LocalUtilsConnectParams, signal: AbortSignal | undefined): Promise; - tracingStarted(params: LocalUtilsTracingStartedParams, signal: AbortSignal | undefined): Promise; - addStackToTracingNoReply(params: LocalUtilsAddStackToTracingNoReplyParams, signal: AbortSignal | undefined): Promise; - traceDiscarded(params: LocalUtilsTraceDiscardedParams, signal: AbortSignal | undefined): Promise; - globToRegex(params: LocalUtilsGlobToRegexParams, signal: AbortSignal | undefined): Promise; + zip(params: LocalUtilsZipParams, options: CommandOptions): Promise; + harOpen(params: LocalUtilsHarOpenParams, options: CommandOptions): Promise; + harLookup(params: LocalUtilsHarLookupParams, options: CommandOptions): Promise; + harClose(params: LocalUtilsHarCloseParams, options: CommandOptions): Promise; + harUnzip(params: LocalUtilsHarUnzipParams, options: CommandOptions): Promise; + connect(params: LocalUtilsConnectParams, options: CommandOptions): Promise; + tracingStarted(params: LocalUtilsTracingStartedParams, options: CommandOptions): Promise; + addStackToTracingNoReply(params: LocalUtilsAddStackToTracingNoReplyParams, options: CommandOptions): Promise; + traceDiscarded(params: LocalUtilsTraceDiscardedParams, options: CommandOptions): Promise; + globToRegex(params: LocalUtilsGlobToRegexParams, options: CommandOptions): Promise; } export type LocalUtilsZipParams = { zipFile: string, @@ -3593,7 +3529,6 @@ export type LocalUtilsConnectParams = { headers?: any, exposeNetwork?: string, slowMo?: number, - timeout: number, socksProxyRedirectPortForTest?: number, }; export type LocalUtilsConnectOptions = { @@ -3664,8 +3599,8 @@ export interface RequestEventTarget { } export interface RequestChannel extends RequestEventTarget, Channel { _type_Request: boolean; - response(params: RequestResponseParams, signal: AbortSignal | undefined): Promise; - rawRequestHeaders(params: RequestRawRequestHeadersParams, signal: AbortSignal | undefined): Promise; + response(params: RequestResponseParams, options: CommandOptions): Promise; + rawRequestHeaders(params: RequestRawRequestHeadersParams, options: CommandOptions): Promise; } export type RequestResponseParams = {}; export type RequestResponseOptions = {}; @@ -3689,10 +3624,10 @@ export interface RouteEventTarget { } export interface RouteChannel extends RouteEventTarget, Channel { _type_Route: boolean; - redirectNavigationRequest(params: RouteRedirectNavigationRequestParams, signal: AbortSignal | undefined): Promise; - abort(params: RouteAbortParams, signal: AbortSignal | undefined): Promise; - continue(params: RouteContinueParams, signal: AbortSignal | undefined): Promise; - fulfill(params: RouteFulfillParams, signal: AbortSignal | undefined): Promise; + redirectNavigationRequest(params: RouteRedirectNavigationRequestParams, options: CommandOptions): Promise; + abort(params: RouteAbortParams, options: CommandOptions): Promise; + continue(params: RouteContinueParams, options: CommandOptions): Promise; + fulfill(params: RouteFulfillParams, options: CommandOptions): Promise; } export type RouteRedirectNavigationRequestParams = { url: string, @@ -3754,12 +3689,12 @@ export interface WebSocketRouteEventTarget { } export interface WebSocketRouteChannel extends WebSocketRouteEventTarget, Channel { _type_WebSocketRoute: boolean; - connect(params: WebSocketRouteConnectParams, signal: AbortSignal | undefined): Promise; - ensureOpened(params: WebSocketRouteEnsureOpenedParams, signal: AbortSignal | undefined): Promise; - sendToPage(params: WebSocketRouteSendToPageParams, signal: AbortSignal | undefined): Promise; - sendToServer(params: WebSocketRouteSendToServerParams, signal: AbortSignal | undefined): Promise; - closePage(params: WebSocketRouteClosePageParams, signal: AbortSignal | undefined): Promise; - closeServer(params: WebSocketRouteCloseServerParams, signal: AbortSignal | undefined): Promise; + connect(params: WebSocketRouteConnectParams, options: CommandOptions): Promise; + ensureOpened(params: WebSocketRouteEnsureOpenedParams, options: CommandOptions): Promise; + sendToPage(params: WebSocketRouteSendToPageParams, options: CommandOptions): Promise; + sendToServer(params: WebSocketRouteSendToServerParams, options: CommandOptions): Promise; + closePage(params: WebSocketRouteClosePageParams, options: CommandOptions): Promise; + closeServer(params: WebSocketRouteCloseServerParams, options: CommandOptions): Promise; } export type WebSocketRouteMessageFromPageEvent = { message: string, @@ -3843,12 +3778,12 @@ export interface ResponseEventTarget { } export interface ResponseChannel extends ResponseEventTarget, Channel { _type_Response: boolean; - body(params: ResponseBodyParams, signal: AbortSignal | undefined): Promise; - securityDetails(params: ResponseSecurityDetailsParams, signal: AbortSignal | undefined): Promise; - serverAddr(params: ResponseServerAddrParams, signal: AbortSignal | undefined): Promise; - rawResponseHeaders(params: ResponseRawResponseHeadersParams, signal: AbortSignal | undefined): Promise; - httpVersion(params: ResponseHttpVersionParams, signal: AbortSignal | undefined): Promise; - sizes(params: ResponseSizesParams, signal: AbortSignal | undefined): Promise; + body(params: ResponseBodyParams, options: CommandOptions): Promise; + securityDetails(params: ResponseSecurityDetailsParams, options: CommandOptions): Promise; + serverAddr(params: ResponseServerAddrParams, options: CommandOptions): Promise; + rawResponseHeaders(params: ResponseRawResponseHeadersParams, options: CommandOptions): Promise; + httpVersion(params: ResponseHttpVersionParams, options: CommandOptions): Promise; + sizes(params: ResponseSizesParams, options: CommandOptions): Promise; } export type ResponseBodyParams = {}; export type ResponseBodyOptions = {}; @@ -3949,64 +3884,64 @@ export interface PageEventTarget { } export interface PageChannel extends PageEventTarget, Channel { _type_Page: boolean; - addInitScript(params: PageAddInitScriptParams, signal: AbortSignal | undefined): Promise; - close(params: PageCloseParams, signal: AbortSignal | undefined): Promise; - runBeforeUnload(params: PageRunBeforeUnloadParams, signal: AbortSignal | undefined): Promise; - clearConsoleMessages(params: PageClearConsoleMessagesParams, signal: AbortSignal | undefined): Promise; - consoleMessages(params: PageConsoleMessagesParams, signal: AbortSignal | undefined): Promise; - emulateMedia(params: PageEmulateMediaParams, signal: AbortSignal | undefined): Promise; - exposeBinding(params: PageExposeBindingParams, signal: AbortSignal | undefined): Promise; - goBack(params: PageGoBackParams, signal: AbortSignal | undefined): Promise; - goForward(params: PageGoForwardParams, signal: AbortSignal | undefined): Promise; - requestGC(params: PageRequestGCParams, signal: AbortSignal | undefined): Promise; - registerLocatorHandler(params: PageRegisterLocatorHandlerParams, signal: AbortSignal | undefined): Promise; - resolveLocatorHandlerNoReply(params: PageResolveLocatorHandlerNoReplyParams, signal: AbortSignal | undefined): Promise; - unregisterLocatorHandler(params: PageUnregisterLocatorHandlerParams, signal: AbortSignal | undefined): Promise; - reload(params: PageReloadParams, signal: AbortSignal | undefined): Promise; - expectScreenshot(params: PageExpectScreenshotParams, signal: AbortSignal | undefined): Promise; - screenshot(params: PageScreenshotParams, signal: AbortSignal | undefined): Promise; - setExtraHTTPHeaders(params: PageSetExtraHTTPHeadersParams, signal: AbortSignal | undefined): Promise; - setNetworkInterceptionPatterns(params: PageSetNetworkInterceptionPatternsParams, signal: AbortSignal | undefined): Promise; - setWebSocketInterceptionPatterns(params: PageSetWebSocketInterceptionPatternsParams, signal: AbortSignal | undefined): Promise; - setViewportSize(params: PageSetViewportSizeParams, signal: AbortSignal | undefined): Promise; - keyboardDown(params: PageKeyboardDownParams, signal: AbortSignal | undefined): Promise; - keyboardUp(params: PageKeyboardUpParams, signal: AbortSignal | undefined): Promise; - keyboardInsertText(params: PageKeyboardInsertTextParams, signal: AbortSignal | undefined): Promise; - keyboardType(params: PageKeyboardTypeParams, signal: AbortSignal | undefined): Promise; - keyboardPress(params: PageKeyboardPressParams, signal: AbortSignal | undefined): Promise; - mouseMove(params: PageMouseMoveParams, signal: AbortSignal | undefined): Promise; - mouseDown(params: PageMouseDownParams, signal: AbortSignal | undefined): Promise; - mouseUp(params: PageMouseUpParams, signal: AbortSignal | undefined): Promise; - mouseClick(params: PageMouseClickParams, signal: AbortSignal | undefined): Promise; - mouseWheel(params: PageMouseWheelParams, signal: AbortSignal | undefined): Promise; - touchscreenTap(params: PageTouchscreenTapParams, signal: AbortSignal | undefined): Promise; - clearPageErrors(params: PageClearPageErrorsParams, signal: AbortSignal | undefined): Promise; - pageErrors(params: PagePageErrorsParams, signal: AbortSignal | undefined): Promise; - pdf(params: PagePdfParams, signal: AbortSignal | undefined): Promise; - requests(params: PageRequestsParams, signal: AbortSignal | undefined): Promise; - startJSCoverage(params: PageStartJSCoverageParams, signal: AbortSignal | undefined): Promise; - stopJSCoverage(params: PageStopJSCoverageParams, signal: AbortSignal | undefined): Promise; - startCSSCoverage(params: PageStartCSSCoverageParams, signal: AbortSignal | undefined): Promise; - stopCSSCoverage(params: PageStopCSSCoverageParams, signal: AbortSignal | undefined): Promise; - bringToFront(params: PageBringToFrontParams, signal: AbortSignal | undefined): Promise; - pickLocator(params: PagePickLocatorParams, signal: AbortSignal | undefined): Promise; - cancelPickLocator(params: PageCancelPickLocatorParams, signal: AbortSignal | undefined): Promise; - hideHighlight(params: PageHideHighlightParams, signal: AbortSignal | undefined): Promise; - screencastShowOverlay(params: PageScreencastShowOverlayParams, signal: AbortSignal | undefined): Promise; - screencastRemoveOverlay(params: PageScreencastRemoveOverlayParams, signal: AbortSignal | undefined): Promise; - screencastChapter(params: PageScreencastChapterParams, signal: AbortSignal | undefined): Promise; - screencastSetOverlayVisible(params: PageScreencastSetOverlayVisibleParams, signal: AbortSignal | undefined): Promise; - screencastShowActions(params: PageScreencastShowActionsParams, signal: AbortSignal | undefined): Promise; - screencastHideActions(params: PageScreencastHideActionsParams, signal: AbortSignal | undefined): Promise; - screencastStart(params: PageScreencastStartParams, signal: AbortSignal | undefined): Promise; - screencastStop(params: PageScreencastStopParams, signal: AbortSignal | undefined): Promise; - updateSubscription(params: PageUpdateSubscriptionParams, signal: AbortSignal | undefined): Promise; - setDockTile(params: PageSetDockTileParams, signal: AbortSignal | undefined): Promise; - webStorageItems(params: PageWebStorageItemsParams, signal: AbortSignal | undefined): Promise; - webStorageGetItem(params: PageWebStorageGetItemParams, signal: AbortSignal | undefined): Promise; - webStorageSetItem(params: PageWebStorageSetItemParams, signal: AbortSignal | undefined): Promise; - webStorageRemoveItem(params: PageWebStorageRemoveItemParams, signal: AbortSignal | undefined): Promise; - webStorageClear(params: PageWebStorageClearParams, signal: AbortSignal | undefined): Promise; + addInitScript(params: PageAddInitScriptParams, options: CommandOptions): Promise; + close(params: PageCloseParams, options: CommandOptions): Promise; + runBeforeUnload(params: PageRunBeforeUnloadParams, options: CommandOptions): Promise; + clearConsoleMessages(params: PageClearConsoleMessagesParams, options: CommandOptions): Promise; + consoleMessages(params: PageConsoleMessagesParams, options: CommandOptions): Promise; + emulateMedia(params: PageEmulateMediaParams, options: CommandOptions): Promise; + exposeBinding(params: PageExposeBindingParams, options: CommandOptions): Promise; + goBack(params: PageGoBackParams, options: CommandOptions): Promise; + goForward(params: PageGoForwardParams, options: CommandOptions): Promise; + requestGC(params: PageRequestGCParams, options: CommandOptions): Promise; + registerLocatorHandler(params: PageRegisterLocatorHandlerParams, options: CommandOptions): Promise; + resolveLocatorHandlerNoReply(params: PageResolveLocatorHandlerNoReplyParams, options: CommandOptions): Promise; + unregisterLocatorHandler(params: PageUnregisterLocatorHandlerParams, options: CommandOptions): Promise; + reload(params: PageReloadParams, options: CommandOptions): Promise; + expectScreenshot(params: PageExpectScreenshotParams, options: CommandOptions): Promise; + screenshot(params: PageScreenshotParams, options: CommandOptions): Promise; + setExtraHTTPHeaders(params: PageSetExtraHTTPHeadersParams, options: CommandOptions): Promise; + setNetworkInterceptionPatterns(params: PageSetNetworkInterceptionPatternsParams, options: CommandOptions): Promise; + setWebSocketInterceptionPatterns(params: PageSetWebSocketInterceptionPatternsParams, options: CommandOptions): Promise; + setViewportSize(params: PageSetViewportSizeParams, options: CommandOptions): Promise; + keyboardDown(params: PageKeyboardDownParams, options: CommandOptions): Promise; + keyboardUp(params: PageKeyboardUpParams, options: CommandOptions): Promise; + keyboardInsertText(params: PageKeyboardInsertTextParams, options: CommandOptions): Promise; + keyboardType(params: PageKeyboardTypeParams, options: CommandOptions): Promise; + keyboardPress(params: PageKeyboardPressParams, options: CommandOptions): Promise; + mouseMove(params: PageMouseMoveParams, options: CommandOptions): Promise; + mouseDown(params: PageMouseDownParams, options: CommandOptions): Promise; + mouseUp(params: PageMouseUpParams, options: CommandOptions): Promise; + mouseClick(params: PageMouseClickParams, options: CommandOptions): Promise; + mouseWheel(params: PageMouseWheelParams, options: CommandOptions): Promise; + touchscreenTap(params: PageTouchscreenTapParams, options: CommandOptions): Promise; + clearPageErrors(params: PageClearPageErrorsParams, options: CommandOptions): Promise; + pageErrors(params: PagePageErrorsParams, options: CommandOptions): Promise; + pdf(params: PagePdfParams, options: CommandOptions): Promise; + requests(params: PageRequestsParams, options: CommandOptions): Promise; + startJSCoverage(params: PageStartJSCoverageParams, options: CommandOptions): Promise; + stopJSCoverage(params: PageStopJSCoverageParams, options: CommandOptions): Promise; + startCSSCoverage(params: PageStartCSSCoverageParams, options: CommandOptions): Promise; + stopCSSCoverage(params: PageStopCSSCoverageParams, options: CommandOptions): Promise; + bringToFront(params: PageBringToFrontParams, options: CommandOptions): Promise; + pickLocator(params: PagePickLocatorParams, options: CommandOptions): Promise; + cancelPickLocator(params: PageCancelPickLocatorParams, options: CommandOptions): Promise; + hideHighlight(params: PageHideHighlightParams, options: CommandOptions): Promise; + screencastShowOverlay(params: PageScreencastShowOverlayParams, options: CommandOptions): Promise; + screencastRemoveOverlay(params: PageScreencastRemoveOverlayParams, options: CommandOptions): Promise; + screencastChapter(params: PageScreencastChapterParams, options: CommandOptions): Promise; + screencastSetOverlayVisible(params: PageScreencastSetOverlayVisibleParams, options: CommandOptions): Promise; + screencastShowActions(params: PageScreencastShowActionsParams, options: CommandOptions): Promise; + screencastHideActions(params: PageScreencastHideActionsParams, options: CommandOptions): Promise; + screencastStart(params: PageScreencastStartParams, options: CommandOptions): Promise; + screencastStop(params: PageScreencastStopParams, options: CommandOptions): Promise; + updateSubscription(params: PageUpdateSubscriptionParams, options: CommandOptions): Promise; + setDockTile(params: PageSetDockTileParams, options: CommandOptions): Promise; + webStorageItems(params: PageWebStorageItemsParams, options: CommandOptions): Promise; + webStorageGetItem(params: PageWebStorageGetItemParams, options: CommandOptions): Promise; + webStorageSetItem(params: PageWebStorageSetItemParams, options: CommandOptions): Promise; + webStorageRemoveItem(params: PageWebStorageRemoveItemParams, options: CommandOptions): Promise; + webStorageClear(params: PageWebStorageClearParams, options: CommandOptions): Promise; } export type PageBindingCallEvent = { binding: BindingCallChannel, @@ -4121,7 +4056,6 @@ export type PageExposeBindingResult = { disposable: DisposableChannel, }; export type PageGoBackParams = { - timeout: number, waitUntil?: LifecycleEvent, }; export type PageGoBackOptions = { @@ -4131,7 +4065,6 @@ export type PageGoBackResult = { response?: ResponseChannel, }; export type PageGoForwardParams = { - timeout: number, waitUntil?: LifecycleEvent, }; export type PageGoForwardOptions = { @@ -4169,7 +4102,6 @@ export type PageUnregisterLocatorHandlerOptions = { }; export type PageUnregisterLocatorHandlerResult = void; export type PageReloadParams = { - timeout: number, waitUntil?: LifecycleEvent, }; export type PageReloadOptions = { @@ -4180,7 +4112,6 @@ export type PageReloadResult = { }; export type PageExpectScreenshotParams = { expected?: Binary, - timeout: number, isNot: boolean, locator?: { frame: FrameChannel, @@ -4240,7 +4171,6 @@ export type PageExpectScreenshotErrorDetails = { log?: string[], }; export type PageScreenshotParams = { - timeout: number, type?: 'png' | 'jpeg' | 'webp', quality?: number, fullPage?: boolean, @@ -4687,7 +4617,7 @@ export interface RootEventTarget { } export interface RootChannel extends RootEventTarget, Channel { _type_Root: boolean; - initialize(params: RootInitializeParams, signal: AbortSignal | undefined): Promise; + initialize(params: RootInitializeParams, options: CommandOptions): Promise; } export type RootInitializeParams = { sdkLanguage: SDKLanguage, @@ -4718,7 +4648,7 @@ export interface PlaywrightEventTarget { } export interface PlaywrightChannel extends PlaywrightEventTarget, Channel { _type_Playwright: boolean; - newRequest(params: PlaywrightNewRequestParams, signal: AbortSignal | undefined): Promise; + newRequest(params: PlaywrightNewRequestParams, options: CommandOptions): Promise; } export type PlaywrightNewRequestParams = { baseURL?: string, @@ -4802,13 +4732,13 @@ export interface DebugControllerEventTarget { } export interface DebugControllerChannel extends DebugControllerEventTarget, Channel { _type_DebugController: boolean; - initialize(params: DebugControllerInitializeParams, signal: AbortSignal | undefined): Promise; - setReportStateChanged(params: DebugControllerSetReportStateChangedParams, signal: AbortSignal | undefined): Promise; - setRecorderMode(params: DebugControllerSetRecorderModeParams, signal: AbortSignal | undefined): Promise; - highlight(params: DebugControllerHighlightParams, signal: AbortSignal | undefined): Promise; - hideHighlight(params: DebugControllerHideHighlightParams, signal: AbortSignal | undefined): Promise; - resume(params: DebugControllerResumeParams, signal: AbortSignal | undefined): Promise; - kill(params: DebugControllerKillParams, signal: AbortSignal | undefined): Promise; + initialize(params: DebugControllerInitializeParams, options: CommandOptions): Promise; + setReportStateChanged(params: DebugControllerSetReportStateChangedParams, options: CommandOptions): Promise; + setRecorderMode(params: DebugControllerSetRecorderModeParams, options: CommandOptions): Promise; + highlight(params: DebugControllerHighlightParams, options: CommandOptions): Promise; + hideHighlight(params: DebugControllerHideHighlightParams, options: CommandOptions): Promise; + resume(params: DebugControllerResumeParams, options: CommandOptions): Promise; + kill(params: DebugControllerKillParams, options: CommandOptions): Promise; } export type DebugControllerInspectRequestedEvent = { selector: string, @@ -4891,11 +4821,11 @@ export interface SocksSupportEventTarget { } export interface SocksSupportChannel extends SocksSupportEventTarget, Channel { _type_SocksSupport: boolean; - socksConnected(params: SocksSupportSocksConnectedParams, signal: AbortSignal | undefined): Promise; - socksFailed(params: SocksSupportSocksFailedParams, signal: AbortSignal | undefined): Promise; - socksData(params: SocksSupportSocksDataParams, signal: AbortSignal | undefined): Promise; - socksError(params: SocksSupportSocksErrorParams, signal: AbortSignal | undefined): Promise; - socksEnd(params: SocksSupportSocksEndParams, signal: AbortSignal | undefined): Promise; + socksConnected(params: SocksSupportSocksConnectedParams, options: CommandOptions): Promise; + socksFailed(params: SocksSupportSocksFailedParams, options: CommandOptions): Promise; + socksData(params: SocksSupportSocksDataParams, options: CommandOptions): Promise; + socksError(params: SocksSupportSocksErrorParams, options: CommandOptions): Promise; + socksEnd(params: SocksSupportSocksEndParams, options: CommandOptions): Promise; } export type SocksSupportSocksRequestedEvent = { uid: string, @@ -4964,8 +4894,8 @@ export interface JsonPipeEventTarget { } export interface JsonPipeChannel extends JsonPipeEventTarget, Channel { _type_JsonPipe: boolean; - send(params: JsonPipeSendParams, signal: AbortSignal | undefined): Promise; - close(params: JsonPipeCloseParams, signal: AbortSignal | undefined): Promise; + send(params: JsonPipeSendParams, options: CommandOptions): Promise; + close(params: JsonPipeCloseParams, options: CommandOptions): Promise; } export type JsonPipeMessageEvent = { message: any, @@ -4997,8 +4927,8 @@ export interface CDPSessionEventTarget { } export interface CDPSessionChannel extends CDPSessionEventTarget, Channel { _type_CDPSession: boolean; - send(params: CDPSessionSendParams, signal: AbortSignal | undefined): Promise; - detach(params: CDPSessionDetachParams, signal: AbortSignal | undefined): Promise; + send(params: CDPSessionSendParams, options: CommandOptions): Promise; + detach(params: CDPSessionDetachParams, options: CommandOptions): Promise; } export type CDPSessionEventEvent = { method: string, @@ -5034,8 +4964,8 @@ export interface BindingCallEventTarget { } export interface BindingCallChannel extends BindingCallEventTarget, Channel { _type_BindingCall: boolean; - reject(params: BindingCallRejectParams, signal: AbortSignal | undefined): Promise; - resolve(params: BindingCallResolveParams, signal: AbortSignal | undefined): Promise; + reject(params: BindingCallRejectParams, options: CommandOptions): Promise; + resolve(params: BindingCallResolveParams, options: CommandOptions): Promise; } export type BindingCallRejectParams = { error: SerializedError, @@ -5062,10 +4992,10 @@ export interface DebuggerEventTarget { } export interface DebuggerChannel extends DebuggerEventTarget, Channel { _type_Debugger: boolean; - requestPause(params: DebuggerRequestPauseParams, signal: AbortSignal | undefined): Promise; - resume(params: DebuggerResumeParams, signal: AbortSignal | undefined): Promise; - next(params: DebuggerNextParams, signal: AbortSignal | undefined): Promise; - runTo(params: DebuggerRunToParams, signal: AbortSignal | undefined): Promise; + requestPause(params: DebuggerRequestPauseParams, options: CommandOptions): Promise; + resume(params: DebuggerResumeParams, options: CommandOptions): Promise; + next(params: DebuggerNextParams, options: CommandOptions): Promise; + runTo(params: DebuggerRunToParams, options: CommandOptions): Promise; } export type DebuggerPausedStateChangedEvent = { pausedDetails?: { @@ -5114,8 +5044,8 @@ export interface DialogEventTarget { } export interface DialogChannel extends DialogEventTarget, Channel { _type_Dialog: boolean; - accept(params: DialogAcceptParams, signal: AbortSignal | undefined): Promise; - dismiss(params: DialogDismissParams, signal: AbortSignal | undefined): Promise; + accept(params: DialogAcceptParams, options: CommandOptions): Promise; + dismiss(params: DialogDismissParams, options: CommandOptions): Promise; } export type DialogAcceptParams = { promptText?: string, @@ -5137,14 +5067,14 @@ export interface TracingEventTarget { } export interface TracingChannel extends TracingEventTarget, Channel { _type_Tracing: boolean; - tracingStart(params: TracingTracingStartParams, signal: AbortSignal | undefined): Promise; - tracingStartChunk(params: TracingTracingStartChunkParams, signal: AbortSignal | undefined): Promise; - tracingGroup(params: TracingTracingGroupParams, signal: AbortSignal | undefined): Promise; - tracingGroupEnd(params: TracingTracingGroupEndParams, signal: AbortSignal | undefined): Promise; - tracingStopChunk(params: TracingTracingStopChunkParams, signal: AbortSignal | undefined): Promise; - tracingStop(params: TracingTracingStopParams, signal: AbortSignal | undefined): Promise; - harStart(params: TracingHarStartParams, signal: AbortSignal | undefined): Promise; - harExport(params: TracingHarExportParams, signal: AbortSignal | undefined): Promise; + tracingStart(params: TracingTracingStartParams, options: CommandOptions): Promise; + tracingStartChunk(params: TracingTracingStartChunkParams, options: CommandOptions): Promise; + tracingGroup(params: TracingTracingGroupParams, options: CommandOptions): Promise; + tracingGroupEnd(params: TracingTracingGroupEndParams, options: CommandOptions): Promise; + tracingStopChunk(params: TracingTracingStopChunkParams, options: CommandOptions): Promise; + tracingStop(params: TracingTracingStopParams, options: CommandOptions): Promise; + harStart(params: TracingHarStartParams, options: CommandOptions): Promise; + harExport(params: TracingHarExportParams, options: CommandOptions): Promise; } export type TracingTracingStartParams = { name?: string, @@ -5237,10 +5167,10 @@ export interface WorkerEventTarget { } export interface WorkerChannel extends WorkerEventTarget, Channel { _type_Worker: boolean; - disconnect(params: WorkerDisconnectParams, signal: AbortSignal | undefined): Promise; - evaluateExpression(params: WorkerEvaluateExpressionParams, signal: AbortSignal | undefined): Promise; - evaluateExpressionHandle(params: WorkerEvaluateExpressionHandleParams, signal: AbortSignal | undefined): Promise; - updateSubscription(params: WorkerUpdateSubscriptionParams, signal: AbortSignal | undefined): Promise; + disconnect(params: WorkerDisconnectParams, options: CommandOptions): Promise; + evaluateExpression(params: WorkerEvaluateExpressionParams, options: CommandOptions): Promise; + evaluateExpressionHandle(params: WorkerEvaluateExpressionHandleParams, options: CommandOptions): Promise; + updateSubscription(params: WorkerUpdateSubscriptionParams, options: CommandOptions): Promise; } export type WorkerConsoleEvent = { type: string, diff --git a/packages/playwright-core/src/client/clock.ts b/packages/playwright-core/src/client/clock.ts index 6fa6074110151..9bb92fec1f8fb 100644 --- a/packages/playwright-core/src/client/clock.ts +++ b/packages/playwright-core/src/client/clock.ts @@ -25,31 +25,31 @@ export class Clock implements api.Clock { } async install(options: { time?: number | string | Date } = { }) { - await this._browserContext._channel.clockInstall({ ...(options.time !== undefined ? parseTime(options.time) : {}) }, undefined); + await this._browserContext._channel.clockInstall({ ...(options.time !== undefined ? parseTime(options.time) : {}) }, { signal: undefined, timeout: 0 }); } async fastForward(ticks: number | string) { - await this._browserContext._channel.clockFastForward({ ...parseTicks(ticks) }, undefined); + await this._browserContext._channel.clockFastForward({ ...parseTicks(ticks) }, { signal: undefined, timeout: 0 }); } async pauseAt(time: number | string | Date) { - await this._browserContext._channel.clockPauseAt({ ...parseTime(time) }, undefined); + await this._browserContext._channel.clockPauseAt({ ...parseTime(time) }, { signal: undefined, timeout: 0 }); } async resume() { - await this._browserContext._channel.clockResume({}, undefined); + await this._browserContext._channel.clockResume({}, { signal: undefined, timeout: 0 }); } async runFor(ticks: number | string) { - await this._browserContext._channel.clockRunFor({ ...parseTicks(ticks) }, undefined); + await this._browserContext._channel.clockRunFor({ ...parseTicks(ticks) }, { signal: undefined, timeout: 0 }); } async setFixedTime(time: string | number | Date) { - await this._browserContext._channel.clockSetFixedTime({ ...parseTime(time) }, undefined); + await this._browserContext._channel.clockSetFixedTime({ ...parseTime(time) }, { signal: undefined, timeout: 0 }); } async setSystemTime(time: string | number | Date) { - await this._browserContext._channel.clockSetSystemTime({ ...parseTime(time) }, undefined); + await this._browserContext._channel.clockSetSystemTime({ ...parseTime(time) }, { signal: undefined, timeout: 0 }); } } diff --git a/packages/playwright-core/src/client/connect.ts b/packages/playwright-core/src/client/connect.ts index 6f06c320f2652..acdaf8f97563a 100644 --- a/packages/playwright-core/src/client/connect.ts +++ b/packages/playwright-core/src/client/connect.ts @@ -34,11 +34,10 @@ export async function connectToBrowser(playwright: Playwright, params: ConnectOp headers, exposeNetwork: params.exposeNetwork, slowMo: params.slowMo, - timeout: params.timeout || 0, }; if ((params as any).__testHookRedirectPortForwarding) connectParams.socksProxyRedirectPortForTest = (params as any).__testHookRedirectPortForwarding; - const connection = await connectToEndpoint(playwright._connection, connectParams); + const connection = await connectToEndpoint(playwright._connection, connectParams, params.timeout || 0); let browser: Browser; connection.on('close', () => { // Emulate all pages, contexts and the browser closing upon disconnect. @@ -74,10 +73,10 @@ export async function connectToBrowser(playwright: Playwright, params: ConnectOp } } -export async function connectToEndpoint(parentConnection: Connection, params: channels.LocalUtilsConnectParams): Promise { +export async function connectToEndpoint(parentConnection: Connection, params: channels.LocalUtilsConnectParams, timeout: number): Promise { const localUtils = parentConnection.localUtils(); const transport = localUtils ? new JsonPipeTransport(localUtils) : new WebSocketTransport(); - const connectHeaders = await transport.connect(params); + const connectHeaders = await transport.connect(params, timeout); const connection = new Connection(localUtils, parentConnection._instrumentation, connectHeaders); connection.markAsRemote(); connection.on('close', () => transport.close()); @@ -100,7 +99,7 @@ export async function connectToEndpoint(parentConnection: Connection, params: ch } interface Transport { - connect(params: channels.LocalUtilsConnectParams): Promise; + connect(params: channels.LocalUtilsConnectParams, timeout: number): Promise; send(message: any): Promise; onMessage(callback: (message: object) => void): void; onClose(callback: (reason?: string) => void): void; @@ -115,14 +114,14 @@ class JsonPipeTransport implements Transport { this._owner = owner; } - async connect(params: channels.LocalUtilsConnectParams) { - const { pipe, headers: connectHeaders } = await this._owner._channel.connect(params, undefined); + async connect(params: channels.LocalUtilsConnectParams, timeout: number) { + const { pipe, headers: connectHeaders } = await this._owner._channel.connect(params, { signal: undefined, timeout }); this._pipe = pipe; return connectHeaders; } async send(message: object) { - await this._pipe!.send({ message }, undefined); + await this._pipe!.send({ message }, { signal: undefined, timeout: 0 }); } onMessage(callback: (message: object) => void) { @@ -134,14 +133,14 @@ class JsonPipeTransport implements Transport { } async close() { - await this._pipe!.close({}, undefined).catch(() => {}); + await this._pipe!.close({}, { signal: undefined, timeout: 0 }).catch(() => {}); } } class WebSocketTransport implements Transport { private _ws: WebSocket | undefined; - async connect(params: channels.LocalUtilsConnectParams) { + async connect(params: channels.LocalUtilsConnectParams, timeout: number) { this._ws = new window.WebSocket(params.endpoint); return []; } diff --git a/packages/playwright-core/src/client/connection.ts b/packages/playwright-core/src/client/connection.ts index db9de249a081c..759cabdd27cab 100644 --- a/packages/playwright-core/src/client/connection.ts +++ b/packages/playwright-core/src/client/connection.ts @@ -60,7 +60,7 @@ class Root extends ChannelOwner { async initialize(): Promise { return Playwright.from((await this._channel.initialize({ sdkLanguage: 'javascript', - }, undefined)).playwright); + }, { signal: undefined, timeout: 0 })).playwright); } } @@ -174,7 +174,7 @@ export class Connection extends EventEmitter { this._tracingCount--; } - async sendMessageToServer(object: ChannelOwner, method: string, params: any, options: { apiName?: string, title?: string, internal?: boolean, frames?: channels.StackFrame[], stepId?: string, signal?: AbortSignal }): Promise { + async sendMessageToServer(object: ChannelOwner, method: string, params: any, options: { apiName?: string, title?: string, internal?: boolean, frames?: channels.StackFrame[], stepId?: string, signal?: AbortSignal, timeout: number }): Promise { // Fire-and-forget: server intentionally never replies to __waitInfo__, // so silently drop it after the connection is closed or the object was collected. if (method === '__waitInfo__' && (this._closedError || object._wasCollected)) @@ -197,7 +197,7 @@ export class Connection extends EventEmitter { debugLogger.log('channel', 'SEND> ' + JSON.stringify(message)); } const location = options.frames?.[0] ? { file: options.frames[0].file, line: options.frames[0].line, column: options.frames[0].column } : undefined; - const metadata: channels.Metadata = { title: options.title, location, internal: options.internal, stepId: options.stepId }; + const metadata: channels.Metadata = { title: options.title, location, internal: options.internal, stepId: options.stepId, timeout: options.timeout }; if (this._tracingCount && options.frames && type !== 'LocalUtils') this._localUtils?.addStackToTracingNoReply({ callData: { stack: options.frames ?? [], id } }).catch(() => {}); // We need to exit zones before calling into the server, otherwise diff --git a/packages/playwright-core/src/client/coverage.ts b/packages/playwright-core/src/client/coverage.ts index 0ce0bb2348267..414ba9941b66e 100644 --- a/packages/playwright-core/src/client/coverage.ts +++ b/packages/playwright-core/src/client/coverage.ts @@ -25,18 +25,18 @@ export class Coverage implements api.Coverage { } async startJSCoverage(options: channels.PageStartJSCoverageOptions = {}) { - await this._channel.startJSCoverage(options, undefined); + await this._channel.startJSCoverage(options, { signal: undefined, timeout: 0 }); } async stopJSCoverage(): Promise { - return (await this._channel.stopJSCoverage({}, undefined)).entries; + return (await this._channel.stopJSCoverage({}, { signal: undefined, timeout: 0 })).entries; } async startCSSCoverage(options: channels.PageStartCSSCoverageOptions = {}) { - await this._channel.startCSSCoverage(options, undefined); + await this._channel.startCSSCoverage(options, { signal: undefined, timeout: 0 }); } async stopCSSCoverage(): Promise { - return (await this._channel.stopCSSCoverage({}, undefined)).entries; + return (await this._channel.stopCSSCoverage({}, { signal: undefined, timeout: 0 })).entries; } } diff --git a/packages/playwright-core/src/client/credentials.ts b/packages/playwright-core/src/client/credentials.ts index e46c36bdba3f4..cdb574e745d35 100644 --- a/packages/playwright-core/src/client/credentials.ts +++ b/packages/playwright-core/src/client/credentials.ts @@ -26,20 +26,20 @@ export class Credentials implements api.Credentials { } async install(): Promise { - await this._browserContext._channel.credentialsInstall({}, undefined); + await this._browserContext._channel.credentialsInstall({}, { signal: undefined, timeout: 0 }); } async create(rpId: string, options: Omit = {}): Promise { - const { credential } = await this._browserContext._channel.credentialsCreate({ ...options, rpId }, undefined); + const { credential } = await this._browserContext._channel.credentialsCreate({ ...options, rpId }, { signal: undefined, timeout: 0 }); return credential; } async get(options: channels.BrowserContextCredentialsGetParams = {}): Promise { - const { credentials } = await this._browserContext._channel.credentialsGet(options, undefined); + const { credentials } = await this._browserContext._channel.credentialsGet(options, { signal: undefined, timeout: 0 }); return credentials; } async delete(id: string): Promise { - await this._browserContext._channel.credentialsDelete({ id }, undefined); + await this._browserContext._channel.credentialsDelete({ id }, { signal: undefined, timeout: 0 }); } } diff --git a/packages/playwright-core/src/client/debugger.ts b/packages/playwright-core/src/client/debugger.ts index c61d7e6cbc353..194a4b3774973 100644 --- a/packages/playwright-core/src/client/debugger.ts +++ b/packages/playwright-core/src/client/debugger.ts @@ -38,19 +38,19 @@ export class Debugger extends ChannelOwner implements } async requestPause(): Promise { - await this._channel.requestPause({}, undefined); + await this._channel.requestPause({}, { signal: undefined, timeout: 0 }); } async resume(): Promise { - await this._channel.resume({}, undefined); + await this._channel.resume({}, { signal: undefined, timeout: 0 }); } async next(): Promise { - await this._channel.next({}, undefined); + await this._channel.next({}, { signal: undefined, timeout: 0 }); } async runTo(location: { file: string, line?: number, column?: number }): Promise { - await this._channel.runTo({ location }, undefined); + await this._channel.runTo({ location }, { signal: undefined, timeout: 0 }); } pausedDetails(): PausedDetails | null { diff --git a/packages/playwright-core/src/client/dialog.ts b/packages/playwright-core/src/client/dialog.ts index d169a46b6aa1d..9030f92f44ccd 100644 --- a/packages/playwright-core/src/client/dialog.ts +++ b/packages/playwright-core/src/client/dialog.ts @@ -53,12 +53,12 @@ export class Dialog extends ChannelOwner implements api. } async accept(promptText: string | undefined) { - await this._channel.accept({ promptText }, undefined); + await this._channel.accept({ promptText }, { signal: undefined, timeout: 0 }); } async dismiss() { try { - await this._channel.dismiss({}, undefined); + await this._channel.dismiss({}, { signal: undefined, timeout: 0 }); } catch (e) { if (isTargetClosedError(e)) return; diff --git a/packages/playwright-core/src/client/disposable.ts b/packages/playwright-core/src/client/disposable.ts index 061de9bc57d30..cecb03ed5f427 100644 --- a/packages/playwright-core/src/client/disposable.ts +++ b/packages/playwright-core/src/client/disposable.ts @@ -34,7 +34,7 @@ export class DisposableObject implements env: options.env ? envObjectToArray(options.env) : undefined, tracesDir: options.tracesDir, artifactsDir: options.artifactsDir, - timeout: new TimeoutSettings().launchTimeout(options), }; - const app = ElectronApplication.from((await this._channel.launch(params, undefined)).electronApplication); + const app = ElectronApplication.from((await this._channel.launch(params, { signal: undefined, timeout: new TimeoutSettings().launchTimeout(options) })).electronApplication); this._playwright.selectors._contextsForSelectors.add(app._context); app.once(Events.ElectronApplication.Close, () => this._playwright.selectors._contextsForSelectors.delete(app._context)); await app._context._initializeHarFromOptions(options.recordHar); @@ -155,17 +154,17 @@ export class ElectronApplication extends ChannelOwner> { - const result = await this._channel.browserWindow({ page: page._channel }, undefined); + const result = await this._channel.browserWindow({ page: page._channel }, { signal: undefined, timeout: 0 }); return JSHandle.from(result.handle); } async evaluate(pageFunction: structs.PageFunctionOn, arg: Arg): Promise { - const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return parseResult(result.value); } async evaluateHandle(pageFunction: structs.PageFunctionOn, arg: Arg): Promise> { - const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return JSHandle.from(result.handle) as any as structs.SmartHandle; } } diff --git a/packages/playwright-core/src/client/elementHandle.ts b/packages/playwright-core/src/client/elementHandle.ts index 8f0a63c7a58b3..60f96b1ed5480 100644 --- a/packages/playwright-core/src/client/elementHandle.ts +++ b/packages/playwright-core/src/client/elementHandle.ts @@ -57,94 +57,94 @@ export class ElementHandle extends JSHandle implements } async ownerFrame(): Promise { - return Frame.fromNullable((await this._elementChannel.ownerFrame({}, undefined)).frame); + return Frame.fromNullable((await this._elementChannel.ownerFrame({}, { signal: undefined, timeout: 0 })).frame); } async contentFrame(): Promise { - return Frame.fromNullable((await this._elementChannel.contentFrame({}, undefined)).frame); + return Frame.fromNullable((await this._elementChannel.contentFrame({}, { signal: undefined, timeout: 0 })).frame); } async getAttribute(name: string): Promise { - const value = (await this._elementChannel.getAttribute({ name }, undefined)).value; + const value = (await this._elementChannel.getAttribute({ name }, { signal: undefined, timeout: 0 })).value; return value === undefined ? null : value; } async inputValue(): Promise { - return (await this._elementChannel.inputValue({}, undefined)).value; + return (await this._elementChannel.inputValue({}, { signal: undefined, timeout: 0 })).value; } async textContent(): Promise { - const value = (await this._elementChannel.textContent({}, undefined)).value; + const value = (await this._elementChannel.textContent({}, { signal: undefined, timeout: 0 })).value; return value === undefined ? null : value; } async innerText(): Promise { - return (await this._elementChannel.innerText({}, undefined)).value; + return (await this._elementChannel.innerText({}, { signal: undefined, timeout: 0 })).value; } async innerHTML(): Promise { - return (await this._elementChannel.innerHTML({}, undefined)).value; + return (await this._elementChannel.innerHTML({}, { signal: undefined, timeout: 0 })).value; } async isChecked(): Promise { - return (await this._elementChannel.isChecked({}, undefined)).value; + return (await this._elementChannel.isChecked({}, { signal: undefined, timeout: 0 })).value; } async isDisabled(): Promise { - return (await this._elementChannel.isDisabled({}, undefined)).value; + return (await this._elementChannel.isDisabled({}, { signal: undefined, timeout: 0 })).value; } async isEditable(): Promise { - return (await this._elementChannel.isEditable({}, undefined)).value; + return (await this._elementChannel.isEditable({}, { signal: undefined, timeout: 0 })).value; } async isEnabled(): Promise { - return (await this._elementChannel.isEnabled({}, undefined)).value; + return (await this._elementChannel.isEnabled({}, { signal: undefined, timeout: 0 })).value; } async isHidden(): Promise { - return (await this._elementChannel.isHidden({}, undefined)).value; + return (await this._elementChannel.isHidden({}, { signal: undefined, timeout: 0 })).value; } async isVisible(): Promise { - return (await this._elementChannel.isVisible({}, undefined)).value; + return (await this._elementChannel.isVisible({}, { signal: undefined, timeout: 0 })).value; } async dispatchEvent(type: string, eventInit: Object = {}) { - await this._elementChannel.dispatchEvent({ type, eventInit: serializeArgument(eventInit) }, undefined); + await this._elementChannel.dispatchEvent({ type, eventInit: serializeArgument(eventInit) }, { signal: undefined, timeout: 0 }); } async scrollIntoViewIfNeeded(options: channels.ElementHandleScrollIntoViewIfNeededOptions & TimeoutOptions = {}) { - await this._elementChannel.scrollIntoViewIfNeeded({ ...options, timeout: this._frame._timeout(options) }, options.signal); + await this._elementChannel.scrollIntoViewIfNeeded({ ...options }, this._frame._timeout(options)); } async hover(options: channels.ElementHandleHoverOptions & TimeoutOptions = {}): Promise { - await this._elementChannel.hover({ ...options, timeout: this._frame._timeout(options) }, options.signal); + await this._elementChannel.hover({ ...options }, this._frame._timeout(options)); } async click(options: channels.ElementHandleClickOptions & TimeoutOptions = {}): Promise { - return await this._elementChannel.click({ ...options, timeout: this._frame._timeout(options) }, options.signal); + return await this._elementChannel.click({ ...options }, this._frame._timeout(options)); } async dblclick(options: channels.ElementHandleDblclickOptions & TimeoutOptions = {}): Promise { - return await this._elementChannel.dblclick({ ...options, timeout: this._frame._timeout(options) }, options.signal); + return await this._elementChannel.dblclick({ ...options }, this._frame._timeout(options)); } async tap(options: channels.ElementHandleTapOptions & TimeoutOptions = {}): Promise { - return await this._elementChannel.tap({ ...options, timeout: this._frame._timeout(options) }, options.signal); + return await this._elementChannel.tap({ ...options }, this._frame._timeout(options)); } async selectOption(values: string | api.ElementHandle | SelectOption | string[] | api.ElementHandle[] | SelectOption[] | null, options: SelectOptionOptions = {}): Promise { - const result = await this._elementChannel.selectOption({ ...convertSelectOptionValues(values), ...options, timeout: this._frame._timeout(options) }, options.signal); + const result = await this._elementChannel.selectOption({ ...convertSelectOptionValues(values), ...options }, this._frame._timeout(options)); return result.values; } async fill(value: string, options: channels.ElementHandleFillOptions & TimeoutOptions = {}): Promise { - return await this._elementChannel.fill({ value, ...options, timeout: this._frame._timeout(options) }, options.signal); + return await this._elementChannel.fill({ value, ...options }, this._frame._timeout(options)); } async selectText(options: channels.ElementHandleSelectTextOptions & TimeoutOptions = {}): Promise { - await this._elementChannel.selectText({ ...options, timeout: this._frame._timeout(options) }, options.signal); + await this._elementChannel.selectText({ ...options }, this._frame._timeout(options)); } async setInputFiles(files: string | FilePayload | string[] | FilePayload[], options: channels.ElementHandleSetInputFilesOptions & TimeoutOptions = {}) { @@ -152,27 +152,27 @@ export class ElementHandle extends JSHandle implements if (!frame) throw new Error('Cannot set input files to detached element'); const converted = await convertInputFiles(files, frame.page().context()); - await this._elementChannel.setInputFiles({ ...converted, ...options, timeout: this._frame._timeout(options) }, options.signal); + await this._elementChannel.setInputFiles({ ...converted, ...options }, this._frame._timeout(options)); } async focus(): Promise { - await this._elementChannel.focus({}, undefined); + await this._elementChannel.focus({}, { signal: undefined, timeout: 0 }); } async type(text: string, options: channels.ElementHandleTypeOptions & TimeoutOptions = {}): Promise { - await this._elementChannel.type({ text, ...options, timeout: this._frame._timeout(options) }, options.signal); + await this._elementChannel.type({ text, ...options }, this._frame._timeout(options)); } async press(key: string, options: channels.ElementHandlePressOptions & TimeoutOptions = {}): Promise { - await this._elementChannel.press({ key, ...options, timeout: this._frame._timeout(options) }, options.signal); + await this._elementChannel.press({ key, ...options }, this._frame._timeout(options)); } async check(options: channels.ElementHandleCheckOptions & TimeoutOptions = {}) { - return await this._elementChannel.check({ ...options, timeout: this._frame._timeout(options) }, options.signal); + return await this._elementChannel.check({ ...options }, this._frame._timeout(options)); } async uncheck(options: channels.ElementHandleUncheckOptions & TimeoutOptions = {}) { - return await this._elementChannel.uncheck({ ...options, timeout: this._frame._timeout(options) }, options.signal); + return await this._elementChannel.uncheck({ ...options }, this._frame._timeout(options)); } async setChecked(checked: boolean, options?: channels.ElementHandleCheckOptions) { @@ -183,13 +183,14 @@ export class ElementHandle extends JSHandle implements } async boundingBox(): Promise { - const value = (await this._elementChannel.boundingBox({}, undefined)).value; + const value = (await this._elementChannel.boundingBox({}, { signal: undefined, timeout: 0 })).value; return value === undefined ? null : value; } async screenshot(options: Omit & TimeoutOptions & { path?: string, mask?: api.Locator[] } = {}): Promise { const mask = options.mask as Locator[] | undefined; - const copy: channels.ElementHandleScreenshotParams = { ...options, mask: undefined, timeout: this._frame._timeout(options) }; + const timeout = this._frame._timeout(options).timeout; + const copy: channels.ElementHandleScreenshotParams = { ...options, mask: undefined }; if (!copy.type) copy.type = determineScreenshotType(options); if (mask) { @@ -198,7 +199,7 @@ export class ElementHandle extends JSHandle implements selector: locator._selector, })); } - const result = await this._elementChannel.screenshot(copy, options.signal); + const result = await this._elementChannel.screenshot(copy, { signal: options.signal, timeout }); if (options.path) { await mkdirIfNeeded(options.path); await fs.promises.writeFile(options.path, result.binary); @@ -207,32 +208,32 @@ export class ElementHandle extends JSHandle implements } async $(selector: string): Promise | null> { - return ElementHandle.fromNullable((await this._elementChannel.querySelector({ selector }, undefined)).element) as ElementHandle | null; + return ElementHandle.fromNullable((await this._elementChannel.querySelector({ selector }, { signal: undefined, timeout: 0 })).element) as ElementHandle | null; } async $$(selector: string): Promise[]> { - const result = await this._elementChannel.querySelectorAll({ selector }, undefined); + const result = await this._elementChannel.querySelectorAll({ selector }, { signal: undefined, timeout: 0 }); return result.elements.map(h => ElementHandle.from(h) as ElementHandle); } async $eval(selector: string, pageFunction: structs.PageFunctionOn, arg?: Arg): Promise { - const result = await this._elementChannel.evalOnSelector({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._elementChannel.evalOnSelector({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return parseResult(result.value); } async $$eval(selector: string, pageFunction: structs.PageFunctionOn, arg?: Arg): Promise { - const result = await this._elementChannel.evalOnSelectorAll({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._elementChannel.evalOnSelectorAll({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return parseResult(result.value); } async waitForElementState(state: 'visible' | 'hidden' | 'stable' | 'enabled' | 'disabled', options: TimeoutOptions = {}): Promise { - return await this._elementChannel.waitForElementState({ state, ...options, timeout: this._frame._timeout(options) }, options.signal); + return await this._elementChannel.waitForElementState({ state, ...options }, this._frame._timeout(options)); } waitForSelector(selector: string, options: channels.ElementHandleWaitForSelectorOptions & TimeoutOptions & { state: 'attached' | 'visible' }): Promise>; waitForSelector(selector: string, options?: channels.ElementHandleWaitForSelectorOptions & TimeoutOptions): Promise | null>; async waitForSelector(selector: string, options: channels.ElementHandleWaitForSelectorOptions & TimeoutOptions = {}): Promise | null> { - const result = await this._elementChannel.waitForSelector({ selector, ...options, timeout: this._frame._timeout(options) }, options.signal); + const result = await this._elementChannel.waitForSelector({ selector, ...options }, this._frame._timeout(options)); return ElementHandle.fromNullable(result.element) as ElementHandle | null; } } @@ -298,7 +299,7 @@ export async function convertInputFiles(files: string | FilePayload | string[] | lastModifiedMs }; })), - }, undefined), { internal: true }); + }, { signal: undefined, timeout: 0 }), { internal: true }); for (let i = 0; i < files.length; i++) { const writable = WritableStream.from(writableStreams[i]); await stream.promises.pipeline(fs.createReadStream(files[i]), writable.stream()); diff --git a/packages/playwright-core/src/client/fetch.ts b/packages/playwright-core/src/client/fetch.ts index 59a729ae636ee..ef06df73bee85 100644 --- a/packages/playwright-core/src/client/fetch.ts +++ b/packages/playwright-core/src/client/fetch.ts @@ -79,7 +79,7 @@ export class APIRequest implements api.APIRequest { storageState, tracesDir: this._playwright._defaultLaunchOptions?.tracesDir, // We do not expose tracesDir in the API, so do not allow options to accidentally override it. clientCertificates: await toClientCertificatesProtocol(options.clientCertificates), - }, options.signal)).request); + }, { signal: options.signal, timeout: 0 })).request); this._contexts.add(context); context._request = this; context._timeoutSettings.setDefaultTimeout(options.timeout ?? this._playwright._defaultContextTimeout); @@ -109,12 +109,16 @@ export class APIRequestContext extends ChannelOwner { this._closeReason = options.reason; await this._instrumentation.runBeforeCloseRequestContext(this); await this.tracing._exportAllHars(); try { - await this._channel.dispose(options, undefined); + await this._channel.dispose(options, { signal: undefined, timeout: 0 }); } catch (e) { if (isTargetClosedError(e)) return; @@ -255,19 +259,18 @@ export class APIRequestContext extends ChannelOwner { - const state = await this._channel.storageState({ indexedDB: options.indexedDB }, undefined); + const state = await this._channel.storageState({ indexedDB: options.indexedDB }, { signal: undefined, timeout: 0 }); if (options.path) { await mkdirIfNeeded(options.path); await fs.promises.writeFile(options.path, JSON.stringify(state, undefined, 2), 'utf8'); @@ -354,7 +357,7 @@ export class APIResponse implements api.APIResponse { async body(): Promise { return await this._request._wrapApiCall(async () => { try { - const result = await this._request._channel.fetchResponseBody({ fetchUid: this._fetchUid() }, undefined); + const result = await this._request._channel.fetchResponseBody({ fetchUid: this._fetchUid() }, { signal: undefined, timeout: 0 }); if (result.binary === undefined) throw new Error('Response has been disposed'); return result.binary; @@ -381,7 +384,7 @@ export class APIResponse implements api.APIResponse { } async dispose(): Promise { - await this._request._channel.disposeAPIResponse({ fetchUid: this._fetchUid() }, undefined); + await this._request._channel.disposeAPIResponse({ fetchUid: this._fetchUid() }, { signal: undefined, timeout: 0 }); } private _inspect() { @@ -394,7 +397,7 @@ export class APIResponse implements api.APIResponse { } async _fetchLog(): Promise { - const { log } = await this._request._channel.fetchLog({ fetchUid: this._fetchUid() }, undefined); + const { log } = await this._request._channel.fetchLog({ fetchUid: this._fetchUid() }, { signal: undefined, timeout: 0 }); return log; } } diff --git a/packages/playwright-core/src/client/frame.ts b/packages/playwright-core/src/client/frame.ts index 31ecc7f73cb2b..ac14e9f9d30fd 100644 --- a/packages/playwright-core/src/client/frame.ts +++ b/packages/playwright-core/src/client/frame.ts @@ -107,19 +107,19 @@ export class Frame extends ChannelOwner implements api.Fr return this._page!; } - _timeout(options?: TimeoutOptions): number { + _timeout(options?: TimeoutOptions): channels.CommandOptions { const timeoutSettings = this._page?._timeoutSettings || new TimeoutSettings(); - return timeoutSettings.timeout(options || {}); + return { signal: options?.signal, timeout: timeoutSettings.timeout(options || {}) }; } - _navigationTimeout(options?: TimeoutOptions): number { + _navigationTimeout(options?: TimeoutOptions): channels.CommandOptions { const timeoutSettings = this._page?._timeoutSettings || new TimeoutSettings(); - return timeoutSettings.navigationTimeout(options || {}); + return { signal: options?.signal, timeout: timeoutSettings.navigationTimeout(options || {}) }; } async goto(url: string, options: channels.FrameGotoOptions & TimeoutOptions = {}): Promise { const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil); - return network.Response.fromNullable((await this._channel.goto({ url, ...options, waitUntil, timeout: this._navigationTimeout(options) }, options.signal)).response); + return network.Response.fromNullable((await this._channel.goto({ url, ...options, waitUntil }, this._navigationTimeout(options))).response); } private _setupNavigationWaiter(options: TimeoutOptions): Waiter { @@ -199,29 +199,29 @@ export class Frame extends ChannelOwner implements api.Fr } async frameElement(): Promise { - return ElementHandle.from((await this._channel.frameElement({}, undefined)).element); + return ElementHandle.from((await this._channel.frameElement({}, { signal: undefined, timeout: 0 })).element); } async evaluateHandle(pageFunction: structs.PageFunction, arg?: Arg): Promise> { assertMaxArguments(arguments.length, 2); - const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return JSHandle.from(result.handle) as any as structs.SmartHandle; } async evaluate(pageFunction: structs.PageFunction, arg?: Arg): Promise { assertMaxArguments(arguments.length, 2); - const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return parseResult(result.value); } async _evaluateExposeUtilityScript(pageFunction: structs.PageFunction, arg?: Arg): Promise { assertMaxArguments(arguments.length, 2); - const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return parseResult(result.value); } async $(selector: string, options?: { strict?: boolean }): Promise | null> { - const result = await this._channel.querySelector({ selector, ...options }, undefined); + const result = await this._channel.querySelector({ selector, ...options }, { signal: undefined, timeout: 0 }); return ElementHandle.fromNullable(result.element) as ElementHandle | null; } @@ -232,42 +232,42 @@ export class Frame extends ChannelOwner implements api.Fr throw new Error('options.visibility is not supported, did you mean options.state?'); if ((options as any).waitFor && (options as any).waitFor !== 'visible') throw new Error('options.waitFor is not supported, did you mean options.state?'); - const result = await this._channel.waitForSelector({ selector, ...options, timeout: this._timeout(options) }, options.signal); + const result = await this._channel.waitForSelector({ selector, ...options }, this._timeout(options)); return ElementHandle.fromNullable(result.element) as ElementHandle | null; } async dispatchEvent(selector: string, type: string, eventInit?: any, options: channels.FrameDispatchEventOptions & TimeoutOptions = {}): Promise { - await this._channel.dispatchEvent({ selector, type, eventInit: serializeArgument(eventInit), ...options, timeout: this._timeout(options) }, options.signal); + await this._channel.dispatchEvent({ selector, type, eventInit: serializeArgument(eventInit), ...options }, this._timeout(options)); } async $eval(selector: string, pageFunction: structs.PageFunctionOn, arg?: Arg): Promise { assertMaxArguments(arguments.length, 3); - const result = await this._channel.evalOnSelector({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._channel.evalOnSelector({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return parseResult(result.value); } async $$eval(selector: string, pageFunction: structs.PageFunctionOn, arg?: Arg): Promise { assertMaxArguments(arguments.length, 3); - const result = await this._channel.evalOnSelectorAll({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._channel.evalOnSelectorAll({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return parseResult(result.value); } async $$(selector: string): Promise[]> { - const result = await this._channel.querySelectorAll({ selector }, undefined); + const result = await this._channel.querySelectorAll({ selector }, { signal: undefined, timeout: 0 }); return result.elements.map(e => ElementHandle.from(e) as ElementHandle); } async _queryCount(selector: string): Promise { - return (await this._channel.queryCount({ selector }, undefined)).value; + return (await this._channel.queryCount({ selector }, { signal: undefined, timeout: 0 })).value; } async content(): Promise { - return (await this._channel.content({}, undefined)).value; + return (await this._channel.content({}, { signal: undefined, timeout: 0 })).value; } async setContent(html: string, options: channels.FrameSetContentOptions & TimeoutOptions = {}): Promise { const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil); - await this._channel.setContent({ html, ...options, waitUntil, timeout: this._navigationTimeout(options) }, options.signal); + await this._channel.setContent({ html, ...options, waitUntil }, this._navigationTimeout(options)); } name(): string { @@ -296,7 +296,7 @@ export class Frame extends ChannelOwner implements api.Fr copy.content = (await fs.promises.readFile(copy.path)).toString(); copy.content = addSourceUrlToScript(copy.content, copy.path); } - return ElementHandle.from((await this._channel.addScriptTag({ ...copy }, undefined)).element); + return ElementHandle.from((await this._channel.addScriptTag({ ...copy }, { signal: undefined, timeout: 0 })).element); } async addStyleTag(options: { url?: string; path?: string; content?: string; } = {}): Promise { @@ -305,19 +305,19 @@ export class Frame extends ChannelOwner implements api.Fr copy.content = (await fs.promises.readFile(copy.path)).toString(); copy.content += '/*# sourceURL=' + copy.path.replace(/\n/g, '') + '*/'; } - return ElementHandle.from((await this._channel.addStyleTag({ ...copy }, undefined)).element); + return ElementHandle.from((await this._channel.addStyleTag({ ...copy }, { signal: undefined, timeout: 0 })).element); } async click(selector: string, options: channels.FrameClickOptions & TimeoutOptions = {}) { - return await this._channel.click({ selector, ...options, timeout: this._timeout(options) }, options.signal); + return await this._channel.click({ selector, ...options }, this._timeout(options)); } async dblclick(selector: string, options: channels.FrameDblclickOptions & TimeoutOptions = {}) { - return await this._channel.dblclick({ selector, ...options, timeout: this._timeout(options) }, options.signal); + return await this._channel.dblclick({ selector, ...options }, this._timeout(options)); } async dragAndDrop(source: string, target: string, options: channels.FrameDragAndDropOptions & TimeoutOptions = {}) { - return await this._channel.dragAndDrop({ source, target, ...options, timeout: this._timeout(options) }, options.signal); + return await this._channel.dragAndDrop({ source, target, ...options }, this._timeout(options)); } async _drop(selector: string, payload: DropPayload, options: Omit & TimeoutOptions = {}) { @@ -334,24 +334,23 @@ export class Frame extends ChannelOwner implements api.Fr ...fileParams, data: dataArray, ...options, - timeout: this._timeout(options), - }, options.signal); + }, this._timeout(options)); } async tap(selector: string, options: channels.FrameTapOptions & TimeoutOptions = {}) { - return await this._channel.tap({ selector, ...options, timeout: this._timeout(options) }, options.signal); + return await this._channel.tap({ selector, ...options }, this._timeout(options)); } async fill(selector: string, value: string, options: channels.FrameFillOptions & TimeoutOptions = {}) { - return await this._channel.fill({ selector, value, ...options, timeout: this._timeout(options) }, options.signal); + return await this._channel.fill({ selector, value, ...options }, this._timeout(options)); } async _highlight(selector: string, style?: string) { - return await this._channel.highlight({ selector, style }, undefined); + return await this._channel.highlight({ selector, style }, { signal: undefined, timeout: 0 }); } async _hideHighlight(selector: string) { - return await this._channel.hideHighlight({ selector }, undefined); + return await this._channel.hideHighlight({ selector }, { signal: undefined, timeout: 0 }); } locator(selector: string, options?: LocatorOptions): Locator { @@ -391,82 +390,82 @@ export class Frame extends ChannelOwner implements api.Fr } async focus(selector: string, options: channels.FrameFocusOptions & TimeoutOptions = {}) { - await this._channel.focus({ selector, ...options, timeout: this._timeout(options) }, options.signal); + await this._channel.focus({ selector, ...options }, this._timeout(options)); } async textContent(selector: string, options: channels.FrameTextContentOptions & TimeoutOptions = {}): Promise { - const value = (await this._channel.textContent({ selector, ...options, timeout: this._timeout(options) }, options.signal)).value; + const value = (await this._channel.textContent({ selector, ...options }, this._timeout(options))).value; return value === undefined ? null : value; } async innerText(selector: string, options: channels.FrameInnerTextOptions & TimeoutOptions = {}): Promise { - return (await this._channel.innerText({ selector, ...options, timeout: this._timeout(options) }, options.signal)).value; + return (await this._channel.innerText({ selector, ...options }, this._timeout(options))).value; } async innerHTML(selector: string, options: channels.FrameInnerHTMLOptions & TimeoutOptions = {}): Promise { - return (await this._channel.innerHTML({ selector, ...options, timeout: this._timeout(options) }, options.signal)).value; + return (await this._channel.innerHTML({ selector, ...options }, this._timeout(options))).value; } async getAttribute(selector: string, name: string, options: channels.FrameGetAttributeOptions & TimeoutOptions = {}): Promise { - const value = (await this._channel.getAttribute({ selector, name, ...options, timeout: this._timeout(options) }, options.signal)).value; + const value = (await this._channel.getAttribute({ selector, name, ...options }, this._timeout(options))).value; return value === undefined ? null : value; } async inputValue(selector: string, options: channels.FrameInputValueOptions & TimeoutOptions = {}): Promise { - return (await this._channel.inputValue({ selector, ...options, timeout: this._timeout(options) }, options.signal)).value; + return (await this._channel.inputValue({ selector, ...options }, this._timeout(options))).value; } async isChecked(selector: string, options: channels.FrameIsCheckedOptions & TimeoutOptions = {}): Promise { - return (await this._channel.isChecked({ selector, ...options, timeout: this._timeout(options) }, options.signal)).value; + return (await this._channel.isChecked({ selector, ...options }, this._timeout(options))).value; } async isDisabled(selector: string, options: channels.FrameIsDisabledOptions & TimeoutOptions = {}): Promise { - return (await this._channel.isDisabled({ selector, ...options, timeout: this._timeout(options) }, options.signal)).value; + return (await this._channel.isDisabled({ selector, ...options }, this._timeout(options))).value; } async isEditable(selector: string, options: channels.FrameIsEditableOptions & TimeoutOptions = {}): Promise { - return (await this._channel.isEditable({ selector, ...options, timeout: this._timeout(options) }, options.signal)).value; + return (await this._channel.isEditable({ selector, ...options }, this._timeout(options))).value; } async isEnabled(selector: string, options: channels.FrameIsEnabledOptions & TimeoutOptions = {}): Promise { - return (await this._channel.isEnabled({ selector, ...options, timeout: this._timeout(options) }, options.signal)).value; + return (await this._channel.isEnabled({ selector, ...options }, this._timeout(options))).value; } async isHidden(selector: string, options: channels.FrameIsHiddenOptions & TimeoutOptions = {}): Promise { - return (await this._channel.isHidden({ selector, ...options }, options.signal)).value; + return (await this._channel.isHidden({ selector, ...options }, { signal: options.signal, timeout: 0 })).value; } async isVisible(selector: string, options: channels.FrameIsVisibleOptions & TimeoutOptions = {}): Promise { - return (await this._channel.isVisible({ selector, ...options }, options.signal)).value; + return (await this._channel.isVisible({ selector, ...options }, { signal: options.signal, timeout: 0 })).value; } async hover(selector: string, options: channels.FrameHoverOptions & TimeoutOptions = {}) { - await this._channel.hover({ selector, ...options, timeout: this._timeout(options) }, options.signal); + await this._channel.hover({ selector, ...options }, this._timeout(options)); } async selectOption(selector: string, values: string | api.ElementHandle | SelectOption | string[] | api.ElementHandle[] | SelectOption[] | null, options: SelectOptionOptions & StrictOptions = {}): Promise { - return (await this._channel.selectOption({ selector, ...convertSelectOptionValues(values), ...options, timeout: this._timeout(options) }, options.signal)).values; + return (await this._channel.selectOption({ selector, ...convertSelectOptionValues(values), ...options }, this._timeout(options))).values; } async setInputFiles(selector: string, files: string | FilePayload | string[] | FilePayload[], options: channels.FrameSetInputFilesOptions & TimeoutOptions = {}): Promise { const converted = await convertInputFiles(files, this.page().context()); - await this._channel.setInputFiles({ selector, ...converted, ...options, timeout: this._timeout(options) }, options.signal); + await this._channel.setInputFiles({ selector, ...converted, ...options }, this._timeout(options)); } async type(selector: string, text: string, options: channels.FrameTypeOptions & TimeoutOptions = {}) { - await this._channel.type({ selector, text, ...options, timeout: this._timeout(options) }, options.signal); + await this._channel.type({ selector, text, ...options }, this._timeout(options)); } async press(selector: string, key: string, options: channels.FramePressOptions & TimeoutOptions = {}) { - await this._channel.press({ selector, key, ...options, timeout: this._timeout(options) }, options.signal); + await this._channel.press({ selector, key, ...options }, this._timeout(options)); } async check(selector: string, options: channels.FrameCheckOptions & TimeoutOptions = {}) { - await this._channel.check({ selector, ...options, timeout: this._timeout(options) }, options.signal); + await this._channel.check({ selector, ...options }, this._timeout(options)); } async uncheck(selector: string, options: channels.FrameUncheckOptions & TimeoutOptions = {}) { - await this._channel.uncheck({ selector, ...options, timeout: this._timeout(options) }, options.signal); + await this._channel.uncheck({ selector, ...options }, this._timeout(options)); } async setChecked(selector: string, checked: boolean, options?: channels.FrameCheckOptions) { @@ -477,7 +476,7 @@ export class Frame extends ChannelOwner implements api.Fr } async waitForTimeout(timeout: number) { - await this._channel.waitForTimeout({ waitTimeout: timeout }, undefined); + await this._channel.waitForTimeout({ waitTimeout: timeout }, { signal: undefined, timeout: 0 }); } async waitForFunction(pageFunction: structs.PageFunction, arg?: Arg, options: WaitForFunctionOptions = {}): Promise> { @@ -489,20 +488,20 @@ export class Frame extends ChannelOwner implements api.Fr expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg), - timeout: this._timeout(options), - }, options.signal); + }, this._timeout(options)); return JSHandle.from(result.handle!) as any as structs.SmartHandle; } async title(): Promise { - return (await this._channel.title({}, undefined)).value; + return (await this._channel.title({}, { signal: undefined, timeout: 0 })).value; } - async _expect(expression: string, options: Omit, signal: AbortSignal | undefined): Promise { - const params: channels.FrameExpectParams = { expression, ...options, isNot: !!options.isNot }; - params.expectedValue = serializeArgument(options.expectedValue); + async _expect(expression: string, options: Omit & { timeout: number }, signal: AbortSignal | undefined): Promise { + const { timeout, ...rest } = options; + const params: channels.FrameExpectParams = { expression, ...rest, isNot: !!rest.isNot }; + params.expectedValue = serializeArgument(rest.expectedValue); try { - await this._channel.expect(params, signal); + await this._channel.expect(params, { signal, timeout }); return { matches: !params.isNot }; } catch (e) { if (e instanceof AbortError) diff --git a/packages/playwright-core/src/client/harRouter.ts b/packages/playwright-core/src/client/harRouter.ts index 173da21afb42d..3824d54df073e 100644 --- a/packages/playwright-core/src/client/harRouter.ts +++ b/packages/playwright-core/src/client/harRouter.ts @@ -127,7 +127,7 @@ export class HarRouter { urlRegexSource: isRegExp(urlMatch) ? urlMatch.source : undefined, urlRegexFlags: isRegExp(urlMatch) ? urlMatch.flags : undefined, notFound: this._notFoundAction, - }, undefined); + }, { signal: undefined, timeout: 0 }); this._apiRequestRegistrations.push({ context, registrationId }); } @@ -137,7 +137,7 @@ export class HarRouter { dispose() { for (const { context, registrationId } of this._apiRequestRegistrations) - context._channel.unrouteAPIRequestsFromHar({ registrationId }, undefined).catch(() => {}); + context._channel.unrouteAPIRequestsFromHar({ registrationId }, { signal: undefined, timeout: 0 }).catch(() => {}); this._apiRequestRegistrations = []; this._localUtils.harClose({ harId: this._harId }).catch(() => {}); } diff --git a/packages/playwright-core/src/client/input.ts b/packages/playwright-core/src/client/input.ts index d5c2780b5be77..57be343a65a7f 100644 --- a/packages/playwright-core/src/client/input.ts +++ b/packages/playwright-core/src/client/input.ts @@ -27,23 +27,23 @@ export class Keyboard implements api.Keyboard { } async down(key: string) { - await this._page._channel.keyboardDown({ key }, undefined); + await this._page._channel.keyboardDown({ key }, { signal: undefined, timeout: 0 }); } async up(key: string) { - await this._page._channel.keyboardUp({ key }, undefined); + await this._page._channel.keyboardUp({ key }, { signal: undefined, timeout: 0 }); } async insertText(text: string) { - await this._page._channel.keyboardInsertText({ text }, undefined); + await this._page._channel.keyboardInsertText({ text }, { signal: undefined, timeout: 0 }); } async type(text: string, options: channels.PageKeyboardTypeOptions = {}) { - await this._page._channel.keyboardType({ text, ...options }, undefined); + await this._page._channel.keyboardType({ text, ...options }, { signal: undefined, timeout: 0 }); } async press(key: string, options: channels.PageKeyboardPressOptions = {}) { - await this._page._channel.keyboardPress({ key, ...options }, undefined); + await this._page._channel.keyboardPress({ key, ...options }, { signal: undefined, timeout: 0 }); } } @@ -55,19 +55,19 @@ export class Mouse implements api.Mouse { } async move(x: number, y: number, options: { steps?: number } = {}) { - await this._page._channel.mouseMove({ x, y, ...options }, undefined); + await this._page._channel.mouseMove({ x, y, ...options }, { signal: undefined, timeout: 0 }); } async down(options: channels.PageMouseDownOptions = {}) { - await this._page._channel.mouseDown({ ...options }, undefined); + await this._page._channel.mouseDown({ ...options }, { signal: undefined, timeout: 0 }); } async up(options: channels.PageMouseUpOptions = {}) { - await this._page._channel.mouseUp(options, undefined); + await this._page._channel.mouseUp(options, { signal: undefined, timeout: 0 }); } async click(x: number, y: number, options: channels.PageMouseClickOptions = {}) { - await this._page._channel.mouseClick({ x, y, ...options }, undefined); + await this._page._channel.mouseClick({ x, y, ...options }, { signal: undefined, timeout: 0 }); } async dblclick(x: number, y: number, options: Omit = {}) { @@ -77,7 +77,7 @@ export class Mouse implements api.Mouse { } async wheel(deltaX: number, deltaY: number) { - await this._page._channel.mouseWheel({ deltaX, deltaY }, undefined); + await this._page._channel.mouseWheel({ deltaX, deltaY }, { signal: undefined, timeout: 0 }); } } @@ -89,6 +89,6 @@ export class Touchscreen implements api.Touchscreen { } async tap(x: number, y: number) { - await this._page._channel.touchscreenTap({ x, y }, undefined); + await this._page._channel.touchscreenTap({ x, y }, { signal: undefined, timeout: 0 }); } } diff --git a/packages/playwright-core/src/client/jsHandle.ts b/packages/playwright-core/src/client/jsHandle.ts index 2df73dd2d9e2d..9d9d7c4b63a05 100644 --- a/packages/playwright-core/src/client/jsHandle.ts +++ b/packages/playwright-core/src/client/jsHandle.ts @@ -37,29 +37,29 @@ export class JSHandle extends ChannelOwner im } async evaluate(pageFunction: structs.PageFunctionOn, arg?: Arg): Promise { - const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return parseResult(result.value); } async evaluateHandle(pageFunction: structs.PageFunctionOn, arg?: Arg): Promise> { - const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return JSHandle.from(result.handle) as any as structs.SmartHandle; } async getProperty(propertyName: string): Promise { - const result = await this._channel.getProperty({ name: propertyName }, undefined); + const result = await this._channel.getProperty({ name: propertyName }, { signal: undefined, timeout: 0 }); return JSHandle.from(result.handle); } async getProperties(): Promise> { const map = new Map(); - for (const { name, value } of (await this._channel.getPropertyList({}, undefined)).properties) + for (const { name, value } of (await this._channel.getPropertyList({}, { signal: undefined, timeout: 0 })).properties) map.set(name, JSHandle.from(value)); return map; } async jsonValue(): Promise { - return parseResult((await this._channel.jsonValue({}, undefined)).value); + return parseResult((await this._channel.jsonValue({}, { signal: undefined, timeout: 0 })).value); } asElement(): T extends Node ? api.ElementHandle : null { @@ -72,7 +72,7 @@ export class JSHandle extends ChannelOwner im async dispose() { try { - await this._channel.dispose({}, undefined); + await this._channel.dispose({}, { signal: undefined, timeout: 0 }); } catch (e) { if (isTargetClosedError(e)) return; diff --git a/packages/playwright-core/src/client/localUtils.ts b/packages/playwright-core/src/client/localUtils.ts index f02be30075ff2..903d5f41ac52d 100644 --- a/packages/playwright-core/src/client/localUtils.ts +++ b/packages/playwright-core/src/client/localUtils.ts @@ -40,34 +40,34 @@ export class LocalUtils extends ChannelOwner { } async zip(params: channels.LocalUtilsZipParams): Promise { - return await this._channel.zip(params, undefined); + return await this._channel.zip(params, { signal: undefined, timeout: 0 }); } async harOpen(params: channels.LocalUtilsHarOpenParams): Promise { - return await this._channel.harOpen(params, undefined); + return await this._channel.harOpen(params, { signal: undefined, timeout: 0 }); } async harLookup(params: channels.LocalUtilsHarLookupParams): Promise { - return await this._channel.harLookup(params, undefined); + return await this._channel.harLookup(params, { signal: undefined, timeout: 0 }); } async harClose(params: channels.LocalUtilsHarCloseParams): Promise { - return await this._channel.harClose(params, undefined); + return await this._channel.harClose(params, { signal: undefined, timeout: 0 }); } async harUnzip(params: channels.LocalUtilsHarUnzipParams): Promise { - return await this._channel.harUnzip(params, undefined); + return await this._channel.harUnzip(params, { signal: undefined, timeout: 0 }); } async tracingStarted(params: channels.LocalUtilsTracingStartedParams): Promise { - return await this._channel.tracingStarted(params, undefined); + return await this._channel.tracingStarted(params, { signal: undefined, timeout: 0 }); } async traceDiscarded(params: channels.LocalUtilsTraceDiscardedParams): Promise { - return await this._channel.traceDiscarded(params, undefined); + return await this._channel.traceDiscarded(params, { signal: undefined, timeout: 0 }); } async addStackToTracingNoReply(params: channels.LocalUtilsAddStackToTracingNoReplyParams): Promise { - return await this._channel.addStackToTracingNoReply(params, undefined); + return await this._channel.addStackToTracingNoReply(params, { signal: undefined, timeout: 0 }); } } diff --git a/packages/playwright-core/src/client/locator.ts b/packages/playwright-core/src/client/locator.ts index 99244f2295842..86a60eef0c4a9 100644 --- a/packages/playwright-core/src/client/locator.ts +++ b/packages/playwright-core/src/client/locator.ts @@ -78,11 +78,11 @@ export class Locator implements api.Locator { } private async _withElement(task: (handle: ElementHandle, timeout?: number) => Promise, options: { title: string, internal?: boolean, timeout?: number, signal?: AbortSignal }): Promise { - const timeout = this._frame._timeout({ timeout: options.timeout }); + const timeout = this._frame._timeout({ timeout: options.timeout }).timeout; const deadline = timeout ? monotonicTime() + timeout : 0; return await this._frame._wrapApiCall(async () => { - const result = await this._frame._channel.waitForSelector({ selector: this._selector, strict: true, state: 'attached', timeout }, options.signal); + const result = await this._frame._channel.waitForSelector({ selector: this._selector, strict: true, state: 'attached' }, { signal: options.signal, timeout }); const handle = ElementHandle.fromNullable(result.element) as ElementHandle | null; if (!handle) throw new Error(`Could not resolve ${this._selector} to DOM Element`); @@ -261,7 +261,7 @@ export class Locator implements api.Locator { } async blur(options?: TimeoutOptions): Promise { - await this._frame._channel.blur({ selector: this._selector, strict: true, ...options, timeout: this._frame._timeout(options) }, options?.signal); + await this._frame._channel.blur({ selector: this._selector, strict: true, ...options }, this._frame._timeout(options)); } async count(): Promise { @@ -269,7 +269,7 @@ export class Locator implements api.Locator { } async normalize(): Promise { - const { resolvedSelector } = await this._frame._channel.resolveSelector({ selector: this._selector }, undefined); + const { resolvedSelector } = await this._frame._channel.resolveSelector({ selector: this._selector }, { signal: undefined, timeout: 0 }); return new Locator(this._frame, resolvedSelector); } @@ -327,7 +327,7 @@ export class Locator implements api.Locator { } async ariaSnapshot(options: TimeoutOptions & { mode?: 'ai' | 'default', depth?: number, boxes?: boolean } = {}): Promise { - const result = await this._frame._channel.ariaSnapshot({ timeout: this._frame._timeout(options), mode: options.mode, selector: this._selector, depth: options.depth, boxes: options.boxes }, options.signal); + const result = await this._frame._channel.ariaSnapshot({ mode: options.mode, selector: this._selector, depth: options.depth, boxes: options.boxes }, this._frame._timeout(options)); return result.snapshot; } @@ -389,7 +389,7 @@ export class Locator implements api.Locator { waitFor(options: channels.FrameWaitForSelectorOptions & TimeoutOptions & { state: 'attached' | 'visible' }): Promise; waitFor(options?: channels.FrameWaitForSelectorOptions & TimeoutOptions): Promise; async waitFor(options?: channels.FrameWaitForSelectorOptions & TimeoutOptions): Promise { - await this._frame._channel.waitForSelector({ selector: this._selector, strict: true, omitReturnValue: true, ...options, timeout: this._frame._timeout(options) }, options?.signal); + await this._frame._channel.waitForSelector({ selector: this._selector, strict: true, omitReturnValue: true, ...options }, this._frame._timeout(options)); } async waitForFunction(pageFunction: structs.PageFunctionOn, arg?: Arg, options?: TimeoutOptions): Promise { @@ -399,8 +399,7 @@ export class Locator implements api.Locator { expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg), - timeout: this._frame._timeout(options), - }, options?.signal); + }, this._frame._timeout(options)); } diff --git a/packages/playwright-core/src/client/network.ts b/packages/playwright-core/src/client/network.ts index 7c33d3a8b6f8a..5852b904dd18f 100644 --- a/packages/playwright-core/src/client/network.ts +++ b/packages/playwright-core/src/client/network.ts @@ -179,7 +179,7 @@ export class Request extends ChannelOwner implements ap if (!this._actualHeadersPromise) { this._actualHeadersPromise = this._wrapApiCall(async () => { - return new RawHeaders((await this._channel.rawRequestHeaders({}, undefined)).headers); + return new RawHeaders((await this._channel.rawRequestHeaders({}, { signal: undefined, timeout: 0 })).headers); }, { internal: true }); } return await this._actualHeadersPromise; @@ -198,11 +198,11 @@ export class Request extends ChannelOwner implements ap } async response(): Promise { - return Response.fromNullable((await this._channel.response({}, undefined)).response); + return Response.fromNullable((await this._channel.response({}, { signal: undefined, timeout: 0 })).response); } async _internalResponse(): Promise { - return Response.fromNullable((await this._channel.response({}, undefined)).response); + return Response.fromNullable((await this._channel.response({}, { signal: undefined, timeout: 0 })).response); } existingResponse(): Response | null { @@ -261,7 +261,7 @@ export class Request extends ChannelOwner implements ap const response = await this.response(); if (!response) throw new Error('Unable to fetch sizes for failed request'); - return (await response._channel.sizes({}, undefined)).sizes; + return (await response._channel.sizes({}, { signal: undefined, timeout: 0 })).sizes; } _setResponseEndTiming(responseEndTiming: number) { @@ -336,13 +336,13 @@ export class Route extends ChannelOwner implements api.Ro async abort(errorCode?: string) { await this._handleRoute(async () => { - await this._raceWithTargetClose(this._channel.abort({ errorCode }, undefined)); + await this._raceWithTargetClose(this._channel.abort({ errorCode }, { signal: undefined, timeout: 0 })); }); } async _redirectNavigationRequest(url: string) { await this._handleRoute(async () => { - await this._raceWithTargetClose(this._channel.redirectNavigationRequest({ url }, undefined)); + await this._raceWithTargetClose(this._channel.redirectNavigationRequest({ url }, { signal: undefined, timeout: 0 })); }); } @@ -423,7 +423,7 @@ export class Route extends ChannelOwner implements api.Ro body, isBase64, fetchResponseUid - }, undefined)); + }, { signal: undefined, timeout: 0 })); } async continue(options: FallbackOverrides = {}) { @@ -452,7 +452,7 @@ export class Route extends ChannelOwner implements api.Ro headers: options.headers ? headersObjectToArray(options.headers) : undefined, postData: options.postDataBuffer, isFallback, - }, undefined)); + }, { signal: undefined, timeout: 0 })); } } @@ -493,14 +493,14 @@ export class WebSocketRoute extends ChannelOwner }, close: async (options: { code?: number, reason?: string } = {}) => { - await this._channel.closeServer({ ...options, wasClean: true }, undefined).catch(() => {}); + await this._channel.closeServer({ ...options, wasClean: true }, { signal: undefined, timeout: 0 }).catch(() => {}); }, send: (message: string | Buffer) => { if (isString(message)) - this._channel.sendToServer({ message, isBase64: false }, undefined).catch(() => {}); + this._channel.sendToServer({ message, isBase64: false }, { signal: undefined, timeout: 0 }).catch(() => {}); else - this._channel.sendToServer({ message: message.toString('base64'), isBase64: true }, undefined).catch(() => {}); + this._channel.sendToServer({ message: message.toString('base64'), isBase64: true }, { signal: undefined, timeout: 0 }).catch(() => {}); }, async [Symbol.asyncDispose]() { @@ -512,28 +512,28 @@ export class WebSocketRoute extends ChannelOwner if (this._onPageMessage) this._onPageMessage(isBase64 ? Buffer.from(message, 'base64') : message); else if (this._connected) - this._channel.sendToServer({ message, isBase64 }, undefined).catch(() => {}); + this._channel.sendToServer({ message, isBase64 }, { signal: undefined, timeout: 0 }).catch(() => {}); }); this._channel.on('messageFromServer', ({ message, isBase64 }) => { if (this._onServerMessage) this._onServerMessage(isBase64 ? Buffer.from(message, 'base64') : message); else - this._channel.sendToPage({ message, isBase64 }, undefined).catch(() => {}); + this._channel.sendToPage({ message, isBase64 }, { signal: undefined, timeout: 0 }).catch(() => {}); }); this._channel.on('closePage', ({ code, reason, wasClean }) => { if (this._onPageClose) this._onPageClose(code, reason); else - this._channel.closeServer({ code, reason, wasClean }, undefined).catch(() => {}); + this._channel.closeServer({ code, reason, wasClean }, { signal: undefined, timeout: 0 }).catch(() => {}); }); this._channel.on('closeServer', ({ code, reason, wasClean }) => { if (this._onServerClose) this._onServerClose(code, reason); else - this._channel.closePage({ code, reason, wasClean }, undefined).catch(() => {}); + this._channel.closePage({ code, reason, wasClean }, { signal: undefined, timeout: 0 }).catch(() => {}); }); } @@ -546,22 +546,22 @@ export class WebSocketRoute extends ChannelOwner } async close(options: { code?: number, reason?: string } = {}) { - await this._channel.closePage({ ...options, wasClean: true }, undefined).catch(() => {}); + await this._channel.closePage({ ...options, wasClean: true }, { signal: undefined, timeout: 0 }).catch(() => {}); } connectToServer() { if (this._connected) throw new Error('Already connected to the server'); this._connected = true; - this._channel.connect({}, undefined).catch(() => {}); + this._channel.connect({}, { signal: undefined, timeout: 0 }).catch(() => {}); return this._server; } send(message: string | Buffer) { if (isString(message)) - this._channel.sendToPage({ message, isBase64: false }, undefined).catch(() => {}); + this._channel.sendToPage({ message, isBase64: false }, { signal: undefined, timeout: 0 }).catch(() => {}); else - this._channel.sendToPage({ message: message.toString('base64'), isBase64: true }, undefined).catch(() => {}); + this._channel.sendToPage({ message: message.toString('base64'), isBase64: true }, { signal: undefined, timeout: 0 }).catch(() => {}); } onMessage(handler: (message: string | Buffer) => any) { @@ -581,7 +581,7 @@ export class WebSocketRoute extends ChannelOwner return; // Ensure that websocket is "open" and can send messages without an actual server connection. // If this happens after the page has been closed, ignore the error. - await this._channel.ensureOpened({}, undefined).catch(() => {}); + await this._channel.ensureOpened({}, { signal: undefined, timeout: 0 }).catch(() => {}); } } @@ -701,7 +701,7 @@ export class Response extends ChannelOwner implements async _actualHeaders(): Promise { if (!this._actualHeadersPromise) { this._actualHeadersPromise = (async () => { - return new RawHeaders((await this._channel.rawResponseHeaders({}, undefined)).headers); + return new RawHeaders((await this._channel.rawResponseHeaders({}, { signal: undefined, timeout: 0 })).headers); })(); } return await this._actualHeadersPromise; @@ -728,7 +728,7 @@ export class Response extends ChannelOwner implements } async body(): Promise { - return (await this._channel.body({}, undefined)).binary; + return (await this._channel.body({}, { signal: undefined, timeout: 0 })).binary; } async text(): Promise { @@ -750,15 +750,15 @@ export class Response extends ChannelOwner implements } async serverAddr(): Promise { - return (await this._channel.serverAddr({}, undefined)).value || null; + return (await this._channel.serverAddr({}, { signal: undefined, timeout: 0 })).value || null; } async securityDetails(): Promise { - return (await this._channel.securityDetails({}, undefined)).value || null; + return (await this._channel.securityDetails({}, { signal: undefined, timeout: 0 })).value || null; } async httpVersion(): Promise { - return (await this._channel.httpVersion({}, undefined)).value; + return (await this._channel.httpVersion({}, { signal: undefined, timeout: 0 })).value; } } diff --git a/packages/playwright-core/src/client/page.ts b/packages/playwright-core/src/client/page.ts index 1ee49a01dc88f..ed79452b94314 100644 --- a/packages/playwright-core/src/client/page.ts +++ b/packages/playwright-core/src/client/page.ts @@ -306,16 +306,16 @@ export class Page extends ChannelOwner implements api.Page } async pickLocator(): Promise { - const { selector } = await this._channel.pickLocator({}, undefined); + const { selector } = await this._channel.pickLocator({}, { signal: undefined, timeout: 0 }); return this.locator(selector); } async cancelPickLocator(): Promise { - await this._channel.cancelPickLocator({}, undefined); + await this._channel.cancelPickLocator({}, { signal: undefined, timeout: 0 }); } async hideHighlight(): Promise { - await this._channel.hideHighlight({}, undefined); + await this._channel.hideHighlight({}, { signal: undefined, timeout: 0 }); } async $(selector: string, options?: { strict?: boolean }): Promise | null> { @@ -360,21 +360,21 @@ export class Page extends ChannelOwner implements api.Page } async exposeFunction(name: string, callback: Function) { - const result = await this._channel.exposeBinding({ name }, undefined); + const result = await this._channel.exposeBinding({ name }, { signal: undefined, timeout: 0 }); const binding = (source: structs.BindingSource, ...args: any[]) => callback(...args); this._bindings.set(name, binding); return DisposableObject.from(result.disposable); } async exposeBinding(name: string, callback: (source: structs.BindingSource, ...args: any[]) => any) { - const result = await this._channel.exposeBinding({ name }, undefined); + const result = await this._channel.exposeBinding({ name }, { signal: undefined, timeout: 0 }); this._bindings.set(name, callback); return DisposableObject.from(result.disposable); } async setExtraHTTPHeaders(headers: Headers) { validateHeaders(headers); - await this._channel.setExtraHTTPHeaders({ headers: headersObjectToArray(headers) }, undefined); + await this._channel.setExtraHTTPHeaders({ headers: headersObjectToArray(headers) }, { signal: undefined, timeout: 0 }); } url(): string { @@ -395,7 +395,7 @@ export class Page extends ChannelOwner implements api.Page async reload(options: channels.PageReloadOptions & TimeoutOptions = {}): Promise { const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil); - return Response.fromNullable((await this._channel.reload({ ...options, waitUntil, timeout: this._timeoutSettings.navigationTimeout(options) }, options.signal)).response); + return Response.fromNullable((await this._channel.reload({ ...options, waitUntil }, this._mainFrame._navigationTimeout(options))).response); } async addLocatorHandler(locator: Locator, handler: (locator: Locator) => any, options: { times?: number, noWaitAfter?: boolean } = {}): Promise { @@ -403,7 +403,7 @@ export class Page extends ChannelOwner implements api.Page throw new Error(`Locator must belong to the main frame of this page`); if (options.times === 0) return; - const { uid } = await this._channel.registerLocatorHandler({ selector: locator._selector, noWaitAfter: options.noWaitAfter }, undefined); + const { uid } = await this._channel.registerLocatorHandler({ selector: locator._selector, noWaitAfter: options.noWaitAfter }, { signal: undefined, timeout: 0 }); this._locatorHandlers.set(uid, { locator, handler, times: options.times }); } @@ -420,7 +420,7 @@ export class Page extends ChannelOwner implements api.Page } finally { if (remove) this._locatorHandlers.delete(uid); - this._channel.resolveLocatorHandlerNoReply({ uid, remove }, undefined).catch(() => {}); + this._channel.resolveLocatorHandlerNoReply({ uid, remove }, { signal: undefined, timeout: 0 }).catch(() => {}); } } @@ -428,7 +428,7 @@ export class Page extends ChannelOwner implements api.Page for (const [uid, data] of this._locatorHandlers) { if (data.locator._equals(locator)) { this._locatorHandlers.delete(uid); - await this._channel.unregisterLocatorHandler({ uid }, undefined).catch(() => {}); + await this._channel.unregisterLocatorHandler({ uid }, { signal: undefined, timeout: 0 }).catch(() => {}); } } } @@ -497,16 +497,16 @@ export class Page extends ChannelOwner implements api.Page async goBack(options: channels.PageGoBackOptions & TimeoutOptions = {}): Promise { const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil); - return Response.fromNullable((await this._channel.goBack({ ...options, waitUntil, timeout: this._timeoutSettings.navigationTimeout(options) }, options.signal)).response); + return Response.fromNullable((await this._channel.goBack({ ...options, waitUntil }, this._mainFrame._navigationTimeout(options))).response); } async goForward(options: channels.PageGoForwardOptions & TimeoutOptions = {}): Promise { const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil); - return Response.fromNullable((await this._channel.goForward({ ...options, waitUntil, timeout: this._timeoutSettings.navigationTimeout(options) }, options.signal)).response); + return Response.fromNullable((await this._channel.goForward({ ...options, waitUntil }, this._mainFrame._navigationTimeout(options))).response); } async requestGC() { - await this._channel.requestGC({}, undefined); + await this._channel.requestGC({}, { signal: undefined, timeout: 0 }); } async emulateMedia(options: { media?: 'screen' | 'print' | null, colorScheme?: 'dark' | 'light' | 'no-preference' | null, reducedMotion?: 'reduce' | 'no-preference' | null, forcedColors?: 'active' | 'none' | null, contrast?: 'no-preference' | 'more' | null } = {}) { @@ -516,12 +516,12 @@ export class Page extends ChannelOwner implements api.Page reducedMotion: options.reducedMotion === null ? 'no-override' : options.reducedMotion, forcedColors: options.forcedColors === null ? 'no-override' : options.forcedColors, contrast: options.contrast === null ? 'no-override' : options.contrast, - }, undefined); + }, { signal: undefined, timeout: 0 }); } async setViewportSize(viewportSize: Size) { this._viewportSize = viewportSize; - await this._channel.setViewportSize({ viewportSize }, undefined); + await this._channel.setViewportSize({ viewportSize }, { signal: undefined, timeout: 0 }); } viewportSize(): Size | null { @@ -535,7 +535,7 @@ export class Page extends ChannelOwner implements api.Page async addInitScript(script: Function | string | { path?: string, content?: string }, arg?: any) { const source = await evaluationScript(script, arg); - return DisposableObject.from((await this._channel.addInitScript({ source }, undefined)).disposable); + return DisposableObject.from((await this._channel.addInitScript({ source }, { signal: undefined, timeout: 0 })).disposable); } async route(url: URLMatch, handler: RouteHandlerCallback, options: { times?: number } = {}): Promise { @@ -595,17 +595,18 @@ export class Page extends ChannelOwner implements api.Page private async _updateInterceptionPatterns(options: { internal: true } | { title: string }) { const patterns = RouteHandler.prepareInterceptionPatterns(this._routes); - await this._wrapApiCall(() => this._channel.setNetworkInterceptionPatterns({ patterns }, undefined), options); + await this._wrapApiCall(() => this._channel.setNetworkInterceptionPatterns({ patterns }, { signal: undefined, timeout: 0 }), options); } private async _updateWebSocketInterceptionPatterns(options: { internal: true } | { title: string }) { const patterns = WebSocketRouteHandler.prepareInterceptionPatterns(this._webSocketRoutes); - await this._wrapApiCall(() => this._channel.setWebSocketInterceptionPatterns({ patterns }, undefined), options); + await this._wrapApiCall(() => this._channel.setWebSocketInterceptionPatterns({ patterns }, { signal: undefined, timeout: 0 }), options); } async screenshot(options: Omit & TimeoutOptions & { path?: string, mask?: api.Locator[] } = {}): Promise { const mask = options.mask as Locator[] | undefined; - const copy: channels.PageScreenshotParams = { ...options, mask: undefined, timeout: this._timeoutSettings.timeout(options) }; + const timeout = this._timeoutSettings.timeout(options); + const copy: channels.PageScreenshotParams = { ...options, mask: undefined }; if (!copy.type) copy.type = determineScreenshotType(options); if (mask) { @@ -614,7 +615,7 @@ export class Page extends ChannelOwner implements api.Page selector: locator._selector, })); } - const result = await this._channel.screenshot(copy, options.signal); + const result = await this._channel.screenshot(copy, { signal: options.signal, timeout }); if (options.path) { await mkdirIfNeeded(options.path); await fs.promises.writeFile(options.path, result.binary); @@ -623,6 +624,7 @@ export class Page extends ChannelOwner implements api.Page } async _expectScreenshot(options: ExpectScreenshotOptions): Promise<{ actual?: Buffer, previous?: Buffer, diff?: Buffer, errorMessage?: string, log?: string[], timedOut?: boolean}> { + const { timeout, ...optionsWithoutTimeout } = options; const mask = options?.mask ? options?.mask.map(locator => ({ frame: (locator as Locator)._frame._channel, selector: (locator as Locator)._selector, @@ -633,11 +635,11 @@ export class Page extends ChannelOwner implements api.Page } : undefined; try { const result = await this._channel.expectScreenshot({ - ...options, + ...optionsWithoutTimeout, isNot: !!options.isNot, locator, mask, - }, undefined); + }, { signal: undefined, timeout }); return { actual: result.actual }; } catch (e) { if (!(e instanceof PlaywrightError)) @@ -652,7 +654,7 @@ export class Page extends ChannelOwner implements api.Page } async bringToFront(): Promise { - await this._channel.bringToFront({}, undefined); + await this._channel.bringToFront({}, { signal: undefined, timeout: 0 }); } async [Symbol.asyncDispose]() { @@ -667,9 +669,9 @@ export class Page extends ChannelOwner implements api.Page if (this._ownedContext) await this._ownedContext.close(); else if (options.runBeforeUnload) - await this._channel.runBeforeUnload({}, undefined); + await this._channel.runBeforeUnload({}, { signal: undefined, timeout: 0 }); else - await this._channel.close({ reason: options.reason }, undefined); + await this._channel.close({ reason: options.reason }, { signal: undefined, timeout: 0 }); } catch (e) { if (isTargetClosedError(e) && !options.runBeforeUnload) return; @@ -702,20 +704,20 @@ export class Page extends ChannelOwner implements api.Page } async clearConsoleMessages(): Promise { - await this._channel.clearConsoleMessages({}, undefined); + await this._channel.clearConsoleMessages({}, { signal: undefined, timeout: 0 }); } async consoleMessages(options?: { filter?: 'all' | 'since-navigation' }): Promise { - const { messages } = await this._channel.consoleMessages({ filter: options?.filter }, undefined); + const { messages } = await this._channel.consoleMessages({ filter: options?.filter }, { signal: undefined, timeout: 0 }); return messages.map(message => new ConsoleMessage(message, this, null)); } async clearPageErrors(): Promise { - await this._channel.clearPageErrors({}, undefined); + await this._channel.clearPageErrors({}, { signal: undefined, timeout: 0 }); } async pageErrors(options?: { filter?: 'all' | 'since-navigation' }): Promise { - const { errors } = await this._channel.pageErrors({ filter: options?.filter }, undefined); + const { errors } = await this._channel.pageErrors({ filter: options?.filter }, { signal: undefined, timeout: 0 }); return errors.map(error => parseError(error)); } @@ -844,7 +846,7 @@ export class Page extends ChannelOwner implements api.Page } async requests() { - const { requests } = await this._channel.requests({}, undefined); + const { requests } = await this._channel.requests({}, { signal: undefined, timeout: 0 }); return requests.map(request => Request.from(request)); } @@ -861,7 +863,7 @@ export class Page extends ChannelOwner implements api.Page this._browserContext.setDefaultNavigationTimeout(0); this._browserContext.setDefaultTimeout(0); this._instrumentation?.onWillPause({ keepTestTimeout: !!_options?.__testHookKeepTestTimeout }); - await this._closedOrCrashedScope.safeRace(this.context()._channel.pause({}, undefined)); + await this._closedOrCrashedScope.safeRace(this.context()._channel.pause({}, { signal: undefined, timeout: 0 })); this._browserContext.setDefaultNavigationTimeout(defaultNavigationTimeout); this._browserContext.setDefaultTimeout(defaultTimeout); } @@ -879,7 +881,7 @@ export class Page extends ChannelOwner implements api.Page if (options.margin && typeof options.margin[index] === 'number') transportOptions.margin![index] = transportOptions.margin![index] + 'px'; } - const result = await this._channel.pdf(transportOptions, undefined); + const result = await this._channel.pdf(transportOptions, { signal: undefined, timeout: 0 }); if (options.path) { await fs.promises.mkdir(path.dirname(options.path), { recursive: true }); await fs.promises.writeFile(options.path, result.pdf); @@ -888,12 +890,12 @@ export class Page extends ChannelOwner implements api.Page } async ariaSnapshot(options: TimeoutOptions & { mode?: 'ai' | 'default', depth?: number, boxes?: boolean } = {}): Promise { - const result = await this.mainFrame()._channel.ariaSnapshot({ timeout: this._timeoutSettings.timeout(options), mode: options.mode, depth: options.depth, boxes: options.boxes }, options.signal); + const result = await this.mainFrame()._channel.ariaSnapshot({ mode: options.mode, depth: options.depth, boxes: options.boxes }, this._mainFrame._timeout(options)); return result.snapshot; } async _setDockTile(image: Buffer) { - await this._channel.setDockTile({ image }, undefined); + await this._channel.setDockTile({ image }, { signal: undefined, timeout: 0 }); } } @@ -915,9 +917,9 @@ export class BindingCall extends ChannelOwner { frame }; const result = await func(source, ...this._initializer.args.map(parseResult)); - this._channel.resolve({ result: serializeArgument(result) }, undefined).catch(() => {}); + this._channel.resolve({ result: serializeArgument(result) }, { signal: undefined, timeout: 0 }).catch(() => {}); } catch (e) { - this._channel.reject({ error: serializeError(e) }, undefined).catch(() => {}); + this._channel.reject({ error: serializeError(e) }, { signal: undefined, timeout: 0 }).catch(() => {}); } } } diff --git a/packages/playwright-core/src/client/screencast.ts b/packages/playwright-core/src/client/screencast.ts index 6b838a80ead92..f867203d02a8e 100644 --- a/packages/playwright-core/src/client/screencast.ts +++ b/packages/playwright-core/src/client/screencast.ts @@ -45,7 +45,7 @@ export class Screencast implements api.Screencast { quality: options.quality, sendFrames: !!options.onFrame, record: !!options.path, - }, undefined); + }, { signal: undefined, timeout: 0 }); if (result.artifact) { this._artifact = Artifact.from(result.artifact); this._savePath = options.path; @@ -57,7 +57,7 @@ export class Screencast implements api.Screencast { await this._page._wrapApiCall(async () => { this._started = false; this._onFrame = null; - await this._page._channel.screencastStop({}, undefined); + await this._page._channel.screencastStop({}, { signal: undefined, timeout: 0 }); if (this._savePath) await this._artifact?.saveAs(this._savePath); this._artifact = undefined; @@ -66,28 +66,28 @@ export class Screencast implements api.Screencast { } async showActions(options?: { duration?: number, position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right', fontSize?: number, cursor?: 'none' | 'pointer' }): Promise { - await this._page._channel.screencastShowActions({ duration: options?.duration, position: options?.position, fontSize: options?.fontSize, cursor: options?.cursor }, undefined); - return new DisposableStub(() => this._page._channel.screencastHideActions({}, undefined)); + await this._page._channel.screencastShowActions({ duration: options?.duration, position: options?.position, fontSize: options?.fontSize, cursor: options?.cursor }, { signal: undefined, timeout: 0 }); + return new DisposableStub(() => this._page._channel.screencastHideActions({}, { signal: undefined, timeout: 0 })); } async hideActions(): Promise { - await this._page._channel.screencastHideActions({}, undefined); + await this._page._channel.screencastHideActions({}, { signal: undefined, timeout: 0 }); } async showOverlay(html: string, options?: { duration?: number }): Promise { - const { id } = await this._page._channel.screencastShowOverlay({ html, duration: options?.duration }, undefined); - return new DisposableStub(() => this._page._channel.screencastRemoveOverlay({ id }, undefined)); + const { id } = await this._page._channel.screencastShowOverlay({ html, duration: options?.duration }, { signal: undefined, timeout: 0 }); + return new DisposableStub(() => this._page._channel.screencastRemoveOverlay({ id }, { signal: undefined, timeout: 0 })); } async showChapter(title: string, options?: { description?: string, duration?: number }): Promise { - await this._page._channel.screencastChapter({ title, ...options }, undefined); + await this._page._channel.screencastChapter({ title, ...options }, { signal: undefined, timeout: 0 }); } async showOverlays(): Promise { - await this._page._channel.screencastSetOverlayVisible({ visible: true }, undefined); + await this._page._channel.screencastSetOverlayVisible({ visible: true }, { signal: undefined, timeout: 0 }); } async hideOverlays(): Promise { - await this._page._channel.screencastSetOverlayVisible({ visible: false }, undefined); + await this._page._channel.screencastSetOverlayVisible({ visible: false }, { signal: undefined, timeout: 0 }); } } diff --git a/packages/playwright-core/src/client/selectors.ts b/packages/playwright-core/src/client/selectors.ts index 43ce5ca431f17..1a6035f3c3690 100644 --- a/packages/playwright-core/src/client/selectors.ts +++ b/packages/playwright-core/src/client/selectors.ts @@ -34,7 +34,7 @@ export class Selectors implements api.Selectors { const source = await evaluationScript(script, undefined, false); const selectorEngine: channels.SelectorEngine = { ...options, name, source }; for (const context of this._contextsForSelectors) - await context._channel.registerSelectorEngine({ selectorEngine }, undefined); + await context._channel.registerSelectorEngine({ selectorEngine }, { signal: undefined, timeout: 0 }); this._selectorEngines.push(selectorEngine); } @@ -43,7 +43,7 @@ export class Selectors implements api.Selectors { setTestIdAttribute(attributeName); for (const context of this._contextsForSelectors) { context._options.testIdAttributeName = attributeName; - context._channel.setTestIdAttributeName({ testIdAttributeName: attributeName }, undefined).catch(() => {}); + context._channel.setTestIdAttributeName({ testIdAttributeName: attributeName }, { signal: undefined, timeout: 0 }).catch(() => {}); } } diff --git a/packages/playwright-core/src/client/stream.ts b/packages/playwright-core/src/client/stream.ts index eb3a43081b9eb..fcc2cdebc28e4 100644 --- a/packages/playwright-core/src/client/stream.ts +++ b/packages/playwright-core/src/client/stream.ts @@ -43,7 +43,7 @@ class ReadableStreamImpl extends Readable { } override async _read() { - const result = await this._channel.read({ size: 1024 * 1024 }, undefined); + const result = await this._channel.read({ size: 1024 * 1024 }, { signal: undefined, timeout: 0 }); if (result.binary.byteLength) this.push(result.binary); else @@ -52,7 +52,7 @@ class ReadableStreamImpl extends Readable { override _destroy(error: Error | null, callback: (error: Error | null | undefined) => void): void { // Stream might be destroyed after the connection was closed. - this._channel.close({}, undefined).catch(e => null); + this._channel.close({}, { signal: undefined, timeout: 0 }).catch(e => null); super._destroy(error, callback); } } diff --git a/packages/playwright-core/src/client/tracing.ts b/packages/playwright-core/src/client/tracing.ts index 5f09f4c77863e..b2fa1378a6746 100644 --- a/packages/playwright-core/src/client/tracing.ts +++ b/packages/playwright-core/src/client/tracing.ts @@ -50,15 +50,15 @@ export class Tracing extends ChannelOwner implements ap snapshots: options.snapshots, screenshots: options.screenshots, live: options.live, - }, undefined); - const { traceName } = await this._channel.tracingStartChunk({ name: options.name, title: options.title }, undefined); + }, { signal: undefined, timeout: 0 }); + const { traceName } = await this._channel.tracingStartChunk({ name: options.name, title: options.title }, { signal: undefined, timeout: 0 }); await this._startCollectingStacks(traceName, this._isLive); }); } async startChunk(options: { name?: string, title?: string } = {}) { await this._wrapApiCall(async () => { - const { traceName } = await this._channel.tracingStartChunk(options, undefined); + const { traceName } = await this._channel.tracingStartChunk(options, { signal: undefined, timeout: 0 }); await this._startCollectingStacks(traceName, this._isLive); }); } @@ -66,12 +66,12 @@ export class Tracing extends ChannelOwner implements ap async group(name: string, options: { location?: { file: string, line?: number, column?: number } } = {}) { if (options.location) this._additionalSources.add(options.location.file); - await this._channel.tracingGroup({ name, location: options.location }, undefined); + await this._channel.tracingGroup({ name, location: options.location }, { signal: undefined, timeout: 0 }); return new DisposableStub(() => this.groupEnd()); } async groupEnd() { - await this._channel.tracingGroupEnd({}, undefined); + await this._channel.tracingGroupEnd({}, { signal: undefined, timeout: 0 }); } private async _startCollectingStacks(traceName: string, live: boolean) { @@ -92,7 +92,7 @@ export class Tracing extends ChannelOwner implements ap async stop(options: { path?: string } = {}) { await this._wrapApiCall(async () => { await this._doStopChunk(options.path); - await this._channel.tracingStop({}, undefined); + await this._channel.tracingStop({}, { signal: undefined, timeout: 0 }); }); } @@ -136,7 +136,7 @@ export class Tracing extends ChannelOwner implements ap harPath: isZip ? undefined : har, resourcesDir: options.resourcesDir, }, - }, undefined); + }, { signal: undefined, timeout: 0 }); this._harRecorders.set(harId, { path: har, resourcesDir: options.resourcesDir }); return harId; } @@ -150,7 +150,7 @@ export class Tracing extends ChannelOwner implements ap const isZip = harParams.path.endsWith('.zip'); if (isLocal) { - const { entries } = await this._channel.harExport({ harId, mode: 'entries' }, undefined); + const { entries } = await this._channel.harExport({ harId, mode: 'entries' }, { signal: undefined, timeout: 0 }); if (!isZip) { // Server wrote HAR and resources to the user's chosen paths. return; @@ -162,7 +162,7 @@ export class Tracing extends ChannelOwner implements ap return; } - const { artifact: artifactChannel } = await this._channel.harExport({ harId, mode: 'archive' }, undefined); + const { artifact: artifactChannel } = await this._channel.harExport({ harId, mode: 'archive' }, { signal: undefined, timeout: 0 }); const artifact = Artifact.from(artifactChannel!); if (isZip) { await artifact.saveAs(harParams.path); @@ -191,7 +191,7 @@ export class Tracing extends ChannelOwner implements ap if (!filePath) { // Not interested in artifacts. - await this._channel.tracingStopChunk({ mode: 'discard' }, undefined); + await this._channel.tracingStopChunk({ mode: 'discard' }, { signal: undefined, timeout: 0 }); if (this._stacksId) await this._connection.localUtils()!.traceDiscarded({ stacksId: this._stacksId }); return; @@ -204,12 +204,12 @@ export class Tracing extends ChannelOwner implements ap const isLocal = !this._connection.isRemote(); if (isLocal) { - const result = await this._channel.tracingStopChunk({ mode: 'entries' }, undefined); + const result = await this._channel.tracingStopChunk({ mode: 'entries' }, { signal: undefined, timeout: 0 }); await localUtils.zip({ zipFile: filePath, entries: result.entries!, mode: 'write', stacksId: this._stacksId, includeSources: this._includeSources, additionalSources }); return; } - const result = await this._channel.tracingStopChunk({ mode: 'archive' }, undefined); + const result = await this._channel.tracingStopChunk({ mode: 'archive' }, { signal: undefined, timeout: 0 }); // The artifact may be missing if the browser closed while stopping tracing. if (!result.artifact) { diff --git a/packages/playwright-core/src/client/types.ts b/packages/playwright-core/src/client/types.ts index 7dadd1257450c..dfa07bc012723 100644 --- a/packages/playwright-core/src/client/types.ts +++ b/packages/playwright-core/src/client/types.ts @@ -147,4 +147,4 @@ export type AnnotateOptions = { duration?: number, position?: AnnotatePosition, export type RemoteAddr = channels.RemoteAddr; export type SecurityDetails = channels.SecurityDetails; -export type FrameExpectParams = Omit & { expectedValue?: any }; +export type FrameExpectParams = Omit & { expectedValue?: any, timeout: number }; diff --git a/packages/playwright-core/src/client/waiter.ts b/packages/playwright-core/src/client/waiter.ts index 9d08ccdf434f4..a20ae8dc61142 100644 --- a/packages/playwright-core/src/client/waiter.ts +++ b/packages/playwright-core/src/client/waiter.ts @@ -55,7 +55,7 @@ export class Waiter { const owner = this._channelOwner; owner._wrapApiCall(async apiZone => { if (apiZone.internal || apiZone.reported) { - void owner._connection.sendMessageToServer(owner, '__waitInfo__', info, { internal: true }); + void owner._connection.sendMessageToServer(owner, '__waitInfo__', info, { internal: true, timeout: 0 }); return; } apiZone.reported = true; @@ -66,7 +66,7 @@ export class Waiter { if (!apiZone.title) apiZone.title = options.title; owner._instrumentation.onApiCallBegin(apiZone, { type: owner._type, method: '__waitInfo__', params: info }); - void owner._connection.sendMessageToServer(owner, '__waitInfo__', info, apiZone); + void owner._connection.sendMessageToServer(owner, '__waitInfo__', info, { ...apiZone, timeout: 0 }); }, options).catch(() => {}); } diff --git a/packages/playwright-core/src/client/webStorage.ts b/packages/playwright-core/src/client/webStorage.ts index 9a1840276f89f..f0ace1879baa0 100644 --- a/packages/playwright-core/src/client/webStorage.ts +++ b/packages/playwright-core/src/client/webStorage.ts @@ -27,24 +27,24 @@ export class WebStorage implements api.WebStorage { } async items(): Promise> { - const { items } = await this._page._channel.webStorageItems({ kind: this._kind }, undefined); + const { items } = await this._page._channel.webStorageItems({ kind: this._kind }, { signal: undefined, timeout: 0 }); return items; } async getItem(name: string): Promise { - const { value } = await this._page._channel.webStorageGetItem({ kind: this._kind, name }, undefined); + const { value } = await this._page._channel.webStorageGetItem({ kind: this._kind, name }, { signal: undefined, timeout: 0 }); return value ?? null; } async setItem(name: string, value: string): Promise { - await this._page._channel.webStorageSetItem({ kind: this._kind, name, value }, undefined); + await this._page._channel.webStorageSetItem({ kind: this._kind, name, value }, { signal: undefined, timeout: 0 }); } async removeItem(name: string): Promise { - await this._page._channel.webStorageRemoveItem({ kind: this._kind, name }, undefined); + await this._page._channel.webStorageRemoveItem({ kind: this._kind, name }, { signal: undefined, timeout: 0 }); } async clear(): Promise { - await this._page._channel.webStorageClear({ kind: this._kind }, undefined); + await this._page._channel.webStorageClear({ kind: this._kind }, { signal: undefined, timeout: 0 }); } } diff --git a/packages/playwright-core/src/client/worker.ts b/packages/playwright-core/src/client/worker.ts index 1279c2256b379..82a90907d7ce4 100644 --- a/packages/playwright-core/src/client/worker.ts +++ b/packages/playwright-core/src/client/worker.ts @@ -76,13 +76,13 @@ export class Worker extends ChannelOwner implements api. async evaluate(pageFunction: structs.PageFunction, arg?: Arg): Promise { assertMaxArguments(arguments.length, 2); - const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return parseResult(result.value); } async evaluateHandle(pageFunction: structs.PageFunction, arg?: Arg): Promise> { assertMaxArguments(arguments.length, 2); - const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, undefined); + const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg) }, { signal: undefined, timeout: 0 }); return JSHandle.from(result.handle) as any as structs.SmartHandle; } @@ -106,7 +106,7 @@ export class Worker extends ChannelOwner implements api. async _disconnect(options: { reason?: string } = {}): Promise { this._closeReason = options.reason; try { - await this._channel.disconnect(options, undefined); + await this._channel.disconnect(options, { signal: undefined, timeout: 0 }); } catch (e) { if (isTargetClosedError(e)) return; diff --git a/packages/playwright-core/src/client/writableStream.ts b/packages/playwright-core/src/client/writableStream.ts index 5a128eef0c297..f9bfae684081f 100644 --- a/packages/playwright-core/src/client/writableStream.ts +++ b/packages/playwright-core/src/client/writableStream.ts @@ -43,13 +43,13 @@ class WritableStreamImpl extends Writable { } override async _write(chunk: Buffer | string, encoding: BufferEncoding, callback: (error?: Error | null) => void) { - const error = await this._channel.write({ binary: typeof chunk === 'string' ? Buffer.from(chunk) : chunk }, undefined).catch(e => e); + const error = await this._channel.write({ binary: typeof chunk === 'string' ? Buffer.from(chunk) : chunk }, { signal: undefined, timeout: 0 }).catch(e => e); callback(error || null); } override async _final(callback: (error?: Error | null) => void) { // Stream might be destroyed after the connection was closed. - const error = await this._channel.close({}, undefined).catch(e => e); + const error = await this._channel.close({}, { signal: undefined, timeout: 0 }).catch(e => e); callback(error || null); } } diff --git a/packages/playwright-core/src/server/channels.d.ts b/packages/playwright-core/src/server/channels.d.ts index 9d55ce6535a64..62c59f0116e2e 100644 --- a/packages/playwright-core/src/server/channels.d.ts +++ b/packages/playwright-core/src/server/channels.d.ts @@ -238,7 +238,6 @@ export type AndroidDeviceWebViewRemovedEvent = { export type AndroidDeviceWaitParams = { androidSelector: AndroidSelector, state?: 'gone', - timeout: number, }; export type AndroidDeviceWaitOptions = { state?: 'gone', @@ -247,7 +246,6 @@ export type AndroidDeviceWaitResult = void; export type AndroidDeviceFillParams = { androidSelector: AndroidSelector, text: string, - timeout: number, }; export type AndroidDeviceFillOptions = { @@ -256,7 +254,6 @@ export type AndroidDeviceFillResult = void; export type AndroidDeviceTapParams = { androidSelector: AndroidSelector, duration?: number, - timeout: number, }; export type AndroidDeviceTapOptions = { duration?: number, @@ -266,7 +263,6 @@ export type AndroidDeviceDragParams = { androidSelector: AndroidSelector, dest: Point, speed?: number, - timeout: number, }; export type AndroidDeviceDragOptions = { speed?: number, @@ -276,7 +272,6 @@ export type AndroidDeviceFlingParams = { androidSelector: AndroidSelector, direction: 'up' | 'down' | 'left' | 'right', speed?: number, - timeout: number, }; export type AndroidDeviceFlingOptions = { speed?: number, @@ -284,7 +279,6 @@ export type AndroidDeviceFlingOptions = { export type AndroidDeviceFlingResult = void; export type AndroidDeviceLongTapParams = { androidSelector: AndroidSelector, - timeout: number, }; export type AndroidDeviceLongTapOptions = { @@ -294,7 +288,6 @@ export type AndroidDevicePinchCloseParams = { androidSelector: AndroidSelector, percent: number, speed?: number, - timeout: number, }; export type AndroidDevicePinchCloseOptions = { speed?: number, @@ -304,7 +297,6 @@ export type AndroidDevicePinchOpenParams = { androidSelector: AndroidSelector, percent: number, speed?: number, - timeout: number, }; export type AndroidDevicePinchOpenOptions = { speed?: number, @@ -315,7 +307,6 @@ export type AndroidDeviceScrollParams = { direction: 'up' | 'down' | 'left' | 'right', percent: number, speed?: number, - timeout: number, }; export type AndroidDeviceScrollOptions = { speed?: number, @@ -326,7 +317,6 @@ export type AndroidDeviceSwipeParams = { direction: 'up' | 'down' | 'left' | 'right', percent: number, speed?: number, - timeout: number, }; export type AndroidDeviceSwipeOptions = { speed?: number, @@ -610,7 +600,6 @@ export type APIRequestContextFetchParams = { jsonData?: string, formData?: NameValue[], multipartData?: FormField[], - timeout: number, failOnStatusCode?: boolean, ignoreHTTPSErrors?: boolean, maxRedirects?: number, @@ -1795,7 +1784,6 @@ export type BrowserTypeLaunchParams = { handleSIGINT?: boolean, handleSIGTERM?: boolean, handleSIGHUP?: boolean, - timeout: number, env?: NameValue[], headless?: boolean, proxy?: { @@ -1849,7 +1837,6 @@ export type BrowserTypeLaunchPersistentContextParams = { handleSIGINT?: boolean, handleSIGTERM?: boolean, handleSIGHUP?: boolean, - timeout: number, env?: NameValue[], headless?: boolean, proxy?: { @@ -2024,7 +2011,6 @@ export type BrowserTypeConnectOverCDPParams = { endpointURL?: string, headers?: NameValue[], slowMo?: number, - timeout: number, isLocal?: boolean, noDefaults?: boolean, artifactsDir?: string, @@ -2045,7 +2031,6 @@ export type BrowserTypeConnectOverCDPResult = { }; export type BrowserTypeConnectToWorkerParams = { endpoint: string, - timeout: number, }; export type BrowserTypeConnectToWorkerOptions = { @@ -2086,7 +2071,6 @@ export type ElectronLaunchParams = { chromiumSandbox?: boolean, cwd?: string, env?: NameValue[], - timeout: number, acceptDownloads?: 'accept' | 'deny' | 'internal-browser-default', bypassCSP?: boolean, colorScheme?: 'dark' | 'light' | 'no-preference' | 'no-override', @@ -2376,7 +2360,6 @@ export type FrameAriaSnapshotParams = { selector?: string, depth?: number, boxes?: boolean, - timeout: number, }; export type FrameAriaSnapshotOptions = { mode?: 'ai' | 'default', @@ -2390,7 +2373,6 @@ export type FrameAriaSnapshotResult = { export type FrameBlurParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameBlurOptions = { strict?: boolean, @@ -2402,7 +2384,6 @@ export type FrameCheckParams = { force?: boolean, scroll?: 'auto' | 'none', position?: Point, - timeout: number, trial?: boolean, }; export type FrameCheckOptions = { @@ -2424,7 +2405,6 @@ export type FrameClickParams = { delay?: number, button?: 'left' | 'right' | 'middle', clickCount?: number, - timeout: number, trial?: boolean, steps?: number, }; @@ -2452,7 +2432,6 @@ export type FrameDragAndDropParams = { target: string, force?: boolean, scroll?: 'auto' | 'none', - timeout: number, trial?: boolean, sourcePosition?: Point, targetPosition?: Point, @@ -2484,7 +2463,6 @@ export type FrameDropParams = { mimeType: string, value: string, }[], - timeout: number, }; export type FrameDropOptions = { strict?: boolean, @@ -2511,7 +2489,6 @@ export type FrameDblclickParams = { position?: Point, delay?: number, button?: 'left' | 'right' | 'middle', - timeout: number, trial?: boolean, steps?: number, }; @@ -2532,7 +2509,6 @@ export type FrameDispatchEventParams = { strict?: boolean, type: string, eventInit: SerializedArgument, - timeout: number, }; export type FrameDispatchEventOptions = { strict?: boolean, @@ -2565,7 +2541,6 @@ export type FrameFillParams = { strict?: boolean, value: string, force?: boolean, - timeout: number, }; export type FrameFillOptions = { strict?: boolean, @@ -2575,7 +2550,6 @@ export type FrameFillResult = void; export type FrameFocusParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameFocusOptions = { strict?: boolean, @@ -2614,7 +2588,6 @@ export type FrameGetAttributeParams = { selector: string, strict?: boolean, name: string, - timeout: number, }; export type FrameGetAttributeOptions = { strict?: boolean, @@ -2624,7 +2597,6 @@ export type FrameGetAttributeResult = { }; export type FrameGotoParams = { url: string, - timeout: number, waitUntil?: LifecycleEvent, referer?: string, }; @@ -2642,7 +2614,6 @@ export type FrameHoverParams = { scroll?: 'auto' | 'none', modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[], position?: Point, - timeout: number, trial?: boolean, }; export type FrameHoverOptions = { @@ -2657,7 +2628,6 @@ export type FrameHoverResult = void; export type FrameInnerHTMLParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameInnerHTMLOptions = { strict?: boolean, @@ -2668,7 +2638,6 @@ export type FrameInnerHTMLResult = { export type FrameInnerTextParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameInnerTextOptions = { strict?: boolean, @@ -2679,7 +2648,6 @@ export type FrameInnerTextResult = { export type FrameInputValueParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameInputValueOptions = { strict?: boolean, @@ -2690,7 +2658,6 @@ export type FrameInputValueResult = { export type FrameIsCheckedParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameIsCheckedOptions = { strict?: boolean, @@ -2701,7 +2668,6 @@ export type FrameIsCheckedResult = { export type FrameIsDisabledParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameIsDisabledOptions = { strict?: boolean, @@ -2712,7 +2678,6 @@ export type FrameIsDisabledResult = { export type FrameIsEnabledParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameIsEnabledOptions = { strict?: boolean, @@ -2743,7 +2708,6 @@ export type FrameIsVisibleResult = { export type FrameIsEditableParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameIsEditableOptions = { strict?: boolean, @@ -2757,7 +2721,6 @@ export type FramePressParams = { key: string, delay?: number, noWaitAfter?: boolean, - timeout: number, }; export type FramePressOptions = { strict?: boolean, @@ -2804,7 +2767,6 @@ export type FrameSelectOptionParams = { index?: number, }[], force?: boolean, - timeout: number, }; export type FrameSelectOptionOptions = { strict?: boolean, @@ -2822,7 +2784,6 @@ export type FrameSelectOptionResult = { }; export type FrameSetContentParams = { html: string, - timeout: number, waitUntil?: LifecycleEvent, }; export type FrameSetContentOptions = { @@ -2841,7 +2802,6 @@ export type FrameSetInputFilesParams = { directoryStream?: WritableStreamChannel, localPaths?: string[], streams?: WritableStreamChannel[], - timeout: number, }; export type FrameSetInputFilesOptions = { strict?: boolean, @@ -2863,7 +2823,6 @@ export type FrameTapParams = { scroll?: 'auto' | 'none', modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[], position?: Point, - timeout: number, trial?: boolean, }; export type FrameTapOptions = { @@ -2878,7 +2837,6 @@ export type FrameTapResult = void; export type FrameTextContentParams = { selector: string, strict?: boolean, - timeout: number, }; export type FrameTextContentOptions = { strict?: boolean, @@ -2896,7 +2854,6 @@ export type FrameTypeParams = { strict?: boolean, text: string, delay?: number, - timeout: number, }; export type FrameTypeOptions = { strict?: boolean, @@ -2909,7 +2866,6 @@ export type FrameUncheckParams = { force?: boolean, scroll?: 'auto' | 'none', position?: Point, - timeout: number, trial?: boolean, }; export type FrameUncheckOptions = { @@ -2931,7 +2887,6 @@ export type FrameWaitForFunctionParams = { expression: string, isFunction?: boolean, arg: SerializedArgument, - timeout: number, pollingInterval?: number, selector?: string, strict?: boolean, @@ -2948,7 +2903,6 @@ export type FrameWaitForFunctionResult = { export type FrameWaitForSelectorParams = { selector: string, strict?: boolean, - timeout: number, state?: 'attached' | 'detached' | 'visible' | 'hidden', omitReturnValue?: boolean, }; @@ -2970,7 +2924,6 @@ export type FrameExpectParams = { expectedValue?: SerializedArgument, useInnerText?: boolean, isNot: boolean, - timeout: number, }; export type FrameExpectOptions = { selector?: string, @@ -3145,7 +3098,6 @@ export type ElementHandleCheckParams = { force?: boolean, scroll?: 'auto' | 'none', position?: Point, - timeout: number, trial?: boolean, }; export type ElementHandleCheckOptions = { @@ -3164,7 +3116,6 @@ export type ElementHandleClickParams = { delay?: number, button?: 'left' | 'right' | 'middle', clickCount?: number, - timeout: number, trial?: boolean, steps?: number, }; @@ -3193,7 +3144,6 @@ export type ElementHandleDblclickParams = { position?: Point, delay?: number, button?: 'left' | 'right' | 'middle', - timeout: number, trial?: boolean, steps?: number, }; @@ -3219,7 +3169,6 @@ export type ElementHandleDispatchEventResult = void; export type ElementHandleFillParams = { value: string, force?: boolean, - timeout: number, }; export type ElementHandleFillOptions = { force?: boolean, @@ -3242,7 +3191,6 @@ export type ElementHandleHoverParams = { scroll?: 'auto' | 'none', modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[], position?: Point, - timeout: number, trial?: boolean, }; export type ElementHandleHoverOptions = { @@ -3306,7 +3254,6 @@ export type ElementHandleOwnerFrameResult = { export type ElementHandlePressParams = { key: string, delay?: number, - timeout: number, noWaitAfter?: boolean, }; export type ElementHandlePressOptions = { @@ -3334,7 +3281,6 @@ export type ElementHandleQuerySelectorAllResult = { elements: ElementHandleChannel[], }; export type ElementHandleScreenshotParams = { - timeout: number, type?: 'png' | 'jpeg' | 'webp', quality?: number, omitBackground?: boolean, @@ -3365,12 +3311,8 @@ export type ElementHandleScreenshotOptions = { export type ElementHandleScreenshotResult = { binary: Binary, }; -export type ElementHandleScrollIntoViewIfNeededParams = { - timeout: number, -}; -export type ElementHandleScrollIntoViewIfNeededOptions = { - -}; +export type ElementHandleScrollIntoViewIfNeededParams = {}; +export type ElementHandleScrollIntoViewIfNeededOptions = {}; export type ElementHandleScrollIntoViewIfNeededResult = void; export type ElementHandleSelectOptionParams = { elements?: ElementHandleChannel[], @@ -3381,7 +3323,6 @@ export type ElementHandleSelectOptionParams = { index?: number, }[], force?: boolean, - timeout: number, }; export type ElementHandleSelectOptionOptions = { elements?: ElementHandleChannel[], @@ -3398,7 +3339,6 @@ export type ElementHandleSelectOptionResult = { }; export type ElementHandleSelectTextParams = { force?: boolean, - timeout: number, }; export type ElementHandleSelectTextOptions = { force?: boolean, @@ -3414,7 +3354,6 @@ export type ElementHandleSetInputFilesParams = { directoryStream?: WritableStreamChannel, localPaths?: string[], streams?: WritableStreamChannel[], - timeout: number, }; export type ElementHandleSetInputFilesOptions = { payloads?: { @@ -3433,7 +3372,6 @@ export type ElementHandleTapParams = { scroll?: 'auto' | 'none', modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[], position?: Point, - timeout: number, trial?: boolean, }; export type ElementHandleTapOptions = { @@ -3452,7 +3390,6 @@ export type ElementHandleTextContentResult = { export type ElementHandleTypeParams = { text: string, delay?: number, - timeout: number, }; export type ElementHandleTypeOptions = { delay?: number, @@ -3462,7 +3399,6 @@ export type ElementHandleUncheckParams = { force?: boolean, scroll?: 'auto' | 'none', position?: Point, - timeout: number, trial?: boolean, }; export type ElementHandleUncheckOptions = { @@ -3474,7 +3410,6 @@ export type ElementHandleUncheckOptions = { export type ElementHandleUncheckResult = void; export type ElementHandleWaitForElementStateParams = { state: 'visible' | 'hidden' | 'stable' | 'enabled' | 'disabled' | 'editable', - timeout: number, }; export type ElementHandleWaitForElementStateOptions = { @@ -3483,7 +3418,6 @@ export type ElementHandleWaitForElementStateResult = void; export type ElementHandleWaitForSelectorParams = { selector: string, strict?: boolean, - timeout: number, state?: 'attached' | 'detached' | 'visible' | 'hidden', }; export type ElementHandleWaitForSelectorOptions = { @@ -3596,7 +3530,6 @@ export type LocalUtilsConnectParams = { headers?: any, exposeNetwork?: string, slowMo?: number, - timeout: number, socksProxyRedirectPortForTest?: number, }; export type LocalUtilsConnectOptions = { @@ -4124,7 +4057,6 @@ export type PageExposeBindingResult = { disposable: DisposableChannel, }; export type PageGoBackParams = { - timeout: number, waitUntil?: LifecycleEvent, }; export type PageGoBackOptions = { @@ -4134,7 +4066,6 @@ export type PageGoBackResult = { response?: ResponseChannel, }; export type PageGoForwardParams = { - timeout: number, waitUntil?: LifecycleEvent, }; export type PageGoForwardOptions = { @@ -4172,7 +4103,6 @@ export type PageUnregisterLocatorHandlerOptions = { }; export type PageUnregisterLocatorHandlerResult = void; export type PageReloadParams = { - timeout: number, waitUntil?: LifecycleEvent, }; export type PageReloadOptions = { @@ -4183,7 +4113,6 @@ export type PageReloadResult = { }; export type PageExpectScreenshotParams = { expected?: Binary, - timeout: number, isNot: boolean, locator?: { frame: FrameChannel, @@ -4243,7 +4172,6 @@ export type PageExpectScreenshotErrorDetails = { log?: string[], }; export type PageScreenshotParams = { - timeout: number, type?: 'png' | 'jpeg' | 'webp', quality?: number, fullPage?: boolean, diff --git a/packages/playwright-core/src/server/dispatchers/dispatcher.ts b/packages/playwright-core/src/server/dispatchers/dispatcher.ts index 1cf7edeb70ac2..d8395683597ac 100644 --- a/packages/playwright-core/src/server/dispatchers/dispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/dispatcher.ts @@ -304,11 +304,14 @@ export class DispatcherConnection { async dispatch(message: object) { const { id, guid, method, params, metadata } = message as any; + const metadataWithDefaults = metadata ? + (typeof metadata === 'object' ? { ...metadata, timeout: metadata.timeout ?? params?.timeout ?? 0 } : metadata) : + { timeout: params?.timeout ?? 0 }; const dispatcher = this._dispatcherByGuid.get(guid); if (method === '__waitInfo__') { // Fire-and-forget: silently drop if the target is gone. if (dispatcher) - await this._dispatchWaitInfo(id, dispatcher, params, metadata); + await this._dispatchWaitInfo(id, dispatcher, params, metadataWithDefaults); return; } if (method === '__abort__') { @@ -326,7 +329,7 @@ export class DispatcherConnection { const validator = findValidator(dispatcher._type, method, 'Params'); const validatorContext = this._validatorFromWireContext(); validParams = validator(params, '', validatorContext); - validMetadata = metadataValidator(metadata, '', validatorContext); + validMetadata = metadataValidator(metadataWithDefaults, '', validatorContext); if (typeof (dispatcher as any)[method] !== 'function') throw new Error(`Mismatching dispatcher: "${dispatcher._type}" does not implement "${method}"`); } catch (e) { @@ -342,6 +345,7 @@ export class DispatcherConnection { } const sdkObject = dispatcher._object; + const paramsForMetadata = validMetadata.timeout ? { ...(params || {}), timeout: validMetadata.timeout } : params || {}; const callMetadata: CallMetadata = { id: `call@${id}`, location: validMetadata.location, @@ -355,7 +359,7 @@ export class DispatcherConnection { endTime: 0, type: dispatcher._type, method, - params: params || {}, + params: paramsForMetadata, log: [], }; const controller = dispatcher.createProgressController(callMetadata); @@ -367,7 +371,7 @@ export class DispatcherConnection { // If the dispatcher has been disposed while running the instrumentation call, error out. if (this._dispatcherByGuid.get(guid) !== dispatcher) throw new TargetClosedError(sdkObject.closeReason()); - const result = await controller.run(progress => (dispatcher as any)[method](validParams, progress), validParams?.timeout); + const result = await controller.run(progress => (dispatcher as any)[method](validParams, progress), validMetadata.timeout); const validator = findValidator(dispatcher._type, method, 'Result'); response.result = validator(result, '', this._validatorToWireContext()); callMetadata.result = result; diff --git a/packages/playwright-core/src/server/dispatchers/frameDispatcher.ts b/packages/playwright-core/src/server/dispatchers/frameDispatcher.ts index 12aea64c8e2fd..67593bde88012 100644 --- a/packages/playwright-core/src/server/dispatchers/frameDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/frameDispatcher.ts @@ -276,7 +276,7 @@ export class FrameDispatcher extends Dispatcher { - progress.log(`${renderTitleForCall(progress.metadata)}${params.timeout ? ` with timeout ${params.timeout}ms` : ''}`); + progress.log(`${renderTitleForCall(progress.metadata)}${progress.timeout ? ` with timeout ${progress.timeout}ms` : ''}`); const expectedValue = params.expectedValue ? parseArgument(params.expectedValue) : undefined; try { await this._frame.expect(progress, params.selector, { ...params, expectedValue }); diff --git a/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts b/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts index 55f51723d210e..b9e4ba875092a 100644 --- a/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts @@ -233,7 +233,7 @@ export class PageDispatcher extends Dispatcher this._channel.socksConnected(payload, undefined)); - this._handler.on(socks.SocksProxyHandler.Events.SocksData, (payload: socks.SocksSocketDataPayload) => this._channel.socksData(payload, undefined)); - this._handler.on(socks.SocksProxyHandler.Events.SocksError, (payload: socks.SocksSocketErrorPayload) => this._channel.socksError(payload, undefined)); - this._handler.on(socks.SocksProxyHandler.Events.SocksFailed, (payload: socks.SocksSocketFailedPayload) => this._channel.socksFailed(payload, undefined)); - this._handler.on(socks.SocksProxyHandler.Events.SocksEnd, (payload: socks.SocksSocketEndPayload) => this._channel.socksEnd(payload, undefined)); + this._handler.on(socks.SocksProxyHandler.Events.SocksConnected, (payload: socks.SocksSocketConnectedPayload) => this._channel.socksConnected(payload, { signal: undefined, timeout: 0 })); + this._handler.on(socks.SocksProxyHandler.Events.SocksData, (payload: socks.SocksSocketDataPayload) => this._channel.socksData(payload, { signal: undefined, timeout: 0 })); + this._handler.on(socks.SocksProxyHandler.Events.SocksError, (payload: socks.SocksSocketErrorPayload) => this._channel.socksError(payload, { signal: undefined, timeout: 0 })); + this._handler.on(socks.SocksProxyHandler.Events.SocksFailed, (payload: socks.SocksSocketFailedPayload) => this._channel.socksFailed(payload, { signal: undefined, timeout: 0 })); + this._handler.on(socks.SocksProxyHandler.Events.SocksEnd, (payload: socks.SocksSocketEndPayload) => this._channel.socksEnd(payload, { signal: undefined, timeout: 0 })); this._channel.on('socksRequested', payload => this._handler.socketRequested(payload)); this._channel.on('socksClosed', payload => this._handler.socketClosed(payload)); this._channel.on('socksData', payload => this._handler.sendSocketData(payload)); diff --git a/packages/protocol/spec/android.yml b/packages/protocol/spec/android.yml index 5c627b675dc8d..7d5c498c90a12 100644 --- a/packages/protocol/spec/android.yml +++ b/packages/protocol/spec/android.yml @@ -62,21 +62,18 @@ AndroidDevice: type: enum? literals: - gone - timeout: float fill: title: Fill "{text}" parameters: androidSelector: AndroidSelector text: string - timeout: float tap: title: Tap parameters: androidSelector: AndroidSelector duration: float? - timeout: float drag: title: Drag @@ -84,7 +81,6 @@ AndroidDevice: androidSelector: AndroidSelector dest: Point speed: float? - timeout: float fling: title: Fling @@ -98,13 +94,11 @@ AndroidDevice: - left - right speed: float? - timeout: float longTap: title: Long tap parameters: androidSelector: AndroidSelector - timeout: float pinchClose: title: Pinch close @@ -112,7 +106,6 @@ AndroidDevice: androidSelector: AndroidSelector percent: float speed: float? - timeout: float pinchOpen: title: Pinch open @@ -120,7 +113,6 @@ AndroidDevice: androidSelector: AndroidSelector percent: float speed: float? - timeout: float scroll: title: Scroll @@ -135,7 +127,6 @@ AndroidDevice: - right percent: float speed: float? - timeout: float swipe: title: Swipe @@ -150,7 +141,6 @@ AndroidDevice: - right percent: float speed: float? - timeout: float info: internal: true diff --git a/packages/protocol/spec/api.yml b/packages/protocol/spec/api.yml index 6e8ff2281d425..e975594a6a7b6 100644 --- a/packages/protocol/spec/api.yml +++ b/packages/protocol/spec/api.yml @@ -40,7 +40,6 @@ APIRequestContext: multipartData: type: array? items: FormField - timeout: float failOnStatusCode: boolean? ignoreHTTPSErrors: boolean? maxRedirects: int? diff --git a/packages/protocol/spec/browserType.yml b/packages/protocol/spec/browserType.yml index 7c4247a8844c9..a50d1d2001505 100644 --- a/packages/protocol/spec/browserType.yml +++ b/packages/protocol/spec/browserType.yml @@ -48,7 +48,6 @@ BrowserType: type: array? items: NameValue slowMo: float? - timeout: float isLocal: boolean? noDefaults: boolean? artifactsDir: string? @@ -61,6 +60,5 @@ BrowserType: title: Connect to worker parameters: endpoint: string - timeout: float returns: worker: Worker diff --git a/packages/protocol/spec/core.yml b/packages/protocol/spec/core.yml index b97078ea769ac..c2bcf92d5aa41 100644 --- a/packages/protocol/spec/core.yml +++ b/packages/protocol/spec/core.yml @@ -25,6 +25,7 @@ Metadata: internal: boolean? # Test runner step id. stepId: string? + timeout: float ClientSideCallMetadata: type: object diff --git a/packages/protocol/spec/electron.yml b/packages/protocol/spec/electron.yml index c25b36becc8b3..877b4077469af 100644 --- a/packages/protocol/spec/electron.yml +++ b/packages/protocol/spec/electron.yml @@ -28,7 +28,6 @@ Electron: env: type: array? items: NameValue - timeout: float acceptDownloads: type: enum? literals: diff --git a/packages/protocol/spec/frame.yml b/packages/protocol/spec/frame.yml index 849ba14302562..421530f52abfb 100644 --- a/packages/protocol/spec/frame.yml +++ b/packages/protocol/spec/frame.yml @@ -87,7 +87,6 @@ Frame: selector: string? depth: int? boxes: boolean? - timeout: float returns: snapshot: string @@ -96,7 +95,6 @@ Frame: parameters: selector: string strict: boolean? - timeout: float flags: slowMo: true snapshot: true @@ -114,7 +112,6 @@ Frame: - auto - none position: Point? - timeout: float trial: boolean? flags: slowMo: true @@ -154,7 +151,6 @@ Frame: - right - middle clickCount: int? - timeout: float trial: boolean? steps: int? flags: @@ -183,7 +179,6 @@ Frame: literals: - auto - none - timeout: float trial: boolean? sourcePosition: Point? targetPosition: Point? @@ -224,7 +219,6 @@ Frame: properties: mimeType: string value: string - timeout: float flags: slowMo: true snapshot: true @@ -261,7 +255,6 @@ Frame: - left - right - middle - timeout: float trial: boolean? steps: int? flags: @@ -278,7 +271,6 @@ Frame: strict: boolean? type: string eventInit: SerializedArgument - timeout: float flags: slowMo: true snapshot: true @@ -315,7 +307,6 @@ Frame: strict: boolean? value: string force: boolean? - timeout: float flags: slowMo: true snapshot: true @@ -328,7 +319,6 @@ Frame: parameters: selector: string strict: boolean? - timeout: float flags: slowMo: true snapshot: true @@ -365,7 +355,6 @@ Frame: selector: string strict: boolean? name: string - timeout: float returns: value: string? flags: @@ -376,7 +365,6 @@ Frame: title: Navigate to "{url}" parameters: url: string - timeout: float waitUntil: LifecycleEvent? referer: string? returns: @@ -408,7 +396,6 @@ Frame: - Meta - Shift position: Point? - timeout: float trial: boolean? flags: slowMo: true @@ -423,7 +410,6 @@ Frame: parameters: selector: string strict: boolean? - timeout: float returns: value: string flags: @@ -436,7 +422,6 @@ Frame: parameters: selector: string strict: boolean? - timeout: float returns: value: string flags: @@ -449,7 +434,6 @@ Frame: parameters: selector: string strict: boolean? - timeout: float returns: value: string flags: @@ -462,7 +446,6 @@ Frame: parameters: selector: string strict: boolean? - timeout: float returns: value: boolean flags: @@ -475,7 +458,6 @@ Frame: parameters: selector: string strict: boolean? - timeout: float returns: value: boolean flags: @@ -488,7 +470,6 @@ Frame: parameters: selector: string strict: boolean? - timeout: float returns: value: boolean flags: @@ -527,7 +508,6 @@ Frame: parameters: selector: string strict: boolean? - timeout: float returns: value: boolean flags: @@ -542,7 +522,6 @@ Frame: key: string delay: float? noWaitAfter: boolean? - timeout: float flags: slowMo: true snapshot: true @@ -599,7 +578,6 @@ Frame: label: string? index: int? force: boolean? - timeout: float returns: values: type: array @@ -615,7 +593,6 @@ Frame: title: Set content parameters: html: string - timeout: float waitUntil: LifecycleEvent? flags: snapshot: true @@ -643,7 +620,6 @@ Frame: streams: type: array? items: WritableStream - timeout: float flags: slowMo: true snapshot: true @@ -673,7 +649,6 @@ Frame: - Meta - Shift position: Point? - timeout: float trial: boolean? flags: slowMo: true @@ -688,7 +663,6 @@ Frame: parameters: selector: string strict: boolean? - timeout: float returns: value: string? flags: @@ -708,7 +682,6 @@ Frame: strict: boolean? text: string delay: float? - timeout: float flags: slowMo: true snapshot: true @@ -728,7 +701,6 @@ Frame: - auto - none position: Point? - timeout: float trial: boolean? flags: slowMo: true @@ -750,7 +722,6 @@ Frame: expression: string isFunction: boolean? arg: SerializedArgument - timeout: float # When present, polls on interval. Otherwise, polls on raf. pollingInterval: float? # When present, first argument is the matched element. @@ -768,7 +739,6 @@ Frame: parameters: selector: string strict: boolean? - timeout: float state: type: enum? literals: @@ -800,7 +770,6 @@ Frame: expectedValue: SerializedArgument? useInnerText: boolean? isNot: boolean - timeout: float errorDetails: received: type: object? diff --git a/packages/protocol/spec/handles.yml b/packages/protocol/spec/handles.yml index 8818c936d1b18..fb38ee8a18dd4 100644 --- a/packages/protocol/spec/handles.yml +++ b/packages/protocol/spec/handles.yml @@ -131,7 +131,6 @@ ElementHandle: - auto - none position: Point? - timeout: float trial: boolean? flags: slowMo: true @@ -169,7 +168,6 @@ ElementHandle: - right - middle clickCount: int? - timeout: float trial: boolean? steps: int? flags: @@ -212,7 +210,6 @@ ElementHandle: - left - right - middle - timeout: float trial: boolean? steps: int? flags: @@ -237,7 +234,6 @@ ElementHandle: parameters: value: string force: boolean? - timeout: float flags: slowMo: true snapshot: true @@ -283,7 +279,6 @@ ElementHandle: - Meta - Shift position: Point? - timeout: float trial: boolean? flags: slowMo: true @@ -384,7 +379,6 @@ ElementHandle: parameters: key: string delay: float? - timeout: float noWaitAfter: boolean? flags: slowMo: true @@ -417,7 +411,6 @@ ElementHandle: screenshot: title: Screenshot parameters: - timeout: float type: type: enum? literals: @@ -434,8 +427,6 @@ ElementHandle: scrollIntoViewIfNeeded: title: Scroll into view - parameters: - timeout: float flags: slowMo: true snapshot: true @@ -457,7 +448,6 @@ ElementHandle: label: string? index: int? force: boolean? - timeout: float returns: values: type: array @@ -473,7 +463,6 @@ ElementHandle: title: Select text parameters: force: boolean? - timeout: float flags: slowMo: true snapshot: true @@ -499,7 +488,6 @@ ElementHandle: streams: type: array? items: WritableStream - timeout: float flags: slowMo: true snapshot: true @@ -527,7 +515,6 @@ ElementHandle: - Meta - Shift position: Point? - timeout: float trial: boolean? flags: slowMo: true @@ -550,7 +537,6 @@ ElementHandle: parameters: text: string delay: float? - timeout: float flags: slowMo: true snapshot: true @@ -568,7 +554,6 @@ ElementHandle: - auto - none position: Point? - timeout: float trial: boolean? flags: slowMo: true @@ -589,7 +574,6 @@ ElementHandle: - enabled - disabled - editable - timeout: float flags: snapshot: true pause: true @@ -599,7 +583,6 @@ ElementHandle: parameters: selector: string strict: boolean? - timeout: float state: type: enum? literals: diff --git a/packages/protocol/spec/localUtils.yml b/packages/protocol/spec/localUtils.yml index 4381f8319dc0f..6d5eb8a8a47a7 100644 --- a/packages/protocol/spec/localUtils.yml +++ b/packages/protocol/spec/localUtils.yml @@ -120,7 +120,6 @@ LocalUtils: headers: json? exposeNetwork: string? slowMo: float? - timeout: float socksProxyRedirectPortForTest: int? returns: pipe: JsonPipe diff --git a/packages/protocol/spec/mixins.yml b/packages/protocol/spec/mixins.yml index c950b7f2b68ac..36c197654b6ca 100644 --- a/packages/protocol/spec/mixins.yml +++ b/packages/protocol/spec/mixins.yml @@ -76,7 +76,6 @@ LaunchOptions: handleSIGINT: boolean? handleSIGTERM: boolean? handleSIGHUP: boolean? - timeout: float env: type: array? items: NameValue diff --git a/packages/protocol/spec/page.yml b/packages/protocol/spec/page.yml index 66426950d9e75..722870100e7cf 100644 --- a/packages/protocol/spec/page.yml +++ b/packages/protocol/spec/page.yml @@ -113,7 +113,6 @@ Page: goBack: title: Go back parameters: - timeout: float waitUntil: LifecycleEvent? returns: response: Response? @@ -125,7 +124,6 @@ Page: goForward: title: Go forward parameters: - timeout: float waitUntil: LifecycleEvent? returns: response: Response? @@ -160,7 +158,6 @@ Page: reload: title: Reload parameters: - timeout: float waitUntil: LifecycleEvent? returns: response: Response? @@ -173,7 +170,6 @@ Page: title: Expect screenshot parameters: expected: binary? - timeout: float isNot: boolean locator: type: object? @@ -210,7 +206,6 @@ Page: screenshot: title: Screenshot parameters: - timeout: float type: type: enum? literals: diff --git a/packages/protocol/src/structs.d.ts b/packages/protocol/src/structs.d.ts index a44c990626d31..76541a7bf0415 100644 --- a/packages/protocol/src/structs.d.ts +++ b/packages/protocol/src/structs.d.ts @@ -90,6 +90,7 @@ export type Metadata = { title?: string, internal?: boolean, stepId?: string, + timeout: number, }; export type ClientSideCallMetadata = { diff --git a/packages/protocol/src/validator.ts b/packages/protocol/src/validator.ts index 6e102e9cfb6fa..46406ef915f47 100644 --- a/packages/protocol/src/validator.ts +++ b/packages/protocol/src/validator.ts @@ -54,52 +54,44 @@ scheme.AndroidDeviceWebViewRemovedEvent = tObject({ scheme.AndroidDeviceWaitParams = tObject({ androidSelector: tType('AndroidSelector'), state: tOptional(tEnum(['gone'])), - timeout: tFloat, }); scheme.AndroidDeviceWaitResult = tOptional(tObject({})); scheme.AndroidDeviceFillParams = tObject({ androidSelector: tType('AndroidSelector'), text: tString, - timeout: tFloat, }); scheme.AndroidDeviceFillResult = tOptional(tObject({})); scheme.AndroidDeviceTapParams = tObject({ androidSelector: tType('AndroidSelector'), duration: tOptional(tFloat), - timeout: tFloat, }); scheme.AndroidDeviceTapResult = tOptional(tObject({})); scheme.AndroidDeviceDragParams = tObject({ androidSelector: tType('AndroidSelector'), dest: tType('Point'), speed: tOptional(tFloat), - timeout: tFloat, }); scheme.AndroidDeviceDragResult = tOptional(tObject({})); scheme.AndroidDeviceFlingParams = tObject({ androidSelector: tType('AndroidSelector'), direction: tEnum(['up', 'down', 'left', 'right']), speed: tOptional(tFloat), - timeout: tFloat, }); scheme.AndroidDeviceFlingResult = tOptional(tObject({})); scheme.AndroidDeviceLongTapParams = tObject({ androidSelector: tType('AndroidSelector'), - timeout: tFloat, }); scheme.AndroidDeviceLongTapResult = tOptional(tObject({})); scheme.AndroidDevicePinchCloseParams = tObject({ androidSelector: tType('AndroidSelector'), percent: tFloat, speed: tOptional(tFloat), - timeout: tFloat, }); scheme.AndroidDevicePinchCloseResult = tOptional(tObject({})); scheme.AndroidDevicePinchOpenParams = tObject({ androidSelector: tType('AndroidSelector'), percent: tFloat, speed: tOptional(tFloat), - timeout: tFloat, }); scheme.AndroidDevicePinchOpenResult = tOptional(tObject({})); scheme.AndroidDeviceScrollParams = tObject({ @@ -107,7 +99,6 @@ scheme.AndroidDeviceScrollParams = tObject({ direction: tEnum(['up', 'down', 'left', 'right']), percent: tFloat, speed: tOptional(tFloat), - timeout: tFloat, }); scheme.AndroidDeviceScrollResult = tOptional(tObject({})); scheme.AndroidDeviceSwipeParams = tObject({ @@ -115,7 +106,6 @@ scheme.AndroidDeviceSwipeParams = tObject({ direction: tEnum(['up', 'down', 'left', 'right']), percent: tFloat, speed: tOptional(tFloat), - timeout: tFloat, }); scheme.AndroidDeviceSwipeResult = tOptional(tObject({})); scheme.AndroidDeviceInfoParams = tObject({ @@ -317,7 +307,6 @@ scheme.APIRequestContextFetchParams = tObject({ jsonData: tOptional(tString), formData: tOptional(tArray(tType('NameValue'))), multipartData: tOptional(tArray(tType('FormField'))), - timeout: tFloat, failOnStatusCode: tOptional(tBoolean), ignoreHTTPSErrors: tOptional(tBoolean), maxRedirects: tOptional(tInt), @@ -988,7 +977,6 @@ scheme.BrowserTypeLaunchParams = tObject({ handleSIGINT: tOptional(tBoolean), handleSIGTERM: tOptional(tBoolean), handleSIGHUP: tOptional(tBoolean), - timeout: tFloat, env: tOptional(tArray(tType('NameValue'))), headless: tOptional(tBoolean), proxy: tOptional(tObject({ @@ -1017,7 +1005,6 @@ scheme.BrowserTypeLaunchPersistentContextParams = tObject({ handleSIGINT: tOptional(tBoolean), handleSIGTERM: tOptional(tBoolean), handleSIGHUP: tOptional(tBoolean), - timeout: tFloat, env: tOptional(tArray(tType('NameValue'))), headless: tOptional(tBoolean), proxy: tOptional(tObject({ @@ -1105,7 +1092,6 @@ scheme.BrowserTypeConnectOverCDPParams = tObject({ endpointURL: tOptional(tString), headers: tOptional(tArray(tType('NameValue'))), slowMo: tOptional(tFloat), - timeout: tFloat, isLocal: tOptional(tBoolean), noDefaults: tOptional(tBoolean), artifactsDir: tOptional(tString), @@ -1117,7 +1103,6 @@ scheme.BrowserTypeConnectOverCDPResult = tObject({ }); scheme.BrowserTypeConnectToWorkerParams = tObject({ endpoint: tString, - timeout: tFloat, }); scheme.BrowserTypeConnectToWorkerResult = tObject({ worker: tChannel(['Worker']), @@ -1131,6 +1116,7 @@ scheme.Metadata = tObject({ title: tOptional(tString), internal: tOptional(tBoolean), stepId: tOptional(tString), + timeout: tFloat, }); scheme.ClientSideCallMetadata = tObject({ id: tInt, @@ -1154,7 +1140,6 @@ scheme.ElectronLaunchParams = tObject({ chromiumSandbox: tOptional(tBoolean), cwd: tOptional(tString), env: tOptional(tArray(tType('NameValue'))), - timeout: tFloat, acceptDownloads: tOptional(tEnum(['accept', 'deny', 'internal-browser-default'])), bypassCSP: tOptional(tBoolean), colorScheme: tOptional(tEnum(['dark', 'light', 'no-preference', 'no-override'])), @@ -1294,7 +1279,6 @@ scheme.FrameAriaSnapshotParams = tObject({ selector: tOptional(tString), depth: tOptional(tInt), boxes: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameAriaSnapshotResult = tObject({ snapshot: tString, @@ -1302,7 +1286,6 @@ scheme.FrameAriaSnapshotResult = tObject({ scheme.FrameBlurParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameBlurResult = tOptional(tObject({})); scheme.FrameCheckParams = tObject({ @@ -1311,7 +1294,6 @@ scheme.FrameCheckParams = tObject({ force: tOptional(tBoolean), scroll: tOptional(tEnum(['auto', 'none'])), position: tOptional(tType('Point')), - timeout: tFloat, trial: tOptional(tBoolean), }); scheme.FrameCheckResult = tOptional(tObject({})); @@ -1326,7 +1308,6 @@ scheme.FrameClickParams = tObject({ delay: tOptional(tFloat), button: tOptional(tEnum(['left', 'right', 'middle'])), clickCount: tOptional(tInt), - timeout: tFloat, trial: tOptional(tBoolean), steps: tOptional(tInt), }); @@ -1340,7 +1321,6 @@ scheme.FrameDragAndDropParams = tObject({ target: tString, force: tOptional(tBoolean), scroll: tOptional(tEnum(['auto', 'none'])), - timeout: tFloat, trial: tOptional(tBoolean), sourcePosition: tOptional(tType('Point')), targetPosition: tOptional(tType('Point')), @@ -1363,7 +1343,6 @@ scheme.FrameDropParams = tObject({ mimeType: tString, value: tString, }))), - timeout: tFloat, }); scheme.FrameDropResult = tOptional(tObject({})); scheme.FrameDblclickParams = tObject({ @@ -1375,7 +1354,6 @@ scheme.FrameDblclickParams = tObject({ position: tOptional(tType('Point')), delay: tOptional(tFloat), button: tOptional(tEnum(['left', 'right', 'middle'])), - timeout: tFloat, trial: tOptional(tBoolean), steps: tOptional(tInt), }); @@ -1385,7 +1363,6 @@ scheme.FrameDispatchEventParams = tObject({ strict: tOptional(tBoolean), type: tString, eventInit: tType('SerializedArgument'), - timeout: tFloat, }); scheme.FrameDispatchEventResult = tOptional(tObject({})); scheme.FrameEvaluateExpressionParams = tObject({ @@ -1409,13 +1386,11 @@ scheme.FrameFillParams = tObject({ strict: tOptional(tBoolean), value: tString, force: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameFillResult = tOptional(tObject({})); scheme.FrameFocusParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameFocusResult = tOptional(tObject({})); scheme.FrameFrameElementParams = tOptional(tObject({})); @@ -1441,14 +1416,12 @@ scheme.FrameGetAttributeParams = tObject({ selector: tString, strict: tOptional(tBoolean), name: tString, - timeout: tFloat, }); scheme.FrameGetAttributeResult = tObject({ value: tOptional(tString), }); scheme.FrameGotoParams = tObject({ url: tString, - timeout: tFloat, waitUntil: tOptional(tType('LifecycleEvent')), referer: tOptional(tString), }); @@ -1462,14 +1435,12 @@ scheme.FrameHoverParams = tObject({ scroll: tOptional(tEnum(['auto', 'none'])), modifiers: tOptional(tArray(tEnum(['Alt', 'Control', 'ControlOrMeta', 'Meta', 'Shift']))), position: tOptional(tType('Point')), - timeout: tFloat, trial: tOptional(tBoolean), }); scheme.FrameHoverResult = tOptional(tObject({})); scheme.FrameInnerHTMLParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameInnerHTMLResult = tObject({ value: tString, @@ -1477,7 +1448,6 @@ scheme.FrameInnerHTMLResult = tObject({ scheme.FrameInnerTextParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameInnerTextResult = tObject({ value: tString, @@ -1485,7 +1455,6 @@ scheme.FrameInnerTextResult = tObject({ scheme.FrameInputValueParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameInputValueResult = tObject({ value: tString, @@ -1493,7 +1462,6 @@ scheme.FrameInputValueResult = tObject({ scheme.FrameIsCheckedParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameIsCheckedResult = tObject({ value: tBoolean, @@ -1501,7 +1469,6 @@ scheme.FrameIsCheckedResult = tObject({ scheme.FrameIsDisabledParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameIsDisabledResult = tObject({ value: tBoolean, @@ -1509,7 +1476,6 @@ scheme.FrameIsDisabledResult = tObject({ scheme.FrameIsEnabledParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameIsEnabledResult = tObject({ value: tBoolean, @@ -1531,7 +1497,6 @@ scheme.FrameIsVisibleResult = tObject({ scheme.FrameIsEditableParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameIsEditableResult = tObject({ value: tBoolean, @@ -1542,7 +1507,6 @@ scheme.FramePressParams = tObject({ key: tString, delay: tOptional(tFloat), noWaitAfter: tOptional(tBoolean), - timeout: tFloat, }); scheme.FramePressResult = tOptional(tObject({})); scheme.FrameQuerySelectorParams = tObject({ @@ -1575,14 +1539,12 @@ scheme.FrameSelectOptionParams = tObject({ index: tOptional(tInt), }))), force: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameSelectOptionResult = tObject({ values: tArray(tString), }); scheme.FrameSetContentParams = tObject({ html: tString, - timeout: tFloat, waitUntil: tOptional(tType('LifecycleEvent')), }); scheme.FrameSetContentResult = tOptional(tObject({})); @@ -1598,7 +1560,6 @@ scheme.FrameSetInputFilesParams = tObject({ directoryStream: tOptional(tChannel(['WritableStream'])), localPaths: tOptional(tArray(tString)), streams: tOptional(tArray(tChannel(['WritableStream']))), - timeout: tFloat, }); scheme.FrameSetInputFilesResult = tOptional(tObject({})); scheme.FrameTapParams = tObject({ @@ -1608,14 +1569,12 @@ scheme.FrameTapParams = tObject({ scroll: tOptional(tEnum(['auto', 'none'])), modifiers: tOptional(tArray(tEnum(['Alt', 'Control', 'ControlOrMeta', 'Meta', 'Shift']))), position: tOptional(tType('Point')), - timeout: tFloat, trial: tOptional(tBoolean), }); scheme.FrameTapResult = tOptional(tObject({})); scheme.FrameTextContentParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tFloat, }); scheme.FrameTextContentResult = tObject({ value: tOptional(tString), @@ -1629,7 +1588,6 @@ scheme.FrameTypeParams = tObject({ strict: tOptional(tBoolean), text: tString, delay: tOptional(tFloat), - timeout: tFloat, }); scheme.FrameTypeResult = tOptional(tObject({})); scheme.FrameUncheckParams = tObject({ @@ -1638,7 +1596,6 @@ scheme.FrameUncheckParams = tObject({ force: tOptional(tBoolean), scroll: tOptional(tEnum(['auto', 'none'])), position: tOptional(tType('Point')), - timeout: tFloat, trial: tOptional(tBoolean), }); scheme.FrameUncheckResult = tOptional(tObject({})); @@ -1650,7 +1607,6 @@ scheme.FrameWaitForFunctionParams = tObject({ expression: tString, isFunction: tOptional(tBoolean), arg: tType('SerializedArgument'), - timeout: tFloat, pollingInterval: tOptional(tFloat), selector: tOptional(tString), strict: tOptional(tBoolean), @@ -1661,7 +1617,6 @@ scheme.FrameWaitForFunctionResult = tObject({ scheme.FrameWaitForSelectorParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tFloat, state: tOptional(tEnum(['attached', 'detached', 'visible', 'hidden'])), omitReturnValue: tOptional(tBoolean), }); @@ -1678,7 +1633,6 @@ scheme.FrameExpectParams = tObject({ expectedValue: tOptional(tType('SerializedArgument')), useInnerText: tOptional(tBoolean), isNot: tBoolean, - timeout: tFloat, }); scheme.FrameExpectResult = tOptional(tObject({})); scheme.FrameExpectErrorDetails = tObject({ @@ -1773,7 +1727,6 @@ scheme.ElementHandleCheckParams = tObject({ force: tOptional(tBoolean), scroll: tOptional(tEnum(['auto', 'none'])), position: tOptional(tType('Point')), - timeout: tFloat, trial: tOptional(tBoolean), }); scheme.ElementHandleCheckResult = tOptional(tObject({})); @@ -1786,7 +1739,6 @@ scheme.ElementHandleClickParams = tObject({ delay: tOptional(tFloat), button: tOptional(tEnum(['left', 'right', 'middle'])), clickCount: tOptional(tInt), - timeout: tFloat, trial: tOptional(tBoolean), steps: tOptional(tInt), }); @@ -1802,7 +1754,6 @@ scheme.ElementHandleDblclickParams = tObject({ position: tOptional(tType('Point')), delay: tOptional(tFloat), button: tOptional(tEnum(['left', 'right', 'middle'])), - timeout: tFloat, trial: tOptional(tBoolean), steps: tOptional(tInt), }); @@ -1815,7 +1766,6 @@ scheme.ElementHandleDispatchEventResult = tOptional(tObject({})); scheme.ElementHandleFillParams = tObject({ value: tString, force: tOptional(tBoolean), - timeout: tFloat, }); scheme.ElementHandleFillResult = tOptional(tObject({})); scheme.ElementHandleFocusParams = tOptional(tObject({})); @@ -1831,7 +1781,6 @@ scheme.ElementHandleHoverParams = tObject({ scroll: tOptional(tEnum(['auto', 'none'])), modifiers: tOptional(tArray(tEnum(['Alt', 'Control', 'ControlOrMeta', 'Meta', 'Shift']))), position: tOptional(tType('Point')), - timeout: tFloat, trial: tOptional(tBoolean), }); scheme.ElementHandleHoverResult = tOptional(tObject({})); @@ -1878,7 +1827,6 @@ scheme.ElementHandleOwnerFrameResult = tObject({ scheme.ElementHandlePressParams = tObject({ key: tString, delay: tOptional(tFloat), - timeout: tFloat, noWaitAfter: tOptional(tBoolean), }); scheme.ElementHandlePressResult = tOptional(tObject({})); @@ -1896,7 +1844,6 @@ scheme.ElementHandleQuerySelectorAllResult = tObject({ elements: tArray(tChannel(['ElementHandle'])), }); scheme.ElementHandleScreenshotParams = tObject({ - timeout: tFloat, type: tOptional(tEnum(['png', 'jpeg', 'webp'])), quality: tOptional(tInt), omitBackground: tOptional(tBoolean), @@ -1913,9 +1860,7 @@ scheme.ElementHandleScreenshotParams = tObject({ scheme.ElementHandleScreenshotResult = tObject({ binary: tBinary, }); -scheme.ElementHandleScrollIntoViewIfNeededParams = tObject({ - timeout: tFloat, -}); +scheme.ElementHandleScrollIntoViewIfNeededParams = tOptional(tObject({})); scheme.ElementHandleScrollIntoViewIfNeededResult = tOptional(tObject({})); scheme.ElementHandleSelectOptionParams = tObject({ elements: tOptional(tArray(tChannel(['ElementHandle']))), @@ -1926,14 +1871,12 @@ scheme.ElementHandleSelectOptionParams = tObject({ index: tOptional(tInt), }))), force: tOptional(tBoolean), - timeout: tFloat, }); scheme.ElementHandleSelectOptionResult = tObject({ values: tArray(tString), }); scheme.ElementHandleSelectTextParams = tObject({ force: tOptional(tBoolean), - timeout: tFloat, }); scheme.ElementHandleSelectTextResult = tOptional(tObject({})); scheme.ElementHandleSetInputFilesParams = tObject({ @@ -1946,7 +1889,6 @@ scheme.ElementHandleSetInputFilesParams = tObject({ directoryStream: tOptional(tChannel(['WritableStream'])), localPaths: tOptional(tArray(tString)), streams: tOptional(tArray(tChannel(['WritableStream']))), - timeout: tFloat, }); scheme.ElementHandleSetInputFilesResult = tOptional(tObject({})); scheme.ElementHandleTapParams = tObject({ @@ -1954,7 +1896,6 @@ scheme.ElementHandleTapParams = tObject({ scroll: tOptional(tEnum(['auto', 'none'])), modifiers: tOptional(tArray(tEnum(['Alt', 'Control', 'ControlOrMeta', 'Meta', 'Shift']))), position: tOptional(tType('Point')), - timeout: tFloat, trial: tOptional(tBoolean), }); scheme.ElementHandleTapResult = tOptional(tObject({})); @@ -1965,26 +1906,22 @@ scheme.ElementHandleTextContentResult = tObject({ scheme.ElementHandleTypeParams = tObject({ text: tString, delay: tOptional(tFloat), - timeout: tFloat, }); scheme.ElementHandleTypeResult = tOptional(tObject({})); scheme.ElementHandleUncheckParams = tObject({ force: tOptional(tBoolean), scroll: tOptional(tEnum(['auto', 'none'])), position: tOptional(tType('Point')), - timeout: tFloat, trial: tOptional(tBoolean), }); scheme.ElementHandleUncheckResult = tOptional(tObject({})); scheme.ElementHandleWaitForElementStateParams = tObject({ state: tEnum(['visible', 'hidden', 'stable', 'enabled', 'disabled', 'editable']), - timeout: tFloat, }); scheme.ElementHandleWaitForElementStateResult = tOptional(tObject({})); scheme.ElementHandleWaitForSelectorParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tFloat, state: tOptional(tEnum(['attached', 'detached', 'visible', 'hidden'])), }); scheme.ElementHandleWaitForSelectorResult = tObject({ @@ -2057,7 +1994,6 @@ scheme.LocalUtilsConnectParams = tObject({ headers: tOptional(tAny), exposeNetwork: tOptional(tString), slowMo: tOptional(tFloat), - timeout: tFloat, socksProxyRedirectPortForTest: tOptional(tInt), }); scheme.LocalUtilsConnectResult = tObject({ @@ -2385,14 +2321,12 @@ scheme.PageExposeBindingResult = tObject({ disposable: tChannel(['Disposable']), }); scheme.PageGoBackParams = tObject({ - timeout: tFloat, waitUntil: tOptional(tType('LifecycleEvent')), }); scheme.PageGoBackResult = tObject({ response: tOptional(tChannel(['Response'])), }); scheme.PageGoForwardParams = tObject({ - timeout: tFloat, waitUntil: tOptional(tType('LifecycleEvent')), }); scheme.PageGoForwardResult = tObject({ @@ -2417,7 +2351,6 @@ scheme.PageUnregisterLocatorHandlerParams = tObject({ }); scheme.PageUnregisterLocatorHandlerResult = tOptional(tObject({})); scheme.PageReloadParams = tObject({ - timeout: tFloat, waitUntil: tOptional(tType('LifecycleEvent')), }); scheme.PageReloadResult = tObject({ @@ -2425,7 +2358,6 @@ scheme.PageReloadResult = tObject({ }); scheme.PageExpectScreenshotParams = tObject({ expected: tOptional(tBinary), - timeout: tFloat, isNot: tBoolean, locator: tOptional(tObject({ frame: tChannel(['Frame']), @@ -2461,7 +2393,6 @@ scheme.PageExpectScreenshotErrorDetails = tObject({ log: tOptional(tArray(tString)), }); scheme.PageScreenshotParams = tObject({ - timeout: tFloat, type: tOptional(tEnum(['png', 'jpeg', 'webp'])), quality: tOptional(tInt), fullPage: tOptional(tBoolean), diff --git a/tests/config/debugControllerBackend.ts b/tests/config/debugControllerBackend.ts index 6246e385e0f98..46ad18ab76400 100644 --- a/tests/config/debugControllerBackend.ts +++ b/tests/config/debugControllerBackend.ts @@ -155,7 +155,7 @@ export class Backend extends EventEmitter { private _send(method: string, params: any = {}): Promise { return new Promise((fulfill, reject) => { const id = ++Backend._lastId; - const command = { id, guid: 'DebugController', method, params, metadata: {} }; + const command = { id, guid: 'DebugController', method, params, metadata: { timeout: 0 } }; this._transport.send(command as any); this._callbacks.set(id, { fulfill, reject }); }); diff --git a/utils/generate_channels.js b/utils/generate_channels.js index 8b3d08e3ad2d6..f6414e8d4723d 100755 --- a/utils/generate_channels.js +++ b/utils/generate_channels.js @@ -133,7 +133,9 @@ import type { Progress } from './progress'; ` : '') + ` import type { Binary, Channel, ${structNames.join(', ')} } from '@protocol/structs'; export type { Binary, Channel, ${structNames.join(', ')} } from '@protocol/structs'; -`]; +` + (target === 'Dispatcher' ? '' : ` +export type CommandOptions = { signal: AbortSignal | undefined, timeout: number }; +`)]; } const validator_ts = [ @@ -360,7 +362,7 @@ function generateChannels(target) { for (const derived of derivedClasses.get(channelName) || []) addScheme(`${derived}${titleCase(methodName)}ErrorDetails`, `tType('${errorDetailsName}')`); } - channels_ts.push(` ${methodName}(params: ${paramsName}, ${isDispatcher ? `progress: Progress` : `signal: AbortSignal | undefined`}): Promise<${resultName}>;`); + channels_ts.push(` ${methodName}(params: ${paramsName}, ${isDispatcher ? `progress: Progress` : `options: CommandOptions`}): Promise<${resultName}>;`); } channels_ts.push(`}`);