diff --git a/src/rpc/channels.ts b/src/rpc/channels.ts index db071ce35d..46dfe7cf2b 100644 --- a/src/rpc/channels.ts +++ b/src/rpc/channels.ts @@ -24,10 +24,10 @@ export interface Channel extends EventEmitter { export interface BrowserTypeChannel extends Channel { - connect(params: { options: types.ConnectOptions }): Promise; - launch(params: { options?: types.LaunchOptions }): Promise; - launchServer(params: { options?: types.LaunchServerOptions }): Promise; - launchPersistentContext(params: { userDataDir: string, options?: types.LaunchOptions & types.BrowserContextOptions }): Promise; + connect(params: types.ConnectOptions): Promise; + launch(params: types.LaunchOptions): Promise; + launchServer(params: types.LaunchServerOptions): Promise; + launchPersistentContext(params: { userDataDir: string } & types.LaunchOptions & types.BrowserContextOptions): Promise; } export type BrowserTypeInitializer = { executablePath: string, @@ -51,7 +51,7 @@ export interface BrowserChannel extends Channel { on(event: 'close', callback: () => void): this; close(): Promise; - newContext(params: { options?: types.BrowserContextOptions }): Promise; + newContext(params: types.BrowserContextOptions): Promise; } export type BrowserInitializer = {}; @@ -69,7 +69,7 @@ export interface BrowserContextChannel extends Channel { close(): Promise; cookies(params: { urls: string[] }): Promise; exposeBinding(params: { name: string }): Promise; - grantPermissions(params: { permissions: string[]; options?: { origin?: string } }): Promise; + grantPermissions(params: { permissions: string[], origin?: string }): Promise; newPage(): Promise; setDefaultNavigationTimeoutNoReply(params: { timeout: number }): void; setDefaultTimeoutNoReply(params: { timeout: number }): void; @@ -113,14 +113,14 @@ export interface PageChannel extends Channel { setFileChooserInterceptedNoReply(params: { intercepted: boolean }): Promise; addInitScript(params: { source: string }): Promise; - close(params: { options?: { runBeforeUnload?: boolean } }): Promise; - emulateMedia(params: { options: { media?: 'screen' | 'print', colorScheme?: 'dark' | 'light' | 'no-preference' } }): Promise; + close(params: { runBeforeUnload?: boolean }): Promise; + emulateMedia(params: { media?: 'screen' | 'print', colorScheme?: 'dark' | 'light' | 'no-preference' }): Promise; exposeBinding(params: { name: string }): Promise; - goBack(params: { options?: types.NavigateOptions }): Promise; - goForward(params: { options?: types.NavigateOptions }): Promise; + goBack(params: types.NavigateOptions): Promise; + goForward(params: types.NavigateOptions): Promise; opener(): Promise; - reload(params: { options?: types.NavigateOptions }): Promise; - screenshot(params: { options?: types.ScreenshotOptions }): Promise; + reload(params: types.NavigateOptions): Promise; + screenshot(params: types.ScreenshotOptions): Promise; setExtraHTTPHeaders(params: { headers: types.Headers }): Promise; setNetworkInterceptionEnabled(params: { enabled: boolean }): Promise; setViewportSize(params: { viewportSize: types.Size }): Promise; @@ -129,16 +129,16 @@ export interface PageChannel extends Channel { keyboardDown(params: { key: string }): Promise; keyboardUp(params: { key: string }): Promise; keyboardInsertText(params: { text: string }): Promise; - keyboardType(params: { text: string, options?: { delay?: number } }): Promise; - keyboardPress(params: { key: string, options?: { delay?: number } }): Promise; - mouseMove(params: { x: number, y: number, options?: { steps?: number } }): Promise; - mouseDown(params: { options?: { button?: types.MouseButton, clickCount?: number } }): Promise; - mouseUp(params: { options?: { button?: types.MouseButton, clickCount?: number } }): Promise; - mouseClick(params: { x: number, y: number, options?: { delay?: number, button?: types.MouseButton, clickCount?: number } }): Promise; + keyboardType(params: { text: string, delay?: number }): Promise; + keyboardPress(params: { key: string, delay?: number }): Promise; + mouseMove(params: { x: number, y: number, steps?: number }): Promise; + mouseDown(params: { button?: types.MouseButton, clickCount?: number }): Promise; + mouseUp(params: { button?: types.MouseButton, clickCount?: number }): Promise; + mouseClick(params: { x: number, y: number, delay?: number, button?: types.MouseButton, clickCount?: number }): Promise; // A11Y - accessibilitySnapshot(params: { options: { interestingOnly?: boolean, root?: ElementHandleChannel } }): Promise; - pdf: (params: { options?: types.PDFOptions }) => Promise; + accessibilitySnapshot(params: { interestingOnly?: boolean, root?: ElementHandleChannel }): Promise; + pdf: (params: types.PDFOptions) => Promise; } export type PageInitializer = { @@ -146,41 +146,42 @@ export type PageInitializer = { viewportSize: types.Size | null }; +export type PageAttribution = { isPage?: boolean }; export interface FrameChannel extends Channel { - evalOnSelector(params: { selector: string; expression: string, isFunction: boolean, arg: any, isPage?: boolean }): Promise; - evalOnSelectorAll(params: { selector: string; expression: string, isFunction: boolean, arg: any, isPage?: boolean }): Promise; - addScriptTag(params: { options: { url?: string | undefined, path?: string | undefined, content?: string | undefined, type?: string | undefined }, isPage?: boolean }): Promise; - addStyleTag(params: { options: { url?: string | undefined, path?: string | undefined, content?: string | undefined }, isPage?: boolean }): Promise; - check(params: { selector: string, options: types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean }, isPage?: boolean }): Promise; - click(params: { selector: string, options: types.PointerActionOptions & types.MouseClickOptions & types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean }, isPage?: boolean }): Promise; + evalOnSelector(params: { selector: string; expression: string, isFunction: boolean, arg: any} & PageAttribution): Promise; + evalOnSelectorAll(params: { selector: string; expression: string, isFunction: boolean, arg: any} & PageAttribution): Promise; + addScriptTag(params: { url?: string | undefined, path?: string | undefined, content?: string | undefined, type?: string | undefined} & PageAttribution): Promise; + addStyleTag(params: { url?: string | undefined, path?: string | undefined, content?: string | undefined} & PageAttribution): Promise; + check(params: { selector: string, force?: boolean, noWaitAfter?: boolean } & types.TimeoutOptions & PageAttribution): Promise; + click(params: { selector: string, force?: boolean, noWaitAfter?: boolean } & types.PointerActionOptions & types.MouseClickOptions & types.TimeoutOptions & PageAttribution): Promise; content(): Promise; - dblclick(params: { selector: string, options: types.PointerActionOptions & types.MouseMultiClickOptions & types.TimeoutOptions & { force?: boolean }, isPage?: boolean}): Promise; - dispatchEvent(params: { selector: string, type: string, eventInit: any, options: types.TimeoutOptions, isPage?: boolean }): Promise; - evaluateExpression(params: { expression: string, isFunction: boolean, arg: any, isPage?: boolean }): Promise; - evaluateExpressionHandle(params: { expression: string, isFunction: boolean, arg: any, isPage?: boolean }): Promise; - fill(params: { selector: string, value: string, options: types.NavigatingActionWaitOptions, isPage?: boolean }): Promise; - focus(params: { selector: string, options: types.TimeoutOptions, isPage?: boolean }): Promise; + dblclick(params: { selector: string, force?: boolean } & types.PointerActionOptions & types.MouseMultiClickOptions & types.TimeoutOptions & PageAttribution): Promise; + dispatchEvent(params: { selector: string, type: string, eventInit: any } & types.TimeoutOptions & PageAttribution): Promise; + evaluateExpression(params: { expression: string, isFunction: boolean, arg: any} & PageAttribution): Promise; + evaluateExpressionHandle(params: { expression: string, isFunction: boolean, arg: any} & PageAttribution): Promise; + fill(params: { selector: string, value: string } & types.NavigatingActionWaitOptions & PageAttribution): Promise; + focus(params: { selector: string } & types.TimeoutOptions & PageAttribution): Promise; frameElement(): Promise; - getAttribute(params: { selector: string, name: string, options: types.TimeoutOptions, isPage?: boolean }): Promise; - goto(params: { url: string, options: types.GotoOptions, isPage?: boolean }): Promise; - hover(params: { selector: string, options: types.PointerActionOptions & types.TimeoutOptions & { force?: boolean }, isPage?: boolean }): Promise; - innerHTML(params: { selector: string, options: types.TimeoutOptions, isPage?: boolean }): Promise; - innerText(params: { selector: string, options: types.TimeoutOptions, isPage?: boolean }): Promise; - press(params: { selector: string, key: string, options: { delay?: number | undefined } & types.TimeoutOptions & { noWaitAfter?: boolean }, isPage?: boolean }): Promise; - querySelector(params: { selector: string, isPage?: boolean }): Promise; - querySelectorAll(params: { selector: string, isPage?: boolean }): Promise; - selectOption(params: { selector: string, values: string | ElementHandleChannel | types.SelectOption | string[] | ElementHandleChannel[] | types.SelectOption[] | null, options: types.NavigatingActionWaitOptions, isPage?: boolean }): Promise; - setContent(params: { html: string, options: types.NavigateOptions, isPage?: boolean }): Promise; - setInputFiles(params: { selector: string, files: { name: string, mimeType: string, buffer: string }[], options: types.NavigatingActionWaitOptions, isPage?: boolean }): Promise; - textContent(params: { selector: string, options: types.TimeoutOptions, isPage?: boolean }): Promise; + getAttribute(params: { selector: string, name: string } & types.TimeoutOptions & PageAttribution): Promise; + goto(params: { url: string } & types.GotoOptions & PageAttribution): Promise; + hover(params: { selector: string, force?: boolean } & types.PointerActionOptions & types.TimeoutOptions & PageAttribution): Promise; + innerHTML(params: { selector: string } & types.TimeoutOptions & PageAttribution): Promise; + innerText(params: { selector: string } & types.TimeoutOptions & PageAttribution): Promise; + press(params: { selector: string, key: string, delay?: number, noWaitAfter?: boolean } & types.TimeoutOptions & PageAttribution): Promise; + querySelector(params: { selector: string} & PageAttribution): Promise; + querySelectorAll(params: { selector: string} & PageAttribution): Promise; + selectOption(params: { selector: string, values: string | ElementHandleChannel | types.SelectOption | string[] | ElementHandleChannel[] | types.SelectOption[] | null } & types.NavigatingActionWaitOptions & PageAttribution): Promise; + setContent(params: { html: string } & types.NavigateOptions & PageAttribution): Promise; + setInputFiles(params: { selector: string, files: { name: string, mimeType: string, buffer: string }[] } & types.NavigatingActionWaitOptions & PageAttribution): Promise; + textContent(params: { selector: string } & types.TimeoutOptions & PageAttribution): Promise; title(): Promise; - type(params: { selector: string, text: string, options: { delay?: number | undefined } & types.TimeoutOptions & { noWaitAfter?: boolean }, isPage?: boolean }): Promise; - uncheck(params: { selector: string, options: types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean }, isPage?: boolean }): Promise; - waitForFunction(params: { expression: string, isFunction: boolean, arg: any; options: types.WaitForFunctionOptions, isPage?: boolean }): Promise; - waitForLoadState(params: { state: types.LifecycleEvent, options: types.TimeoutOptions, isPage?: boolean }): Promise; - waitForNavigation(params: { options: types.WaitForNavigationOptions, isPage?: boolean }): Promise; - waitForSelector(params: { selector: string, options: types.WaitForElementOptions, isPage?: boolean }): Promise; + type(params: { selector: string, text: string, delay?: number, noWaitAfter?: boolean } & types.TimeoutOptions & PageAttribution): Promise; + uncheck(params: { selector: string, force?: boolean, noWaitAfter?: boolean } & types.TimeoutOptions & PageAttribution): Promise; + waitForFunction(params: { expression: string, isFunction: boolean, arg: any } & types.WaitForFunctionOptions & PageAttribution): Promise; + waitForLoadState(params: { state: types.LifecycleEvent } & types.TimeoutOptions & PageAttribution): Promise; + waitForNavigation(params: types.WaitForNavigationOptions & PageAttribution): Promise; + waitForSelector(params: { selector: string } & types.WaitForElementOptions & PageAttribution): Promise; } export type FrameInitializer = { url: string, @@ -217,29 +218,29 @@ export interface ElementHandleChannel extends JSHandleChannel { evalOnSelector(params: { selector: string; expression: string, isFunction: boolean, arg: any }): Promise; evalOnSelectorAll(params: { selector: string; expression: string, isFunction: boolean, arg: any }): Promise; boundingBox(): Promise; - check(params: { options?: types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean } }): Promise; - click(params: { options?: types.PointerActionOptions & types.MouseClickOptions & types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean } }): Promise; + check(params: { force?: boolean } & { noWaitAfter?: boolean } & types.TimeoutOptions): Promise; + click(params: { force?: boolean, noWaitAfter?: boolean } & types.PointerActionOptions & types.MouseClickOptions & types.TimeoutOptions): Promise; contentFrame(): Promise; - dblclick(params: { options?: types.PointerActionOptions & types.MouseMultiClickOptions & types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean } }): Promise; + dblclick(params: { force?: boolean, noWaitAfter?: boolean } & types.PointerActionOptions & types.MouseMultiClickOptions & types.TimeoutOptions): Promise; dispatchEvent(params: { type: string, eventInit: any }): Promise; - fill(params: { value: string; options?: types.NavigatingActionWaitOptions }): Promise; + fill(params: { value: string } & types.NavigatingActionWaitOptions): Promise; focus(): Promise; getAttribute(params: { name: string }): Promise; - hover(params: { options?: types.PointerActionOptions & types.TimeoutOptions & { force?: boolean } }): Promise; + hover(params: { force?: boolean } & types.PointerActionOptions & types.TimeoutOptions): Promise; innerHTML(): Promise; innerText(): Promise; ownerFrame(): Promise; - press(params: { key: string; options?: { delay?: number } & types.TimeoutOptions & { noWaitAfter?: boolean } }): Promise; + press(params: { key: string, delay?: number } & types.TimeoutOptions & { noWaitAfter?: boolean }): Promise; querySelector(params: { selector: string }): Promise; querySelectorAll(params: { selector: string }): Promise; - screenshot(params: { options?: types.ElementScreenshotOptions }): Promise; - scrollIntoViewIfNeeded(params: { options?: types.TimeoutOptions }): Promise; - selectOption(params: { values: string | ElementHandleChannel | types.SelectOption | string[] | ElementHandleChannel[] | types.SelectOption[] | null; options?: types.NavigatingActionWaitOptions }): string[] | Promise; - selectText(params: { options?: types.TimeoutOptions }): Promise; - setInputFiles(params: { files: string | string[] | types.FilePayload | types.FilePayload[], options?: types.NavigatingActionWaitOptions }): Promise; + screenshot(params: types.ElementScreenshotOptions): Promise; + scrollIntoViewIfNeeded(params: types.TimeoutOptions): Promise; + selectOption(params: { values: string | ElementHandleChannel | types.SelectOption | string[] | ElementHandleChannel[] | types.SelectOption[] | null } & types.NavigatingActionWaitOptions): string[] | Promise; + selectText(params: types.TimeoutOptions): Promise; + setInputFiles(params: { files: string | string[] | types.FilePayload | types.FilePayload[] } & types.NavigatingActionWaitOptions): Promise; textContent(): Promise; - type(params: { text: string; options?: { delay?: number } & types.TimeoutOptions & { noWaitAfter?: boolean } }): Promise; - uncheck(params: { options?: types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean } }): Promise; + type(params: { text: string, delay?: number, noWaitAfter?: boolean } & types.TimeoutOptions): Promise; + uncheck(params: { force?: boolean, noWaitAfter?: boolean } & types.TimeoutOptions): Promise; } diff --git a/src/rpc/client/accessibility.ts b/src/rpc/client/accessibility.ts index adf6928dd1..9c33d8f0c0 100644 --- a/src/rpc/client/accessibility.ts +++ b/src/rpc/client/accessibility.ts @@ -28,6 +28,6 @@ export class Accessibility { snapshot(options: { interestingOnly?: boolean; root?: ElementHandle } = {}): Promise { const root = options.root ? options.root._elementChannel : undefined; - return this._channel.accessibilitySnapshot({ options: { interestingOnly: options.interestingOnly, root } }); + return this._channel.accessibilitySnapshot({ interestingOnly: options.interestingOnly, root }); } } diff --git a/src/rpc/client/browser.ts b/src/rpc/client/browser.ts index c295715def..2cfe9f4b92 100644 --- a/src/rpc/client/browser.ts +++ b/src/rpc/client/browser.ts @@ -48,7 +48,7 @@ export class Browser extends ChannelOwner { async newContext(options: types.BrowserContextOptions = {}): Promise { delete (options as any).logger; - const context = BrowserContext.from(await this._channel.newContext({ options })); + const context = BrowserContext.from(await this._channel.newContext(options)); this._contexts.add(context); context._browser = this; return context; diff --git a/src/rpc/client/browserContext.ts b/src/rpc/client/browserContext.ts index fcfeed4d61..e17af9e096 100644 --- a/src/rpc/client/browserContext.ts +++ b/src/rpc/client/browserContext.ts @@ -116,7 +116,7 @@ export class BrowserContext extends ChannelOwner { - await this._channel.grantPermissions({ permissions, options }); + await this._channel.grantPermissions({ permissions, ...options }); } async clearPermissions(): Promise { diff --git a/src/rpc/client/browserType.ts b/src/rpc/client/browserType.ts index dc3eceb7c0..4b38bf0a57 100644 --- a/src/rpc/client/browserType.ts +++ b/src/rpc/client/browserType.ts @@ -37,21 +37,21 @@ export class BrowserType extends ChannelOwner { delete (options as any).logger; - return Browser.from(await this._channel.launch({ options })); + return Browser.from(await this._channel.launch(options)); } - async launchServer(options?: types.LaunchServerOptions): Promise { + async launchServer(options: types.LaunchServerOptions = {}): Promise { delete (options as any).logger; - return BrowserServer.from(await this._channel.launchServer({ options })); + return BrowserServer.from(await this._channel.launchServer(options)); } async launchPersistentContext(userDataDir: string, options: types.LaunchOptions & types.BrowserContextOptions = {}): Promise { delete (options as any).logger; - return BrowserContext.from(await this._channel.launchPersistentContext({ userDataDir, options })); + return BrowserContext.from(await this._channel.launchPersistentContext({ userDataDir, ...options })); } async connect(options: types.ConnectOptions): Promise { delete (options as any).logger; - return Browser.from(await this._channel.connect({ options })); + return Browser.from(await this._channel.connect(options)); } } diff --git a/src/rpc/client/elementHandle.ts b/src/rpc/client/elementHandle.ts index 74032f53e5..ad614f7e0d 100644 --- a/src/rpc/client/elementHandle.ts +++ b/src/rpc/client/elementHandle.ts @@ -68,36 +68,36 @@ export class ElementHandle extends JSHandle { await this._elementChannel.dispatchEvent({ type, eventInit }); } - async scrollIntoViewIfNeeded(options?: types.TimeoutOptions) { - await this._elementChannel.scrollIntoViewIfNeeded({ options }); + async scrollIntoViewIfNeeded(options: types.TimeoutOptions = {}) { + await this._elementChannel.scrollIntoViewIfNeeded(options); } async hover(options: types.PointerActionOptions & types.PointerActionWaitOptions = {}): Promise { - await this._elementChannel.hover({ options }); + await this._elementChannel.hover(options); } async click(options: types.MouseClickOptions & types.PointerActionWaitOptions & types.NavigatingActionWaitOptions = {}): Promise { - return await this._elementChannel.click({ options }); + return await this._elementChannel.click(options); } async dblclick(options: types.MouseMultiClickOptions & types.PointerActionWaitOptions & types.NavigatingActionWaitOptions = {}): Promise { - return await this._elementChannel.dblclick({ options }); + return await this._elementChannel.dblclick(options); } async selectOption(values: string | ElementHandle | types.SelectOption | string[] | ElementHandle[] | types.SelectOption[] | null, options: types.NavigatingActionWaitOptions = {}): Promise { - return await this._elementChannel.selectOption({ values: convertSelectOptionValues(values), options }); + return await this._elementChannel.selectOption({ values: convertSelectOptionValues(values), ...options }); } async fill(value: string, options: types.NavigatingActionWaitOptions = {}): Promise { - return await this._elementChannel.fill({ value, options }); + return await this._elementChannel.fill({ value, ...options }); } async selectText(options: types.TimeoutOptions): Promise { - await this._elementChannel.selectText({ options }); + await this._elementChannel.selectText(options); } async setInputFiles(files: string | types.FilePayload | string[] | types.FilePayload[], options: types.NavigatingActionWaitOptions = {}) { - await this._elementChannel.setInputFiles({ files, options }); + await this._elementChannel.setInputFiles({ files, ...options }); } async focus(): Promise { @@ -105,27 +105,27 @@ export class ElementHandle extends JSHandle { } async type(text: string, options: { delay?: number } & types.NavigatingActionWaitOptions = {}): Promise { - await this._elementChannel.type({ text, options }); + await this._elementChannel.type({ text, ...options }); } async press(key: string, options: { delay?: number } & types.NavigatingActionWaitOptions = {}): Promise { - await this._elementChannel.press({ key, options }); + await this._elementChannel.press({ key, ...options }); } async check(options: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions = {}) { - return await this._elementChannel.check({ options }); + return await this._elementChannel.check(options); } async uncheck(options: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions = {}) { - return await this._elementChannel.uncheck({ options }); + return await this._elementChannel.uncheck(options); } async boundingBox(): Promise { return await this._elementChannel.boundingBox(); } - async screenshot(options?: types.ElementScreenshotOptions): Promise { - return Buffer.from(await this._elementChannel.screenshot({ options }), 'base64'); + async screenshot(options: types.ElementScreenshotOptions = {}): Promise { + return Buffer.from(await this._elementChannel.screenshot(options), 'base64'); } async $(selector: string): Promise | null> { diff --git a/src/rpc/client/frame.ts b/src/rpc/client/frame.ts index 931aa1f0df..940fada31e 100644 --- a/src/rpc/client/frame.ts +++ b/src/rpc/client/frame.ts @@ -60,15 +60,15 @@ export class Frame extends ChannelOwner { } async goto(url: string, options: GotoOptions = {}): Promise { - return Response.fromNullable(await this._channel.goto({ url, options, isPage: this._page!._isPageCall })); + return Response.fromNullable(await this._channel.goto({ url, ...options, isPage: this._page!._isPageCall })); } async waitForNavigation(options: types.WaitForNavigationOptions = {}): Promise { - return Response.fromNullable(await this._channel.waitForNavigation({ options, isPage: this._page!._isPageCall })); + return Response.fromNullable(await this._channel.waitForNavigation({ ...options, isPage: this._page!._isPageCall })); } async waitForLoadState(state: types.LifecycleEvent = 'load', options: types.TimeoutOptions = {}): Promise { - await this._channel.waitForLoadState({ state, options, isPage: this._page!._isPageCall }); + await this._channel.waitForLoadState({ state, ...options, isPage: this._page!._isPageCall }); } async frameElement(): Promise { @@ -94,11 +94,11 @@ export class Frame extends ChannelOwner { } async waitForSelector(selector: string, options: types.WaitForElementOptions = {}): Promise | null> { - return ElementHandle.fromNullable(await this._channel.waitForSelector({ selector, options, isPage: this._page!._isPageCall })) as ElementHandle | null; + return ElementHandle.fromNullable(await this._channel.waitForSelector({ selector, ...options, isPage: this._page!._isPageCall })) as ElementHandle | null; } async dispatchEvent(selector: string, type: string, eventInit?: any, options: types.TimeoutOptions = {}): Promise { - await this._channel.dispatchEvent({ selector, type, eventInit: serializeArgument(eventInit), options, isPage: this._page!._isPageCall }); + await this._channel.dispatchEvent({ selector, type, eventInit: serializeArgument(eventInit), ...options, isPage: this._page!._isPageCall }); } async $eval(selector: string, pageFunction: FuncOn, arg: Arg): Promise; @@ -125,7 +125,7 @@ export class Frame extends ChannelOwner { } async setContent(html: string, options: types.NavigateOptions = {}): Promise { - await this._channel.setContent({ html, options, isPage: this._page!._isPageCall }); + await this._channel.setContent({ html, ...options, isPage: this._page!._isPageCall }); } name(): string { @@ -149,72 +149,72 @@ export class Frame extends ChannelOwner { } async addScriptTag(options: { url?: string, path?: string, content?: string, type?: string }): Promise { - return ElementHandle.from(await this._channel.addScriptTag({ options, isPage: this._page!._isPageCall })); + return ElementHandle.from(await this._channel.addScriptTag({ ...options, isPage: this._page!._isPageCall })); } async addStyleTag(options: { url?: string; path?: string; content?: string; }): Promise { - return ElementHandle.from(await this._channel.addStyleTag({ options, isPage: this._page!._isPageCall })); + return ElementHandle.from(await this._channel.addStyleTag({ ...options, isPage: this._page!._isPageCall })); } async click(selector: string, options: types.MouseClickOptions & types.PointerActionWaitOptions & types.NavigatingActionWaitOptions = {}) { - return await this._channel.click({ selector, options, isPage: this._page!._isPageCall }); + return await this._channel.click({ selector, ...options, isPage: this._page!._isPageCall }); } async dblclick(selector: string, options: types.MouseMultiClickOptions & types.PointerActionWaitOptions & types.NavigatingActionWaitOptions = {}) { - return await this._channel.dblclick({ selector, options, isPage: this._page!._isPageCall }); + return await this._channel.dblclick({ selector, ...options, isPage: this._page!._isPageCall }); } async fill(selector: string, value: string, options: types.NavigatingActionWaitOptions = {}) { - return await this._channel.fill({ selector, value, options, isPage: this._page!._isPageCall }); + return await this._channel.fill({ selector, value, ...options, isPage: this._page!._isPageCall }); } async focus(selector: string, options: types.TimeoutOptions = {}) { - await this._channel.focus({ selector, options, isPage: this._page!._isPageCall }); + await this._channel.focus({ selector, ...options, isPage: this._page!._isPageCall }); } async textContent(selector: string, options: types.TimeoutOptions = {}): Promise { - return await this._channel.textContent({ selector, options, isPage: this._page!._isPageCall }); + return await this._channel.textContent({ selector, ...options, isPage: this._page!._isPageCall }); } async innerText(selector: string, options: types.TimeoutOptions = {}): Promise { - return await this._channel.innerText({ selector, options, isPage: this._page!._isPageCall }); + return await this._channel.innerText({ selector, ...options, isPage: this._page!._isPageCall }); } async innerHTML(selector: string, options: types.TimeoutOptions = {}): Promise { - return await this._channel.innerHTML({ selector, options, isPage: this._page!._isPageCall }); + return await this._channel.innerHTML({ selector, ...options, isPage: this._page!._isPageCall }); } async getAttribute(selector: string, name: string, options: types.TimeoutOptions = {}): Promise { - return await this._channel.getAttribute({ selector, name, options, isPage: this._page!._isPageCall }); + return await this._channel.getAttribute({ selector, name, ...options, isPage: this._page!._isPageCall }); } async hover(selector: string, options: types.PointerActionOptions & types.PointerActionWaitOptions = {}) { - await this._channel.hover({ selector, options, isPage: this._page!._isPageCall }); + await this._channel.hover({ selector, ...options, isPage: this._page!._isPageCall }); } async selectOption(selector: string, values: string | ElementHandle | types.SelectOption | string[] | ElementHandle[] | types.SelectOption[] | null, options: types.NavigatingActionWaitOptions = {}): Promise { - return await this._channel.selectOption({ selector, values: convertSelectOptionValues(values), options, isPage: this._page!._isPageCall }); + return await this._channel.selectOption({ selector, values: convertSelectOptionValues(values), ...options, isPage: this._page!._isPageCall }); } async setInputFiles(selector: string, files: string | types.FilePayload | string[] | types.FilePayload[], options: types.NavigatingActionWaitOptions = {}): Promise { const filePayloads = await normalizeFilePayloads(files); - await this._channel.setInputFiles({ selector, files: filePayloads.map(f => ({ name: f.name, mimeType: f.mimeType, buffer: f.buffer.toString('base64') })), options, isPage: this._page!._isPageCall }); + await this._channel.setInputFiles({ selector, files: filePayloads.map(f => ({ name: f.name, mimeType: f.mimeType, buffer: f.buffer.toString('base64') })), ...options, isPage: this._page!._isPageCall }); } async type(selector: string, text: string, options: { delay?: number } & types.NavigatingActionWaitOptions = {}) { - await this._channel.type({ selector, text, options, isPage: this._page!._isPageCall }); + await this._channel.type({ selector, text, ...options, isPage: this._page!._isPageCall }); } async press(selector: string, key: string, options: { delay?: number } & types.NavigatingActionWaitOptions = {}) { - await this._channel.press({ selector, key, options, isPage: this._page!._isPageCall }); + await this._channel.press({ selector, key, ...options, isPage: this._page!._isPageCall }); } async check(selector: string, options: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions = {}) { - await this._channel.check({ selector, options, isPage: this._page!._isPageCall }); + await this._channel.check({ selector, ...options, isPage: this._page!._isPageCall }); } async uncheck(selector: string, options: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions = {}) { - await this._channel.uncheck({ selector, options, isPage: this._page!._isPageCall }); + await this._channel.uncheck({ selector, ...options, isPage: this._page!._isPageCall }); } async waitForTimeout(timeout: number) { @@ -224,7 +224,7 @@ export class Frame extends ChannelOwner { async waitForFunction(pageFunction: Func1, arg: Arg, options?: types.WaitForFunctionOptions): Promise>; async waitForFunction(pageFunction: Func1, arg?: any, options?: types.WaitForFunctionOptions): Promise>; async waitForFunction(pageFunction: Func1, arg: Arg, options: types.WaitForFunctionOptions = {}): Promise> { - return JSHandle.from(await this._channel.waitForFunction({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg), options, isPage: this._page!._isPageCall })) as SmartHandle; + return JSHandle.from(await this._channel.waitForFunction({ expression: String(pageFunction), isFunction: typeof pageFunction === 'function', arg: serializeArgument(arg), ...options, isPage: this._page!._isPageCall })) as SmartHandle; } async title(): Promise { diff --git a/src/rpc/client/input.ts b/src/rpc/client/input.ts index 8519133f46..f3b2b35bce 100644 --- a/src/rpc/client/input.ts +++ b/src/rpc/client/input.ts @@ -38,11 +38,11 @@ export class Keyboard { } async type(text: string, options: { delay?: number } = {}) { - await this._channel.keyboardType({ text, options }); + await this._channel.keyboardType({ text, ...options }); } async press(key: string, options: { delay?: number } = {}) { - await this._channel.keyboardPress({ key, options }); + await this._channel.keyboardPress({ key, ...options }); } } @@ -54,19 +54,19 @@ export class Mouse { } async move(x: number, y: number, options: { steps?: number } = {}) { - await this._channel.mouseMove({ x, y, options }); + await this._channel.mouseMove({ x, y, ...options }); } async down(options: { button?: types.MouseButton, clickCount?: number } = {}) { - await this._channel.mouseDown({ options }); + await this._channel.mouseDown({ ...options }); } async up(options: { button?: types.MouseButton, clickCount?: number } = {}) { - await this._channel.mouseUp({ options }); + await this._channel.mouseUp(options); } async click(x: number, y: number, options: { delay?: number, button?: types.MouseButton, clickCount?: number } = {}) { - await this._channel.mouseClick({ x, y, options }); + await this._channel.mouseClick({ x, y, ...options }); } async dblclick(x: number, y: number, options: { delay?: number, button?: types.MouseButton } = {}) { diff --git a/src/rpc/client/page.ts b/src/rpc/client/page.ts index ebc5a087b9..eb3331ba4d 100644 --- a/src/rpc/client/page.ts +++ b/src/rpc/client/page.ts @@ -303,8 +303,8 @@ export class Page extends ChannelOwner { return this._attributeToPage(() => this._mainFrame.goto(url, options)); } - async reload(options?: types.NavigateOptions): Promise { - return Response.fromNullable(await this._channel.reload({ options })); + async reload(options: types.NavigateOptions = {}): Promise { + return Response.fromNullable(await this._channel.reload(options)); } async waitForLoadState(state?: types.LifecycleEvent, options?: types.TimeoutOptions): Promise { @@ -343,16 +343,16 @@ export class Page extends ChannelOwner { return result; } - async goBack(options?: types.NavigateOptions): Promise { - return Response.fromNullable(await this._channel.goBack({ options })); + async goBack(options: types.NavigateOptions = {}): Promise { + return Response.fromNullable(await this._channel.goBack(options)); } - async goForward(options?: types.NavigateOptions): Promise { - return Response.fromNullable(await this._channel.goForward({ options })); + async goForward(options: types.NavigateOptions = {}): Promise { + return Response.fromNullable(await this._channel.goForward(options)); } async emulateMedia(options: { media?: types.MediaType, colorScheme?: types.ColorScheme }) { - await this._channel.emulateMedia({ options }); + await this._channel.emulateMedia(options); } async setViewportSize(viewportSize: types.Size) { @@ -388,8 +388,8 @@ export class Page extends ChannelOwner { await this._channel.setNetworkInterceptionEnabled({ enabled: false }); } - async screenshot(options?: types.ScreenshotOptions): Promise { - return Buffer.from(await this._channel.screenshot({ options }), 'base64'); + async screenshot(options: types.ScreenshotOptions = {}): Promise { + return Buffer.from(await this._channel.screenshot(options), 'base64'); } async title(): Promise { @@ -397,7 +397,7 @@ export class Page extends ChannelOwner { } async close(options: { runBeforeUnload?: boolean } = {runBeforeUnload: undefined}) { - await this._channel.close({ options }); + await this._channel.close(options); if (this._ownedContext) await this._ownedContext.close(); } @@ -496,8 +496,8 @@ export class Page extends ChannelOwner { return this; } - async pdf(options?: types.PDFOptions): Promise { - const binary = await this._channel.pdf({ options }); + async pdf(options: types.PDFOptions = {}): Promise { + const binary = await this._channel.pdf(options); return Buffer.from(binary, 'base64'); } } diff --git a/src/rpc/server/browserDispatcher.ts b/src/rpc/server/browserDispatcher.ts index 2dcadfa84b..826a77f2f4 100644 --- a/src/rpc/server/browserDispatcher.ts +++ b/src/rpc/server/browserDispatcher.ts @@ -31,8 +31,8 @@ export class BrowserDispatcher extends Dispatcher i }); } - async newContext(params: { options?: types.BrowserContextOptions }): Promise { - return new BrowserContextDispatcher(this._scope, await this._object.newContext(params.options) as BrowserContextBase); + async newContext(params: types.BrowserContextOptions): Promise { + return new BrowserContextDispatcher(this._scope, await this._object.newContext(params) as BrowserContextBase); } async close(): Promise { diff --git a/src/rpc/server/browserTypeDispatcher.ts b/src/rpc/server/browserTypeDispatcher.ts index 1a2bbf975d..91bb05f48f 100644 --- a/src/rpc/server/browserTypeDispatcher.ts +++ b/src/rpc/server/browserTypeDispatcher.ts @@ -32,22 +32,22 @@ export class BrowserTypeDispatcher extends Dispatcher { - const browser = await this._object.launch(params.options || undefined); + async launch(params: types.LaunchOptions): Promise { + const browser = await this._object.launch(params); return new BrowserDispatcher(this._scope, browser as BrowserBase); } - async launchPersistentContext(params: { userDataDir: string, options?: types.LaunchOptions & types.BrowserContextOptions }): Promise { - const browserContext = await this._object.launchPersistentContext(params.userDataDir, params.options); + async launchPersistentContext(params: { userDataDir: string } & types.LaunchOptions & types.BrowserContextOptions): Promise { + const browserContext = await this._object.launchPersistentContext(params.userDataDir, params); return new BrowserContextDispatcher(this._scope, browserContext as BrowserContextBase); } - async launchServer(params: { options?: types.LaunchServerOptions }): Promise { - return new BrowserServerDispatcher(this._scope, await this._object.launchServer(params.options)); + async launchServer(params: types.LaunchServerOptions): Promise { + return new BrowserServerDispatcher(this._scope, await this._object.launchServer(params)); } - async connect(params: { options: types.ConnectOptions }): Promise { - const browser = await this._object.connect(params.options); + async connect(params: types.ConnectOptions): Promise { + const browser = await this._object.connect(params); return new BrowserDispatcher(this._scope, browser as BrowserBase); } } diff --git a/src/rpc/server/elementHandlerDispatcher.ts b/src/rpc/server/elementHandlerDispatcher.ts index 2adc083cf8..0a09ec59e0 100644 --- a/src/rpc/server/elementHandlerDispatcher.ts +++ b/src/rpc/server/elementHandlerDispatcher.ts @@ -69,64 +69,64 @@ export class ElementHandleDispatcher extends JSHandleDispatcher implements Eleme await this._elementHandle.dispatchEvent(params.type, params.eventInit); } - async scrollIntoViewIfNeeded(params: { options?: types.TimeoutOptions }) { - await this._elementHandle.scrollIntoViewIfNeeded(params.options); + async scrollIntoViewIfNeeded(params: types.TimeoutOptions) { + await this._elementHandle.scrollIntoViewIfNeeded(params); } - async hover(params: { options?: types.PointerActionOptions & types.PointerActionWaitOptions }) { - await this._elementHandle.hover(params.options); + async hover(params: types.PointerActionOptions & types.PointerActionWaitOptions) { + await this._elementHandle.hover(params); } - async click(params: { options?: types.MouseClickOptions & types.PointerActionWaitOptions & types.NavigatingActionWaitOptions }) { - await this._elementHandle.click(params.options); + async click(params: types.MouseClickOptions & types.PointerActionWaitOptions & types.NavigatingActionWaitOptions) { + await this._elementHandle.click(params); } - async dblclick(params: { options?: types.MouseMultiClickOptions & types.PointerActionWaitOptions & types.NavigatingActionWaitOptions }) { - await this._elementHandle.dblclick(params.options); + async dblclick(params: types.MouseMultiClickOptions & types.PointerActionWaitOptions & types.NavigatingActionWaitOptions) { + await this._elementHandle.dblclick(params); } - async selectOption(params: { values: string | ElementHandleChannel | types.SelectOption | string[] | ElementHandleChannel[] | types.SelectOption[] | null, options: types.NavigatingActionWaitOptions }): Promise { - return this._elementHandle.selectOption(convertSelectOptionValues(params.values), params.options); + async selectOption(params: { values: string | ElementHandleChannel | types.SelectOption | string[] | ElementHandleChannel[] | types.SelectOption[] | null } & types.NavigatingActionWaitOptions): Promise { + return this._elementHandle.selectOption(convertSelectOptionValues(params.values), params); } - async fill(params: { value: string, options: types.NavigatingActionWaitOptions }) { - await this._elementHandle.fill(params.value, params.options); + async fill(params: { value: string } & types.NavigatingActionWaitOptions) { + await this._elementHandle.fill(params.value, params); } - async selectText(params: { options?: types.TimeoutOptions }) { - await this._elementHandle.selectText(params.options); + async selectText(params: types.TimeoutOptions) { + await this._elementHandle.selectText(params); } - async setInputFiles(params: { files: string | types.FilePayload | string[] | types.FilePayload[], options?: types.NavigatingActionWaitOptions }) { - await this._elementHandle.setInputFiles(params.files, params.options); + async setInputFiles(params: { files: string | types.FilePayload | string[] | types.FilePayload[] } & types.NavigatingActionWaitOptions) { + await this._elementHandle.setInputFiles(params.files, params); } async focus() { await this._elementHandle.focus(); } - async type(params: { text: string, options: { delay?: number } & types.NavigatingActionWaitOptions }) { - await this._elementHandle.type(params.text, params.options); + async type(params: { text: string } & { delay?: number } & types.NavigatingActionWaitOptions) { + await this._elementHandle.type(params.text, params); } - async press(params: { key: string, options: { delay?: number } & types.NavigatingActionWaitOptions }) { - await this._elementHandle.press(params.key, params.options); + async press(params: { key: string } & { delay?: number } & types.NavigatingActionWaitOptions) { + await this._elementHandle.press(params.key, params); } - async check(params: { options?: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions }) { - await this._elementHandle.check(params.options); + async check(params: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions) { + await this._elementHandle.check(params); } - async uncheck(params: { options?: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions }) { - await this._elementHandle.uncheck(params.options); + async uncheck(params: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions) { + await this._elementHandle.uncheck(params); } async boundingBox(): Promise { return await this._elementHandle.boundingBox(); } - async screenshot(params: { options?: types.ElementScreenshotOptions }): Promise { - return (await this._elementHandle.screenshot(params.options)).toString('base64'); + async screenshot(params: types.ElementScreenshotOptions): Promise { + return (await this._elementHandle.screenshot(params)).toString('base64'); } async querySelector(params: { selector: string }): Promise { diff --git a/src/rpc/server/frameDispatcher.ts b/src/rpc/server/frameDispatcher.ts index b305a264c5..4244d9c896 100644 --- a/src/rpc/server/frameDispatcher.ts +++ b/src/rpc/server/frameDispatcher.ts @@ -16,7 +16,7 @@ import { Frame } from '../../frames'; import * as types from '../../types'; -import { ElementHandleChannel, FrameChannel, FrameInitializer, JSHandleChannel, ResponseChannel } from '../channels'; +import { ElementHandleChannel, FrameChannel, FrameInitializer, JSHandleChannel, ResponseChannel, PageAttribution } from '../channels'; import { Dispatcher, DispatcherScope, lookupNullableDispatcher, existingDispatcher } from './dispatcher'; import { convertSelectOptionValues, ElementHandleDispatcher, createHandle } from './elementHandlerDispatcher'; import { parseArgument, serializeResult } from './jsHandleDispatcher'; @@ -39,61 +39,61 @@ export class FrameDispatcher extends Dispatcher impleme this._frame = frame; } - async goto(params: { url: string, options: types.GotoOptions, isPage?: boolean }): Promise { + async goto(params: { url: string } & types.GotoOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - return lookupNullableDispatcher(await target.goto(params.url, params.options)); + return lookupNullableDispatcher(await target.goto(params.url, params)); } - async waitForLoadState(params: { state?: 'load' | 'domcontentloaded' | 'networkidle', options?: types.TimeoutOptions, isPage?: boolean }): Promise { + async waitForLoadState(params: { state?: 'load' | 'domcontentloaded' | 'networkidle' } & types.TimeoutOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - await target.waitForLoadState(params.state, params.options); + await target.waitForLoadState(params.state, params); } - async waitForNavigation(params: { options?: types.WaitForNavigationOptions, isPage?: boolean }): Promise { + async waitForNavigation(params: types.WaitForNavigationOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - return lookupNullableDispatcher(await target.waitForNavigation(params.options)); + return lookupNullableDispatcher(await target.waitForNavigation(params)); } async frameElement(): Promise { return new ElementHandleDispatcher(this._scope, await this._frame.frameElement()); } - async evaluateExpression(params: { expression: string, isFunction: boolean, arg: any, isPage?: boolean }): Promise { + async evaluateExpression(params: { expression: string, isFunction: boolean, arg: any } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; return serializeResult(await target._evaluateExpression(params.expression, params.isFunction, parseArgument(params.arg))); } - async evaluateExpressionHandle(params: { expression: string, isFunction: boolean, arg: any, isPage?: boolean }): Promise { + async evaluateExpressionHandle(params: { expression: string, isFunction: boolean, arg: any } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; return createHandle(this._scope, await target._evaluateExpressionHandle(params.expression, params.isFunction, parseArgument(params.arg))); } - async waitForSelector(params: { selector: string, options: types.WaitForElementOptions, isPage?: boolean }): Promise { + async waitForSelector(params: { selector: string } & types.WaitForElementOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - return ElementHandleDispatcher.createNullable(this._scope, await target.waitForSelector(params.selector, params.options)); + return ElementHandleDispatcher.createNullable(this._scope, await target.waitForSelector(params.selector, params)); } - async dispatchEvent(params: { selector: string, type: string, eventInit: any, options: types.TimeoutOptions, isPage?: boolean }): Promise { + async dispatchEvent(params: { selector: string, type: string, eventInit: any } & types.TimeoutOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - return target.dispatchEvent(params.selector, params.type, parseArgument(params.eventInit), params.options); + return target.dispatchEvent(params.selector, params.type, parseArgument(params.eventInit), params); } - async evalOnSelector(params: { selector: string, expression: string, isFunction: boolean, arg: any, isPage?: boolean }): Promise { + async evalOnSelector(params: { selector: string, expression: string, isFunction: boolean, arg: any } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; return serializeResult(await target._$evalExpression(params.selector, params.expression, params.isFunction, parseArgument(params.arg))); } - async evalOnSelectorAll(params: { selector: string, expression: string, isFunction: boolean, arg: any, isPage?: boolean }): Promise { + async evalOnSelectorAll(params: { selector: string, expression: string, isFunction: boolean, arg: any } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; return serializeResult(await target._$$evalExpression(params.selector, params.expression, params.isFunction, parseArgument(params.arg))); } - async querySelector(params: { selector: string, isPage?: boolean }): Promise { + async querySelector(params: { selector: string } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; return ElementHandleDispatcher.createNullable(this._scope, await target.$(params.selector)); } - async querySelectorAll(params: { selector: string, isPage?: boolean }): Promise { + async querySelectorAll(params: { selector: string } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; const elements = await target.$$(params.selector); return elements.map(e => new ElementHandleDispatcher(this._scope, e)); @@ -103,99 +103,99 @@ export class FrameDispatcher extends Dispatcher impleme return await this._frame.content(); } - async setContent(params: { html: string, options: types.NavigateOptions, isPage?: boolean }): Promise { + async setContent(params: { html: string } & types.NavigateOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - await target.setContent(params.html, params.options); + await target.setContent(params.html, params); } - async addScriptTag(params: { options: { url?: string | undefined, path?: string | undefined, content?: string | undefined, type?: string | undefined }, isPage?: boolean }): Promise { + async addScriptTag(params: { url?: string | undefined, path?: string | undefined, content?: string | undefined, type?: string | undefined } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - return new ElementHandleDispatcher(this._scope, await target.addScriptTag(params.options)); + return new ElementHandleDispatcher(this._scope, await target.addScriptTag(params)); } - async addStyleTag(params: { options: { url?: string | undefined, path?: string | undefined, content?: string | undefined }, isPage?: boolean }): Promise { + async addStyleTag(params: { url?: string | undefined, path?: string | undefined, content?: string | undefined } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - return new ElementHandleDispatcher(this._scope, await target.addStyleTag(params.options)); + return new ElementHandleDispatcher(this._scope, await target.addStyleTag(params)); } - async click(params: { selector: string, options: types.PointerActionOptions & types.MouseClickOptions & types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean }, isPage?: boolean }): Promise { + async click(params: { selector: string } & types.PointerActionOptions & types.MouseClickOptions & types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - await target.click(params.selector, params.options); + await target.click(params.selector, params); } - async dblclick(params: { selector: string, options: types.PointerActionOptions & types.MouseMultiClickOptions & types.TimeoutOptions & { force?: boolean }, isPage?: boolean }): Promise { + async dblclick(params: { selector: string } & types.PointerActionOptions & types.MouseMultiClickOptions & types.TimeoutOptions & { force?: boolean } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - await target.dblclick(params.selector, params.options); + await target.dblclick(params.selector, params); } - async fill(params: { selector: string, value: string, options: types.NavigatingActionWaitOptions, isPage?: boolean }): Promise { + async fill(params: { selector: string, value: string } & types.NavigatingActionWaitOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - await target.fill(params.selector, params.value, params.options); + await target.fill(params.selector, params.value, params); } - async focus(params: { selector: string, options: types.TimeoutOptions, isPage?: boolean }): Promise { + async focus(params: { selector: string } & types.TimeoutOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - await target.focus(params.selector, params.options); + await target.focus(params.selector, params); } - async textContent(params: { selector: string, options: types.TimeoutOptions, isPage?: boolean }): Promise { + async textContent(params: { selector: string } & types.TimeoutOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - return await target.textContent(params.selector, params.options); + return await target.textContent(params.selector, params); } - async innerText(params: { selector: string, options: types.TimeoutOptions, isPage?: boolean }): Promise { + async innerText(params: { selector: string } & types.TimeoutOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - return await target.innerText(params.selector, params.options); + return await target.innerText(params.selector, params); } - async innerHTML(params: { selector: string, options: types.TimeoutOptions, isPage?: boolean }): Promise { + async innerHTML(params: { selector: string } & types.TimeoutOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - return await target.innerHTML(params.selector, params.options); + return await target.innerHTML(params.selector, params); } - async getAttribute(params: { selector: string, name: string, options: types.TimeoutOptions, isPage?: boolean }): Promise { + async getAttribute(params: { selector: string, name: string } & types.TimeoutOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - return await target.getAttribute(params.selector, params.name, params.options); + return await target.getAttribute(params.selector, params.name, params); } - async hover(params: { selector: string, options: types.PointerActionOptions & types.TimeoutOptions & { force?: boolean }, isPage?: boolean }): Promise { + async hover(params: { selector: string } & types.PointerActionOptions & types.TimeoutOptions & { force?: boolean } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - await target.hover(params.selector, params.options); + await target.hover(params.selector, params); } - async selectOption(params: { selector: string, values: string | ElementHandleChannel | types.SelectOption | string[] | ElementHandleChannel[] | types.SelectOption[] | null, options: types.NavigatingActionWaitOptions, isPage?: boolean }): Promise { + async selectOption(params: { selector: string, values: string | ElementHandleChannel | types.SelectOption | string[] | ElementHandleChannel[] | types.SelectOption[] | null } & types.NavigatingActionWaitOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - return target.selectOption(params.selector, convertSelectOptionValues(params.values), params.options); + return target.selectOption(params.selector, convertSelectOptionValues(params.values), params); } - async setInputFiles(params: { selector: string, files: { name: string, mimeType: string, buffer: string }[], options: types.NavigatingActionWaitOptions, isPage?: boolean }): Promise { + async setInputFiles(params: { selector: string, files: { name: string, mimeType: string, buffer: string }[] } & types.NavigatingActionWaitOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - await target.setInputFiles(params.selector, params.files.map(f => ({ name: f.name, mimeType: f.mimeType, buffer: Buffer.from(f.buffer, 'base64') })), params.options); + await target.setInputFiles(params.selector, params.files.map(f => ({ name: f.name, mimeType: f.mimeType, buffer: Buffer.from(f.buffer, 'base64') })), params); } - async type(params: { selector: string, text: string, options: { delay?: number | undefined } & types.TimeoutOptions & { noWaitAfter?: boolean }, isPage?: boolean }): Promise { + async type(params: { selector: string, text: string } & { delay?: number | undefined } & types.TimeoutOptions & { noWaitAfter?: boolean } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - await target.type(params.selector, params.text, params.options); + await target.type(params.selector, params.text, params); } - async press(params: { selector: string, key: string, options: { delay?: number | undefined } & types.TimeoutOptions & { noWaitAfter?: boolean }, isPage?: boolean }): Promise { + async press(params: { selector: string, key: string } & { delay?: number | undefined } & types.TimeoutOptions & { noWaitAfter?: boolean } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - await target.press(params.selector, params.key, params.options); + await target.press(params.selector, params.key, params); } - async check(params: { selector: string, options: types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean }, isPage?: boolean }): Promise { + async check(params: { selector: string } & types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - await target.check(params.selector, params.options); + await target.check(params.selector, params); } - async uncheck(params: { selector: string, options: types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean }, isPage?: boolean }): Promise { + async uncheck(params: { selector: string } & types.TimeoutOptions & { force?: boolean } & { noWaitAfter?: boolean } & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - await target.uncheck(params.selector, params.options); + await target.uncheck(params.selector, params); } - async waitForFunction(params: { expression: string, isFunction: boolean, arg: any; options: types.WaitForFunctionOptions, isPage?: boolean }): Promise { + async waitForFunction(params: { expression: string, isFunction: boolean, arg: any } & types.WaitForFunctionOptions & PageAttribution): Promise { const target = params.isPage ? this._frame._page : this._frame; - return createHandle(this._scope, await target._waitForFunctionExpression(params.expression, params.isFunction, parseArgument(params.arg), params.options)); + return createHandle(this._scope, await target._waitForFunctionExpression(params.expression, params.isFunction, parseArgument(params.arg), params)); } async title(): Promise { diff --git a/src/rpc/server/pageDispatcher.ts b/src/rpc/server/pageDispatcher.ts index 4c565b44b4..d51f1e1516 100644 --- a/src/rpc/server/pageDispatcher.ts +++ b/src/rpc/server/pageDispatcher.ts @@ -91,20 +91,20 @@ export class PageDispatcher extends Dispatcher implements await this._page.setExtraHTTPHeaders(params.headers); } - async reload(params: { options?: types.NavigateOptions }): Promise { - return lookupNullableDispatcher(await this._page.reload(params.options)); + async reload(params: types.NavigateOptions): Promise { + return lookupNullableDispatcher(await this._page.reload(params)); } - async goBack(params: { options?: types.NavigateOptions }): Promise { - return lookupNullableDispatcher(await this._page.goBack(params.options)); + async goBack(params: types.NavigateOptions): Promise { + return lookupNullableDispatcher(await this._page.goBack(params)); } - async goForward(params: { options?: types.NavigateOptions }): Promise { - return lookupNullableDispatcher(await this._page.goForward(params.options)); + async goForward(params: types.NavigateOptions): Promise { + return lookupNullableDispatcher(await this._page.goForward(params)); } - async emulateMedia(params: { options: { media?: 'screen' | 'print', colorScheme?: 'dark' | 'light' | 'no-preference' } }): Promise { - await this._page.emulateMedia(params.options); + async emulateMedia(params: { media?: 'screen' | 'print', colorScheme?: 'dark' | 'light' | 'no-preference' }): Promise { + await this._page.emulateMedia(params); } async setViewportSize(params: { viewportSize: types.Size }): Promise { @@ -125,12 +125,12 @@ export class PageDispatcher extends Dispatcher implements }); } - async screenshot(params: { options?: types.ScreenshotOptions }): Promise { - return (await this._page.screenshot(params.options)).toString('base64'); + async screenshot(params: types.ScreenshotOptions): Promise { + return (await this._page.screenshot(params)).toString('base64'); } - async close(params: { options?: { runBeforeUnload?: boolean } }): Promise { - await this._page.close(params.options); + async close(params: { runBeforeUnload?: boolean }): Promise { + await this._page.close(params); } async setFileChooserInterceptedNoReply(params: { intercepted: boolean }) { @@ -152,41 +152,41 @@ export class PageDispatcher extends Dispatcher implements await this._page.keyboard.insertText(params.text); } - async keyboardType(params: { text: string, options?: { delay?: number } }): Promise { - await this._page.keyboard.type(params.text, params.options); + async keyboardType(params: { text: string, delay?: number }): Promise { + await this._page.keyboard.type(params.text, params); } - async keyboardPress(params: { key: string, options?: { delay?: number } }): Promise { - await this._page.keyboard.press(params.key, params.options); + async keyboardPress(params: { key: string, delay?: number }): Promise { + await this._page.keyboard.press(params.key, params); } - async mouseMove(params: { x: number, y: number, options?: { steps?: number } }): Promise { - await this._page.mouse.move(params.x, params.y, params.options); + async mouseMove(params: { x: number, y: number, steps?: number }): Promise { + await this._page.mouse.move(params.x, params.y, params); } - async mouseDown(params: { options?: { button?: types.MouseButton, clickCount?: number } }): Promise { - await this._page.mouse.down(params.options); + async mouseDown(params: { button?: types.MouseButton, clickCount?: number }): Promise { + await this._page.mouse.down(params); } - async mouseUp(params: { options?: { button?: types.MouseButton, clickCount?: number } }): Promise { - await this._page.mouse.up(params.options); + async mouseUp(params: { button?: types.MouseButton, clickCount?: number }): Promise { + await this._page.mouse.up(params); } - async mouseClick(params: { x: number, y: number, options?: { delay?: number, button?: types.MouseButton, clickCount?: number } }): Promise { - await this._page.mouse.click(params.x, params.y, params.options); + async mouseClick(params: { x: number, y: number, delay?: number, button?: types.MouseButton, clickCount?: number }): Promise { + await this._page.mouse.click(params.x, params.y, params); } - async accessibilitySnapshot(params: { options: { interestingOnly?: boolean, root?: ElementHandleChannel } }): Promise { + async accessibilitySnapshot(params: { interestingOnly?: boolean, root?: ElementHandleChannel }): Promise { return await this._page.accessibility.snapshot({ - interestingOnly: params.options.interestingOnly, - root: params.options.root ? (params.options.root as ElementHandleDispatcher)._elementHandle : undefined + interestingOnly: params.interestingOnly, + root: params.root ? (params.root as ElementHandleDispatcher)._elementHandle : undefined }); } - async pdf(params: { options?: types.PDFOptions }): Promise { + async pdf(params: types.PDFOptions): Promise { if (!this._page.pdf) throw new Error('PDF generation is only supported for Headless Chromium'); - const binary = await this._page.pdf(params.options); + const binary = await this._page.pdf(params); return binary.toString('base64'); }