From 5f7739962cdbdc4d3604afe033ccd7b0b0918c3e Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 10 May 2021 16:26:11 +0200 Subject: [PATCH] chore: get rid of trailing spaces in types.d.ts (#6481) --- types/types.d.ts | 1748 ++++++++++++++++----------------- utils/generate_types/index.js | 2 + 2 files changed, 876 insertions(+), 874 deletions(-) diff --git a/types/types.d.ts b/types/types.d.ts index d464d5d94c..11b88b390a 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -29,16 +29,16 @@ type ElementHandleWaitForSelectorOptionsNotHidden = ElementHandleWaitForSelector /** * - extends: [EventEmitter] - * + * * Page provides methods to interact with a single tab in a [Browser], or an * [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One [Browser] * instance might have multiple [Page] instances. - * + * * This example creates a page, navigates it to a URL, and then saves a screenshot: - * + * * ```js * const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'. - * + * * (async () => { * const browser = await webkit.launch(); * const context = await browser.newContext(); @@ -48,19 +48,19 @@ type ElementHandleWaitForSelectorOptionsNotHidden = ElementHandleWaitForSelector * await browser.close(); * })(); * ``` - * + * * The Page class emits various events (described below) which can be handled using any of Node's native * [`EventEmitter`](https://nodejs.org/api/events.html#events_class_eventemitter) methods, such as `on`, `once` or * `removeListener`. - * + * * This example logs a message for a single page `load` event: - * + * * ```js * page.once('load', () => console.log('Page loaded!')); * ``` - * + * * To unsubscribe from events use the `removeListener` method: - * + * * ```js * function logRequest(interceptedRequest) { * console.log('A request was made:', interceptedRequest.url()); @@ -69,51 +69,51 @@ type ElementHandleWaitForSelectorOptionsNotHidden = ElementHandleWaitForSelector * // Sometime later... * page.removeListener('request', logRequest); * ``` - * + * */ export interface Page { /** * Returns the value of the `pageFunction` invocation. - * + * * If the function passed to the * [page.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevaluatepagefunction-arg) returns a * [Promise], then * [page.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevaluatepagefunction-arg) would wait * for the promise to resolve and return its value. - * + * * If the function passed to the * [page.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevaluatepagefunction-arg) returns a * non-[Serializable] value, then * [page.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevaluatepagefunction-arg) resolves * to `undefined`. Playwright also supports transferring some additional values that are not serializable by `JSON`: `-0`, * `NaN`, `Infinity`, `-Infinity`. - * + * * Passing argument to `pageFunction`: - * + * * ```js * const result = await page.evaluate(([x, y]) => { * return Promise.resolve(x * y); * }, [7, 8]); * console.log(result); // prints "56" * ``` - * + * * A string can also be passed in instead of a function: - * + * * ```js * console.log(await page.evaluate('1 + 2')); // prints "3" * const x = 10; * console.log(await page.evaluate(`1 + ${x}`)); // prints "11" * ``` - * + * * [ElementHandle] instances can be passed as an argument to the * [page.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevaluatepagefunction-arg): - * + * * ```js * const bodyHandle = await page.$('body'); * const html = await page.evaluate(([body, suffix]) => body.innerHTML + suffix, [bodyHandle, 'hello']); * await bodyHandle.dispose(); * ``` - * + * * Shortcut for main frame's * [frame.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-frame#frameevaluatepagefunction-arg). * @param pageFunction Function to be evaluated in the page context. @@ -124,41 +124,41 @@ export interface Page { /** * Returns the value of the `pageFunction` invocation as a [JSHandle]. - * + * * The only difference between * [page.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevaluatepagefunction-arg) and * [page.evaluateHandle(pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevaluatehandlepagefunction-arg) * is that * [page.evaluateHandle(pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevaluatehandlepagefunction-arg) * returns [JSHandle]. - * + * * If the function passed to the * [page.evaluateHandle(pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevaluatehandlepagefunction-arg) * returns a [Promise], then * [page.evaluateHandle(pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevaluatehandlepagefunction-arg) * would wait for the promise to resolve and return its value. - * + * * ```js * const aWindowHandle = await page.evaluateHandle(() => Promise.resolve(window)); * aWindowHandle; // Handle for the window object. * ``` - * + * * A string can also be passed in instead of a function: - * + * * ```js * const aHandle = await page.evaluateHandle('document'); // Handle for the 'document' * ``` - * + * * [JSHandle] instances can be passed as an argument to the * [page.evaluateHandle(pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevaluatehandlepagefunction-arg): - * + * * ```js * const aHandle = await page.evaluateHandle(() => document.body); * const resultHandle = await page.evaluateHandle(body => body.innerHTML, aHandle); * console.log(await resultHandle.jsonValue()); * await resultHandle.dispose(); * ``` - * + * * @param pageFunction Function to be evaluated in the page context. * @param arg Optional argument to pass to `pageFunction`. */ @@ -168,7 +168,7 @@ export interface Page { /** * The method finds an element matching the specified selector within the page. If no elements match the selector, the * return value resolves to `null`. - * + * * Shortcut for main frame's [frame.$(selector)](https://playwright.dev/docs/api/class-frame#frameselector). * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details. */ @@ -178,7 +178,7 @@ export interface Page { /** * The method finds all elements matching the specified selector within the page. If no elements match the selector, the * return value resolves to `[]`. - * + * * Shortcut for main frame's [frame.$$(selector)](https://playwright.dev/docs/api/class-frame#frameselector). * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details. */ @@ -188,19 +188,19 @@ export interface Page { /** * The method finds an element matching the specified selector within the page and passes it as a first argument to * `pageFunction`. If no elements match the selector, the method throws an error. Returns the value of `pageFunction`. - * + * * If `pageFunction` returns a [Promise], then * [page.$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevalselector-pagefunction-arg) * would wait for the promise to resolve and return its value. - * + * * Examples: - * + * * ```js * const searchValue = await page.$eval('#search', el => el.value); * const preloadHref = await page.$eval('link[rel=preload]', el => el.href); * const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello'); * ``` - * + * * Shortcut for main frame's * [frame.$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-frame#frameevalselector-pagefunction-arg). * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details. @@ -215,17 +215,17 @@ export interface Page { /** * The method finds all elements matching the specified selector within the page and passes an array of matched elements as * a first argument to `pageFunction`. Returns the result of `pageFunction` invocation. - * + * * If `pageFunction` returns a [Promise], then * [page.$$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-page#pageevalselector-pagefunction-arg) * would wait for the promise to resolve and return its value. - * + * * Examples: - * + * * ```js * const divCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10); * ``` - * + * * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param pageFunction Function to be evaluated in the page context. * @param arg Optional argument to pass to `pageFunction`. @@ -237,14 +237,14 @@ export interface Page { /** * Returns when the `pageFunction` returns a truthy value. It resolves to a JSHandle of the truthy value. - * + * * The * [page.waitForFunction(pageFunction[, arg, options])](https://playwright.dev/docs/api/class-page#pagewaitforfunctionpagefunction-arg-options) * can be used to observe viewport size change: - * + * * ```js * const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'. - * + * * (async () => { * const browser = await webkit.launch(); * const page = await browser.newPage(); @@ -254,21 +254,21 @@ export interface Page { * await browser.close(); * })(); * ``` - * + * * To pass an argument to the predicate of * [page.waitForFunction(pageFunction[, arg, options])](https://playwright.dev/docs/api/class-page#pagewaitforfunctionpagefunction-arg-options) * function: - * + * * ```js * const selector = '.foo'; * await page.waitForFunction(selector => !!document.querySelector(selector), selector); * ``` - * + * * Shortcut for main frame's * [frame.waitForFunction(pageFunction[, arg, options])](https://playwright.dev/docs/api/class-frame#framewaitforfunctionpagefunction-arg-options). * @param pageFunction Function to be evaluated in the page context. * @param arg Optional argument to pass to `pageFunction`. - * @param options + * @param options */ waitForFunction(pageFunction: PageFunction, arg: Arg, options?: PageWaitForFunctionOptions): Promise>; waitForFunction(pageFunction: PageFunction, arg?: any, options?: PageWaitForFunctionOptions): Promise>; @@ -276,16 +276,16 @@ export interface Page { /** * Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or * `detached`. - * + * * Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at * the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the * selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw. - * + * * This method works across navigations: - * + * * ```js * const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'. - * + * * (async () => { * const browser = await chromium.launch(); * const page = await browser.newPage(); @@ -297,9 +297,9 @@ export interface Page { * await browser.close(); * })(); * ``` - * + * * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details. - * @param options + * @param options */ waitForSelector(selector: K, options?: PageWaitForSelectorOptionsNotHidden): Promise>; waitForSelector(selector: string, options?: PageWaitForSelectorOptionsNotHidden): Promise>; @@ -310,23 +310,23 @@ export interface Page { * The method adds a function called `name` on the `window` object of every frame in this page. When called, the function * executes `callback` and returns a [Promise] which resolves to the return value of `callback`. If the `callback` returns * a [Promise], it will be awaited. - * + * * The first argument of the `callback` function contains information about the caller: `{ browserContext: BrowserContext, * page: Page, frame: Frame }`. - * + * * See * [browserContext.exposeBinding(name, callback[, options])](https://playwright.dev/docs/api/class-browsercontext#browsercontextexposebindingname-callback-options) * for the context-wide version. - * + * * > NOTE: Functions installed via * [page.exposeBinding(name, callback[, options])](https://playwright.dev/docs/api/class-page#pageexposebindingname-callback-options) * survive navigations. - * + * * An example of exposing page URL to all frames in a page: - * + * * ```js * const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'. - * + * * (async () => { * const browser = await webkit.launch({ headless: false }); * const context = await browser.newContext(); @@ -344,9 +344,9 @@ export interface Page { * await page.click('button'); * })(); * ``` - * + * * An example of passing an element handle: - * + * * ```js * await page.exposeBinding('clicked', async (source, element) => { * console.log(await element.textContent()); @@ -359,10 +359,10 @@ export interface Page { *
Or click me
* `); * ``` - * + * * @param name Name of the function on the window object. * @param callback Callback function that will be called in the Playwright's context. - * @param options + * @param options */ exposeBinding(name: string, playwrightBinding: (source: BindingSource, arg: JSHandle) => any, options: { handle: true }): Promise; exposeBinding(name: string, playwrightBinding: (source: BindingSource, ...args: any[]) => any, options?: { handle?: boolean }): Promise; @@ -374,11 +374,11 @@ export interface Page { /** * Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`. Also * emitted if the page throws an error or a warning. - * + * * The arguments passed into `console.log` appear as arguments on the event handler. - * + * * An example of handling `console` event: - * + * * ```js * page.on('console', async msg => { * for (let i = 0; i < msg.args().length; ++i) @@ -386,16 +386,16 @@ export interface Page { * }); * await page.evaluate(() => console.log('hello', 5, {foo: 'bar'})); * ``` - * + * */ on(event: 'console', listener: (consoleMessage: ConsoleMessage) => void): this; /** * Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page crashes, * ongoing and subsequent operations will throw. - * + * * The most common way to deal with crashes is to catch an exception: - * + * * ```js * try { * // Crash might happen during a click. @@ -406,7 +406,7 @@ export interface Page { * // When the page crashes, exception message contains 'crash'. * } * ``` - * + * */ on(event: 'crash', listener: (page: Page) => void): this; @@ -416,7 +416,7 @@ export interface Page { * [dialog.dismiss()](https://playwright.dev/docs/api/class-dialog#dialogdismiss) the dialog - otherwise the page will * [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and * actions like click will never finish. - * + * * > NOTE: When no [page.on('dialog')](https://playwright.dev/docs/api/class-page#pageondialog) listeners are present, all * dialogs are automatically dismissed. */ @@ -431,7 +431,7 @@ export interface Page { /** * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed * [Download] instance. - * + * * > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the * downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not * performed and user has no access to the downloaded files. @@ -443,13 +443,13 @@ export interface Page { * respond to it via setting the input files using * [fileChooser.setFiles(files[, options])](https://playwright.dev/docs/api/class-filechooser#filechoosersetfilesfiles-options) * that can be uploaded after that. - * + * * ```js * page.on('filechooser', async (fileChooser) => { * await fileChooser.setFiles('/tmp/myfile.pdf'); * }); * ``` - * + * */ on(event: 'filechooser', listener: (fileChooser: FileChooser) => void): this; @@ -482,11 +482,11 @@ export interface Page { * Emitted when the page opens a new tab or window. This event is emitted in addition to the * [browserContext.on('page')](https://playwright.dev/docs/api/class-browsercontext#browsercontextonpage), but only for * popups relevant to this page. - * + * * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a * popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is * done and its response has started loading in the popup. - * + * * ```js * const [popup] = await Promise.all([ * page.waitForEvent('popup'), @@ -494,7 +494,7 @@ export interface Page { * ]); * console.log(await popup.evaluate('location.href')); * ``` - * + * * > NOTE: Use * [page.waitForLoadState([state, options])](https://playwright.dev/docs/api/class-page#pagewaitforloadstatestate-options) * to wait until the page gets to a particular state (you should not need it in most cases). @@ -510,7 +510,7 @@ export interface Page { /** * Emitted when a request fails, for example by timing out. - * + * * > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will * complete with [page.on('requestfinished')](https://playwright.dev/docs/api/class-page#pageonrequestfinished) event and * not with [page.on('requestfailed')](https://playwright.dev/docs/api/class-page#pageonrequestfailed). @@ -548,11 +548,11 @@ export interface Page { /** * Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`. Also * emitted if the page throws an error or a warning. - * + * * The arguments passed into `console.log` appear as arguments on the event handler. - * + * * An example of handling `console` event: - * + * * ```js * page.on('console', async msg => { * for (let i = 0; i < msg.args().length; ++i) @@ -560,16 +560,16 @@ export interface Page { * }); * await page.evaluate(() => console.log('hello', 5, {foo: 'bar'})); * ``` - * + * */ once(event: 'console', listener: (consoleMessage: ConsoleMessage) => void): this; /** * Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page crashes, * ongoing and subsequent operations will throw. - * + * * The most common way to deal with crashes is to catch an exception: - * + * * ```js * try { * // Crash might happen during a click. @@ -580,7 +580,7 @@ export interface Page { * // When the page crashes, exception message contains 'crash'. * } * ``` - * + * */ once(event: 'crash', listener: (page: Page) => void): this; @@ -590,7 +590,7 @@ export interface Page { * [dialog.dismiss()](https://playwright.dev/docs/api/class-dialog#dialogdismiss) the dialog - otherwise the page will * [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and * actions like click will never finish. - * + * * > NOTE: When no [page.on('dialog')](https://playwright.dev/docs/api/class-page#pageondialog) listeners are present, all * dialogs are automatically dismissed. */ @@ -605,7 +605,7 @@ export interface Page { /** * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed * [Download] instance. - * + * * > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the * downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not * performed and user has no access to the downloaded files. @@ -617,13 +617,13 @@ export interface Page { * respond to it via setting the input files using * [fileChooser.setFiles(files[, options])](https://playwright.dev/docs/api/class-filechooser#filechoosersetfilesfiles-options) * that can be uploaded after that. - * + * * ```js * page.on('filechooser', async (fileChooser) => { * await fileChooser.setFiles('/tmp/myfile.pdf'); * }); * ``` - * + * */ once(event: 'filechooser', listener: (fileChooser: FileChooser) => void): this; @@ -656,11 +656,11 @@ export interface Page { * Emitted when the page opens a new tab or window. This event is emitted in addition to the * [browserContext.on('page')](https://playwright.dev/docs/api/class-browsercontext#browsercontextonpage), but only for * popups relevant to this page. - * + * * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a * popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is * done and its response has started loading in the popup. - * + * * ```js * const [popup] = await Promise.all([ * page.waitForEvent('popup'), @@ -668,7 +668,7 @@ export interface Page { * ]); * console.log(await popup.evaluate('location.href')); * ``` - * + * * > NOTE: Use * [page.waitForLoadState([state, options])](https://playwright.dev/docs/api/class-page#pagewaitforloadstatestate-options) * to wait until the page gets to a particular state (you should not need it in most cases). @@ -684,7 +684,7 @@ export interface Page { /** * Emitted when a request fails, for example by timing out. - * + * * > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will * complete with [page.on('requestfinished')](https://playwright.dev/docs/api/class-page#pageonrequestfinished) event and * not with [page.on('requestfailed')](https://playwright.dev/docs/api/class-page#pageonrequestfailed). @@ -722,11 +722,11 @@ export interface Page { /** * Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`. Also * emitted if the page throws an error or a warning. - * + * * The arguments passed into `console.log` appear as arguments on the event handler. - * + * * An example of handling `console` event: - * + * * ```js * page.on('console', async msg => { * for (let i = 0; i < msg.args().length; ++i) @@ -734,16 +734,16 @@ export interface Page { * }); * await page.evaluate(() => console.log('hello', 5, {foo: 'bar'})); * ``` - * + * */ addListener(event: 'console', listener: (consoleMessage: ConsoleMessage) => void): this; /** * Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page crashes, * ongoing and subsequent operations will throw. - * + * * The most common way to deal with crashes is to catch an exception: - * + * * ```js * try { * // Crash might happen during a click. @@ -754,7 +754,7 @@ export interface Page { * // When the page crashes, exception message contains 'crash'. * } * ``` - * + * */ addListener(event: 'crash', listener: (page: Page) => void): this; @@ -764,7 +764,7 @@ export interface Page { * [dialog.dismiss()](https://playwright.dev/docs/api/class-dialog#dialogdismiss) the dialog - otherwise the page will * [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and * actions like click will never finish. - * + * * > NOTE: When no [page.on('dialog')](https://playwright.dev/docs/api/class-page#pageondialog) listeners are present, all * dialogs are automatically dismissed. */ @@ -779,7 +779,7 @@ export interface Page { /** * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed * [Download] instance. - * + * * > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the * downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not * performed and user has no access to the downloaded files. @@ -791,13 +791,13 @@ export interface Page { * respond to it via setting the input files using * [fileChooser.setFiles(files[, options])](https://playwright.dev/docs/api/class-filechooser#filechoosersetfilesfiles-options) * that can be uploaded after that. - * + * * ```js * page.on('filechooser', async (fileChooser) => { * await fileChooser.setFiles('/tmp/myfile.pdf'); * }); * ``` - * + * */ addListener(event: 'filechooser', listener: (fileChooser: FileChooser) => void): this; @@ -830,11 +830,11 @@ export interface Page { * Emitted when the page opens a new tab or window. This event is emitted in addition to the * [browserContext.on('page')](https://playwright.dev/docs/api/class-browsercontext#browsercontextonpage), but only for * popups relevant to this page. - * + * * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a * popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is * done and its response has started loading in the popup. - * + * * ```js * const [popup] = await Promise.all([ * page.waitForEvent('popup'), @@ -842,7 +842,7 @@ export interface Page { * ]); * console.log(await popup.evaluate('location.href')); * ``` - * + * * > NOTE: Use * [page.waitForLoadState([state, options])](https://playwright.dev/docs/api/class-page#pagewaitforloadstatestate-options) * to wait until the page gets to a particular state (you should not need it in most cases). @@ -858,7 +858,7 @@ export interface Page { /** * Emitted when a request fails, for example by timing out. - * + * * > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will * complete with [page.on('requestfinished')](https://playwright.dev/docs/api/class-page#pageonrequestfinished) event and * not with [page.on('requestfailed')](https://playwright.dev/docs/api/class-page#pageonrequestfailed). @@ -896,11 +896,11 @@ export interface Page { /** * Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`. Also * emitted if the page throws an error or a warning. - * + * * The arguments passed into `console.log` appear as arguments on the event handler. - * + * * An example of handling `console` event: - * + * * ```js * page.on('console', async msg => { * for (let i = 0; i < msg.args().length; ++i) @@ -908,16 +908,16 @@ export interface Page { * }); * await page.evaluate(() => console.log('hello', 5, {foo: 'bar'})); * ``` - * + * */ removeListener(event: 'console', listener: (consoleMessage: ConsoleMessage) => void): this; /** * Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page crashes, * ongoing and subsequent operations will throw. - * + * * The most common way to deal with crashes is to catch an exception: - * + * * ```js * try { * // Crash might happen during a click. @@ -928,7 +928,7 @@ export interface Page { * // When the page crashes, exception message contains 'crash'. * } * ``` - * + * */ removeListener(event: 'crash', listener: (page: Page) => void): this; @@ -938,7 +938,7 @@ export interface Page { * [dialog.dismiss()](https://playwright.dev/docs/api/class-dialog#dialogdismiss) the dialog - otherwise the page will * [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and * actions like click will never finish. - * + * * > NOTE: When no [page.on('dialog')](https://playwright.dev/docs/api/class-page#pageondialog) listeners are present, all * dialogs are automatically dismissed. */ @@ -953,7 +953,7 @@ export interface Page { /** * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed * [Download] instance. - * + * * > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the * downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not * performed and user has no access to the downloaded files. @@ -965,13 +965,13 @@ export interface Page { * respond to it via setting the input files using * [fileChooser.setFiles(files[, options])](https://playwright.dev/docs/api/class-filechooser#filechoosersetfilesfiles-options) * that can be uploaded after that. - * + * * ```js * page.on('filechooser', async (fileChooser) => { * await fileChooser.setFiles('/tmp/myfile.pdf'); * }); * ``` - * + * */ removeListener(event: 'filechooser', listener: (fileChooser: FileChooser) => void): this; @@ -1004,11 +1004,11 @@ export interface Page { * Emitted when the page opens a new tab or window. This event is emitted in addition to the * [browserContext.on('page')](https://playwright.dev/docs/api/class-browsercontext#browsercontextonpage), but only for * popups relevant to this page. - * + * * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a * popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is * done and its response has started loading in the popup. - * + * * ```js * const [popup] = await Promise.all([ * page.waitForEvent('popup'), @@ -1016,7 +1016,7 @@ export interface Page { * ]); * console.log(await popup.evaluate('location.href')); * ``` - * + * * > NOTE: Use * [page.waitForLoadState([state, options])](https://playwright.dev/docs/api/class-page#pagewaitforloadstatestate-options) * to wait until the page gets to a particular state (you should not need it in most cases). @@ -1032,7 +1032,7 @@ export interface Page { /** * Emitted when a request fails, for example by timing out. - * + * * > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will * complete with [page.on('requestfinished')](https://playwright.dev/docs/api/class-page#pageonrequestfinished) event and * not with [page.on('requestfailed')](https://playwright.dev/docs/api/class-page#pageonrequestfailed). @@ -1070,11 +1070,11 @@ export interface Page { /** * Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`. Also * emitted if the page throws an error or a warning. - * + * * The arguments passed into `console.log` appear as arguments on the event handler. - * + * * An example of handling `console` event: - * + * * ```js * page.on('console', async msg => { * for (let i = 0; i < msg.args().length; ++i) @@ -1082,16 +1082,16 @@ export interface Page { * }); * await page.evaluate(() => console.log('hello', 5, {foo: 'bar'})); * ``` - * + * */ off(event: 'console', listener: (consoleMessage: ConsoleMessage) => void): this; /** * Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page crashes, * ongoing and subsequent operations will throw. - * + * * The most common way to deal with crashes is to catch an exception: - * + * * ```js * try { * // Crash might happen during a click. @@ -1102,7 +1102,7 @@ export interface Page { * // When the page crashes, exception message contains 'crash'. * } * ``` - * + * */ off(event: 'crash', listener: (page: Page) => void): this; @@ -1112,7 +1112,7 @@ export interface Page { * [dialog.dismiss()](https://playwright.dev/docs/api/class-dialog#dialogdismiss) the dialog - otherwise the page will * [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and * actions like click will never finish. - * + * * > NOTE: When no [page.on('dialog')](https://playwright.dev/docs/api/class-page#pageondialog) listeners are present, all * dialogs are automatically dismissed. */ @@ -1127,7 +1127,7 @@ export interface Page { /** * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed * [Download] instance. - * + * * > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the * downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not * performed and user has no access to the downloaded files. @@ -1139,13 +1139,13 @@ export interface Page { * respond to it via setting the input files using * [fileChooser.setFiles(files[, options])](https://playwright.dev/docs/api/class-filechooser#filechoosersetfilesfiles-options) * that can be uploaded after that. - * + * * ```js * page.on('filechooser', async (fileChooser) => { * await fileChooser.setFiles('/tmp/myfile.pdf'); * }); * ``` - * + * */ off(event: 'filechooser', listener: (fileChooser: FileChooser) => void): this; @@ -1178,11 +1178,11 @@ export interface Page { * Emitted when the page opens a new tab or window. This event is emitted in addition to the * [browserContext.on('page')](https://playwright.dev/docs/api/class-browsercontext#browsercontextonpage), but only for * popups relevant to this page. - * + * * The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a * popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is * done and its response has started loading in the popup. - * + * * ```js * const [popup] = await Promise.all([ * page.waitForEvent('popup'), @@ -1190,7 +1190,7 @@ export interface Page { * ]); * console.log(await popup.evaluate('location.href')); * ``` - * + * * > NOTE: Use * [page.waitForLoadState([state, options])](https://playwright.dev/docs/api/class-page#pagewaitforloadstatestate-options) * to wait until the page gets to a particular state (you should not need it in most cases). @@ -1206,7 +1206,7 @@ export interface Page { /** * Emitted when a request fails, for example by timing out. - * + * * > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will * complete with [page.on('requestfinished')](https://playwright.dev/docs/api/class-page#pageonrequestfinished) event and * not with [page.on('requestfailed')](https://playwright.dev/docs/api/class-page#pageonrequestfailed). @@ -1243,22 +1243,22 @@ export interface Page { * - Whenever the page is navigated. * - Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly * attached frame. - * + * * The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend * the JavaScript environment, e.g. to seed `Math.random`. - * + * * An example of overriding `Math.random` before the page loads: - * + * * ```js browser * // preload.js * Math.random = () => 42; * ``` - * + * * ```js * // In your playwright script, assuming the preload.js file is in same directory * await page.addInitScript({ path: './preload.js' }); * ``` - * + * * > NOTE: The order of evaluation of multiple scripts installed via * [browserContext.addInitScript(script[, arg])](https://playwright.dev/docs/api/class-browsercontext#browsercontextaddinitscriptscript-arg) * and [page.addInitScript(script[, arg])](https://playwright.dev/docs/api/class-page#pageaddinitscriptscript-arg) is not @@ -1282,10 +1282,10 @@ export interface Page { /** * Adds a `