mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: update Prettier and other deps (#10555)
This commit is contained in:
parent
cdd310fe5e
commit
de09b058ba
@ -44,3 +44,5 @@ yarn-error.log*
|
||||
# ESLint ignores.
|
||||
assets/
|
||||
third_party/
|
||||
sandbox/
|
||||
ng-schematics/src/**/files/
|
||||
|
@ -1,4 +1,5 @@
|
||||
const prettier = require('prettier');
|
||||
const prettier = require('@prettier/sync');
|
||||
const prettierConfig = require('./.prettierrc.cjs');
|
||||
|
||||
const cleanupBlockComment = value => {
|
||||
return value
|
||||
@ -18,12 +19,13 @@ const cleanupBlockComment = value => {
|
||||
.trim();
|
||||
};
|
||||
|
||||
const format = (value, offset, prettierOptions) => {
|
||||
const format = (value, offset) => {
|
||||
return prettier
|
||||
.format(value, {
|
||||
...prettierOptions,
|
||||
...prettierConfig,
|
||||
parser: 'markdown',
|
||||
// This is the print width minus 3 (the length of ` * `) and the offset.
|
||||
printWidth: prettierOptions.printWidth - (offset + 3),
|
||||
printWidth: 80 - (offset + 3),
|
||||
})
|
||||
.trim();
|
||||
};
|
||||
@ -57,17 +59,12 @@ const rule = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const prettierOptions = {
|
||||
printWidth: 80,
|
||||
...prettier.resolveConfig.sync(context.getPhysicalFilename()),
|
||||
parser: 'markdown',
|
||||
};
|
||||
for (const comment of context.getSourceCode().getAllComments()) {
|
||||
for (const comment of context.sourceCode.getAllComments()) {
|
||||
switch (comment.type) {
|
||||
case 'Block': {
|
||||
const offset = comment.loc.start.column;
|
||||
const value = cleanupBlockComment(comment.value);
|
||||
const formattedValue = format(value, offset, prettierOptions);
|
||||
const formattedValue = format(value, offset);
|
||||
if (formattedValue !== value) {
|
||||
context.report({
|
||||
node: comment,
|
||||
|
@ -134,6 +134,7 @@ module.exports = {
|
||||
extends: [
|
||||
'plugin:@typescript-eslint/eslint-recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:@typescript-eslint/stylistic',
|
||||
],
|
||||
plugins: ['eslint-plugin-tsdoc', 'local'],
|
||||
rules: {
|
||||
@ -211,6 +212,7 @@ module.exports = {
|
||||
'error',
|
||||
{ignoreVoid: true, ignoreIIFE: true},
|
||||
],
|
||||
'@typescript-eslint/prefer-ts-expect-error': 'error',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -8,7 +8,7 @@ sidebar_label: ElementFor
|
||||
|
||||
```typescript
|
||||
export type ElementFor<
|
||||
TagName extends keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap
|
||||
TagName extends keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap,
|
||||
> = TagName extends keyof HTMLElementTagNameMap
|
||||
? HTMLElementTagNameMap[TagName]
|
||||
: TagName extends keyof SVGElementTagNameMap
|
||||
|
@ -18,7 +18,7 @@ class ElementHandle {
|
||||
Func extends EvaluateFuncWith<
|
||||
Array<NodeFor<Selector>>,
|
||||
Params
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
|
@ -18,7 +18,7 @@ class ElementHandle {
|
||||
Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<
|
||||
NodeFor<Selector>,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
|
@ -18,7 +18,7 @@ class Frame {
|
||||
Func extends EvaluateFuncWith<
|
||||
Array<NodeFor<Selector>>,
|
||||
Params
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
|
@ -18,7 +18,7 @@ class Frame {
|
||||
Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<
|
||||
NodeFor<Selector>,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
|
@ -12,7 +12,7 @@ Behaves identically to [Page.evaluate()](./puppeteer.page.evaluate.md) except it
|
||||
class Frame {
|
||||
evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -12,7 +12,7 @@ Behaves identically to [Page.evaluateHandle()](./puppeteer.page.evaluatehandle.m
|
||||
class Frame {
|
||||
evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -10,7 +10,7 @@ sidebar_label: Frame.waitForFunction
|
||||
class Frame {
|
||||
waitForFunction<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
options?: FrameWaitForFunctionOptions,
|
||||
|
@ -12,7 +12,7 @@ Evaluates the given function with the current handle as its first argument.
|
||||
class JSHandle {
|
||||
evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -12,7 +12,7 @@ Evaluates the given function with the current handle as its first argument.
|
||||
class JSHandle {
|
||||
evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -16,7 +16,7 @@ class Page {
|
||||
Func extends EvaluateFuncWith<
|
||||
Array<NodeFor<Selector>>,
|
||||
Params
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
|
@ -16,7 +16,7 @@ class Page {
|
||||
Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<
|
||||
NodeFor<Selector>,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
|
@ -14,7 +14,7 @@ If the function passed to `page.evaluate` returns a Promise, the function will w
|
||||
class Page {
|
||||
evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -10,7 +10,7 @@ sidebar_label: Page.evaluateHandle
|
||||
class Page {
|
||||
evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -18,7 +18,7 @@ The function is invoked after the document was created but before any of its scr
|
||||
class Page {
|
||||
evaluateOnNewDocument<
|
||||
Params extends unknown[],
|
||||
Func extends (...args: Params) => unknown = (...args: Params) => unknown
|
||||
Func extends (...args: Params) => unknown = (...args: Params) => unknown,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -12,7 +12,7 @@ Waits for a function to finish evaluating in the page's context.
|
||||
class Page {
|
||||
waitForFunction<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
options?: FrameWaitForFunctionOptions,
|
||||
|
@ -12,7 +12,7 @@ If the function passed to the `worker.evaluate` returns a Promise, then `worker.
|
||||
class WebWorker {
|
||||
evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -12,7 +12,7 @@ The only difference between `worker.evaluate` and `worker.evaluateHandle` is tha
|
||||
class WebWorker {
|
||||
evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -2,17 +2,19 @@
|
||||
sidebar_label: InstalledBrowser
|
||||
---
|
||||
|
||||
# InstalledBrowser type
|
||||
# InstalledBrowser interface
|
||||
|
||||
#### Signature:
|
||||
|
||||
```typescript
|
||||
export type InstalledBrowser = {
|
||||
path: string;
|
||||
browser: Browser;
|
||||
buildId: string;
|
||||
platform: BrowserPlatform;
|
||||
};
|
||||
export interface InstalledBrowser
|
||||
```
|
||||
|
||||
**References:** [Browser](./browsers.browser.md), [BrowserPlatform](./browsers.browserplatform.md)
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description | Default |
|
||||
| -------- | --------- | ------------------------------------------------ | ----------- | ------- |
|
||||
| browser | | [Browser](./browsers.browser.md) | | |
|
||||
| buildId | | string | | |
|
||||
| path | | string | | |
|
||||
| platform | | [BrowserPlatform](./browsers.browserplatform.md) | | |
|
||||
|
@ -2,21 +2,25 @@
|
||||
sidebar_label: LaunchOptions
|
||||
---
|
||||
|
||||
# LaunchOptions type
|
||||
# LaunchOptions interface
|
||||
|
||||
#### Signature:
|
||||
|
||||
```typescript
|
||||
export type LaunchOptions = {
|
||||
executablePath: string;
|
||||
pipe?: boolean;
|
||||
dumpio?: boolean;
|
||||
args?: string[];
|
||||
env?: Record<string, string | undefined>;
|
||||
handleSIGINT?: boolean;
|
||||
handleSIGTERM?: boolean;
|
||||
handleSIGHUP?: boolean;
|
||||
detached?: boolean;
|
||||
onExit?: () => Promise<void>;
|
||||
};
|
||||
export interface LaunchOptions
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description | Default |
|
||||
| -------------- | --------------------- | ----------------------------------------- | ----------- | ------- |
|
||||
| args | <code>optional</code> | string\[\] | | |
|
||||
| detached | <code>optional</code> | boolean | | |
|
||||
| dumpio | <code>optional</code> | boolean | | |
|
||||
| env | <code>optional</code> | Record<string, string \| undefined> | | |
|
||||
| executablePath | | string | | |
|
||||
| handleSIGHUP | <code>optional</code> | boolean | | |
|
||||
| handleSIGINT | <code>optional</code> | boolean | | |
|
||||
| handleSIGTERM | <code>optional</code> | boolean | | |
|
||||
| onExit | <code>optional</code> | () => Promise<void> | | |
|
||||
| pipe | <code>optional</code> | boolean | | |
|
||||
|
@ -68,7 +68,9 @@ The programmatic API allows installing and launching browsers from your code. Se
|
||||
| Interface | Description |
|
||||
| ------------------------------------------------------------------------ | ----------- |
|
||||
| [GetInstalledBrowsersOptions](./browsers.getinstalledbrowsersoptions.md) | |
|
||||
| [InstalledBrowser](./browsers.installedbrowser.md) | |
|
||||
| [InstallOptions](./browsers.installoptions.md) | |
|
||||
| [LaunchOptions](./browsers.launchoptions.md) | |
|
||||
| [Options](./browsers.options.md) | |
|
||||
| [ProfileOptions](./browsers.profileoptions.md) | |
|
||||
| [SystemOptions](./browsers.systemoptions.md) | |
|
||||
@ -80,10 +82,3 @@ The programmatic API allows installing and launching browsers from your code. Se
|
||||
| ------------------------------------------------------------------------------------------------ | ----------- |
|
||||
| [CDP_WEBSOCKET_ENDPOINT_REGEX](./browsers.cdp_websocket_endpoint_regex.md) | |
|
||||
| [WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX](./browsers.webdriver_bidi_websocket_endpoint_regex.md) | |
|
||||
|
||||
## Type Aliases
|
||||
|
||||
| Type Alias | Description |
|
||||
| -------------------------------------------------- | ----------- |
|
||||
| [InstalledBrowser](./browsers.installedbrowser.md) | |
|
||||
| [LaunchOptions](./browsers.launchoptions.md) | |
|
||||
|
@ -143,9 +143,11 @@ The following example searches [developer.chrome.com](https://developer.chrome.c
|
||||
import puppeteer from 'puppeteer';
|
||||
|
||||
(async () => {
|
||||
// Launch the browser and open a new blank page
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
|
||||
// Navigate the page to a URL
|
||||
await page.goto('https://developer.chrome.com/');
|
||||
|
||||
// Set screen size
|
||||
|
2757
package-lock.json
generated
2757
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@ -123,11 +123,12 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@actions/core": "1.10.0",
|
||||
"@microsoft/api-documenter": "7.22.10",
|
||||
"@microsoft/api-extractor": "7.35.1",
|
||||
"@microsoft/api-extractor-model": "7.27.1",
|
||||
"@microsoft/api-documenter": "7.22.27",
|
||||
"@microsoft/api-extractor": "7.36.2",
|
||||
"@microsoft/api-extractor-model": "7.27.4",
|
||||
"@pptr/testserver": "file:packages/testserver",
|
||||
"@rollup/plugin-commonjs": "25.0.0",
|
||||
"@prettier/sync": "0.2.1",
|
||||
"@rollup/plugin-commonjs": "25.0.2",
|
||||
"@rollup/plugin-node-resolve": "15.1.0",
|
||||
"@types/debug": "4.1.8",
|
||||
"@types/diff": "5.0.3",
|
||||
@ -141,25 +142,25 @@
|
||||
"@types/sinon": "10.0.15",
|
||||
"@types/tar-fs": "2.0.1",
|
||||
"@types/unbzip2-stream": "1.4.0",
|
||||
"@types/ws": "8.5.4",
|
||||
"@typescript-eslint/eslint-plugin": "5.59.9",
|
||||
"@typescript-eslint/parser": "5.59.9",
|
||||
"c8": "7.14.0",
|
||||
"@types/ws": "8.5.5",
|
||||
"@typescript-eslint/eslint-plugin": "6.0.0",
|
||||
"@typescript-eslint/parser": "6.0.0",
|
||||
"c8": "8.0.0",
|
||||
"commonmark": "0.30.0",
|
||||
"cross-env": "7.0.3",
|
||||
"diff": "5.1.0",
|
||||
"esbuild": "0.17.19",
|
||||
"eslint": "8.42.0",
|
||||
"esbuild": "0.18.12",
|
||||
"eslint": "8.44.0",
|
||||
"eslint-config-prettier": "8.8.0",
|
||||
"eslint-formatter-codeframe": "7.32.1",
|
||||
"eslint-plugin-import": "2.27.5",
|
||||
"eslint-plugin-local": "1.0.0",
|
||||
"eslint-plugin-mocha": "10.1.0",
|
||||
"eslint-plugin-prettier": "4.2.1",
|
||||
"eslint-plugin-prettier": "5.0.0",
|
||||
"eslint-plugin-tsdoc": "0.2.17",
|
||||
"eslint-plugin-unused-imports": "2.0.0",
|
||||
"eslint-plugin-unused-imports": "3.0.0",
|
||||
"esprima": "4.0.1",
|
||||
"expect": "29.5.0",
|
||||
"expect": "29.6.1",
|
||||
"glob": "10.3.3",
|
||||
"gts": "4.0.1",
|
||||
"jpeg-js": "0.4.4",
|
||||
@ -171,20 +172,20 @@
|
||||
"npm-run-all": "4.1.5",
|
||||
"pixelmatch": "5.3.0",
|
||||
"pngjs": "7.0.0",
|
||||
"prettier": "2.8.8",
|
||||
"prettier": "3.0.0",
|
||||
"puppeteer": "file:packages/puppeteer",
|
||||
"rimraf": "5.0.1",
|
||||
"rollup": "3.24.0",
|
||||
"semver": "7.5.1",
|
||||
"sinon": "15.1.0",
|
||||
"rollup": "3.26.2",
|
||||
"semver": "7.5.4",
|
||||
"sinon": "15.2.0",
|
||||
"source-map-support": "0.5.21",
|
||||
"spdx-satisfies": "5.0.1",
|
||||
"text-diff": "1.0.1",
|
||||
"tsd": "0.28.1",
|
||||
"tsx": "3.12.7",
|
||||
"typescript": "5.1.3",
|
||||
"wireit": "0.9.5",
|
||||
"zod": "3.21.2"
|
||||
"typescript": "5.1.6",
|
||||
"wireit": "0.10.0",
|
||||
"zod": "3.21.4"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*",
|
||||
|
@ -37,7 +37,7 @@ import {
|
||||
launch,
|
||||
} from './launch.js';
|
||||
|
||||
type InstallArgs = {
|
||||
interface InstallArgs {
|
||||
browser: {
|
||||
name: Browser;
|
||||
buildId: string;
|
||||
@ -45,9 +45,9 @@ type InstallArgs = {
|
||||
path?: string;
|
||||
platform?: BrowserPlatform;
|
||||
baseUrl?: string;
|
||||
};
|
||||
}
|
||||
|
||||
type LaunchArgs = {
|
||||
interface LaunchArgs {
|
||||
browser: {
|
||||
name: Browser;
|
||||
buildId: string;
|
||||
@ -56,11 +56,11 @@ type LaunchArgs = {
|
||||
platform?: BrowserPlatform;
|
||||
detached: boolean;
|
||||
system: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
type ClearArgs = {
|
||||
interface ClearArgs {
|
||||
path?: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
|
@ -22,12 +22,12 @@ import {Browser, BrowserPlatform} from './browser-data/browser-data.js';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type InstalledBrowser = {
|
||||
export interface InstalledBrowser {
|
||||
path: string;
|
||||
browser: Browser;
|
||||
buildId: string;
|
||||
platform: BrowserPlatform;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The cache used by Puppeteer relies on the following structure:
|
||||
|
@ -80,9 +80,7 @@ export async function getLastKnownGoodReleaseForChannel(
|
||||
'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json'
|
||||
)
|
||||
)) as {
|
||||
channels: {
|
||||
[channel: string]: {version: string};
|
||||
};
|
||||
channels: Record<string, {version: string}>;
|
||||
};
|
||||
|
||||
for (const channel of Object.keys(data.channels)) {
|
||||
|
@ -70,9 +70,7 @@ export async function resolveBuildId(
|
||||
): Promise<string> {
|
||||
const versions = (await getJSON(
|
||||
new URL('https://product-details.mozilla.org/1.0/firefox_versions.json')
|
||||
)) as {
|
||||
[channel: string]: string;
|
||||
};
|
||||
)) as Record<string, string>;
|
||||
const version = versions[channel];
|
||||
if (!version) {
|
||||
throw new Error(`Channel ${channel} is not found.`);
|
||||
|
@ -129,7 +129,7 @@ export function computeSystemExecutablePath(options: SystemOptions): string {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type LaunchOptions = {
|
||||
export interface LaunchOptions {
|
||||
executablePath: string;
|
||||
pipe?: boolean;
|
||||
dumpio?: boolean;
|
||||
@ -140,7 +140,7 @@ export type LaunchOptions = {
|
||||
handleSIGHUP?: boolean;
|
||||
detached?: boolean;
|
||||
onExit?: () => Promise<void>;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
|
@ -135,7 +135,7 @@ export interface Point {
|
||||
*/
|
||||
|
||||
export class ElementHandle<
|
||||
ElementType extends Node = Element
|
||||
ElementType extends Node = Element,
|
||||
> extends JSHandle<ElementType> {
|
||||
/**
|
||||
* @internal
|
||||
@ -195,7 +195,7 @@ export class ElementHandle<
|
||||
Func extends EvaluateFuncWith<ElementType, Params> = EvaluateFuncWith<
|
||||
ElementType,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -211,7 +211,7 @@ export class ElementHandle<
|
||||
Func extends EvaluateFuncWith<ElementType, Params> = EvaluateFuncWith<
|
||||
ElementType,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -329,7 +329,7 @@ export class ElementHandle<
|
||||
Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<
|
||||
NodeFor<Selector>,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
@ -386,7 +386,7 @@ export class ElementHandle<
|
||||
Func extends EvaluateFuncWith<
|
||||
Array<NodeFor<Selector>>,
|
||||
Params
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
@ -394,9 +394,12 @@ export class ElementHandle<
|
||||
): Promise<Awaited<ReturnType<Func>>> {
|
||||
pageFunction = withSourcePuppeteerURLIfNone(this.$$eval.name, pageFunction);
|
||||
const results = await this.$$(selector);
|
||||
const elements = await this.evaluateHandle((_, ...elements) => {
|
||||
const elements = await this.evaluateHandle(
|
||||
(_, ...elements) => {
|
||||
return elements;
|
||||
}, ...results);
|
||||
},
|
||||
...results
|
||||
);
|
||||
const [result] = await Promise.all([
|
||||
elements.evaluate(pageFunction, ...args),
|
||||
...results.map(results => {
|
||||
@ -606,7 +609,7 @@ export class ElementHandle<
|
||||
* automatically disposed.**
|
||||
*/
|
||||
async toElement<
|
||||
K extends keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap
|
||||
K extends keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap,
|
||||
>(tagName: K): Promise<HandleFor<ElementFor<K>>> {
|
||||
const isMatchingTagName = await this.evaluate((node, tagName) => {
|
||||
return node.nodeName === tagName.toUpperCase();
|
||||
|
@ -48,7 +48,7 @@ export interface Realm {
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<InnerLazyParams<Params>> = EvaluateFunc<
|
||||
InnerLazyParams<Params>
|
||||
>
|
||||
>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
options: {
|
||||
@ -63,14 +63,14 @@ export interface Realm {
|
||||
transferHandle<T extends JSHandle<Node>>(handle: T): Promise<T>;
|
||||
evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -382,14 +382,14 @@ export class Frame {
|
||||
*/
|
||||
async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(): Promise<HandleFor<Awaited<ReturnType<Func>>>> {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
@ -402,14 +402,14 @@ export class Frame {
|
||||
*/
|
||||
async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
): Promise<Awaited<ReturnType<Func>>>;
|
||||
async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(): Promise<Awaited<ReturnType<Func>>> {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
@ -484,7 +484,7 @@ export class Frame {
|
||||
Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<
|
||||
NodeFor<Selector>,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
@ -496,7 +496,7 @@ export class Frame {
|
||||
Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<
|
||||
NodeFor<Selector>,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(): Promise<Awaited<ReturnType<Func>>> {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
@ -527,7 +527,7 @@ export class Frame {
|
||||
Func extends EvaluateFuncWith<
|
||||
Array<NodeFor<Selector>>,
|
||||
Params
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
@ -539,7 +539,7 @@ export class Frame {
|
||||
Func extends EvaluateFuncWith<
|
||||
Array<NodeFor<Selector>>,
|
||||
Params
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>,
|
||||
>(): Promise<Awaited<ReturnType<Func>>> {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
@ -674,7 +674,7 @@ export class Frame {
|
||||
*/
|
||||
waitForFunction<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
options: FrameWaitForFunctionOptions = {},
|
||||
|
@ -500,7 +500,7 @@ export function headersArray(
|
||||
* List taken from {@link https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml}
|
||||
* with extra 306 and 418 codes.
|
||||
*/
|
||||
export const STATUS_TEXTS: {[key: string]: string | undefined} = {
|
||||
export const STATUS_TEXTS: Record<string, string | undefined> = {
|
||||
'100': 'Continue',
|
||||
'101': 'Switching Protocols',
|
||||
'102': 'Processing',
|
||||
|
@ -82,7 +82,7 @@ export class JSHandle<T = unknown> {
|
||||
*/
|
||||
async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -97,7 +97,7 @@ export class JSHandle<T = unknown> {
|
||||
*/
|
||||
async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -930,14 +930,14 @@ export class Page extends EventEmitter {
|
||||
*/
|
||||
async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(): Promise<HandleFor<Awaited<ReturnType<Func>>>> {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
@ -1040,7 +1040,7 @@ export class Page extends EventEmitter {
|
||||
Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<
|
||||
NodeFor<Selector>,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
@ -1118,7 +1118,7 @@ export class Page extends EventEmitter {
|
||||
Func extends EvaluateFuncWith<
|
||||
Array<NodeFor<Selector>>,
|
||||
Params
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
@ -2167,14 +2167,14 @@ export class Page extends EventEmitter {
|
||||
*/
|
||||
async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
): Promise<Awaited<ReturnType<Func>>>;
|
||||
async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(): Promise<Awaited<ReturnType<Func>>> {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
@ -2213,7 +2213,7 @@ export class Page extends EventEmitter {
|
||||
*/
|
||||
async evaluateOnNewDocument<
|
||||
Params extends unknown[],
|
||||
Func extends (...args: Params) => unknown = (...args: Params) => unknown
|
||||
Func extends (...args: Params) => unknown = (...args: Params) => unknown,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -2773,7 +2773,7 @@ export class Page extends EventEmitter {
|
||||
*/
|
||||
waitForFunction<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
options?: FrameWaitForFunctionOptions,
|
||||
|
@ -40,7 +40,10 @@ const queryAXTree = async (
|
||||
});
|
||||
};
|
||||
|
||||
type ARIASelector = {name?: string; role?: string};
|
||||
interface ARIASelector {
|
||||
name?: string;
|
||||
role?: string;
|
||||
}
|
||||
|
||||
const KNOWN_ATTRIBUTES = Object.freeze(['name', 'role']);
|
||||
const isKnownAttribute = (
|
||||
|
@ -50,17 +50,16 @@ export class ChromeTargetManager extends EventEmitter implements TargetManager {
|
||||
*
|
||||
* `targetFilterCallback` has no effect on this map.
|
||||
*/
|
||||
#discoveredTargetsByTargetId: Map<string, Protocol.Target.TargetInfo> =
|
||||
new Map();
|
||||
#discoveredTargetsByTargetId = new Map<string, Protocol.Target.TargetInfo>();
|
||||
/**
|
||||
* A target is added to this map once ChromeTargetManager has created
|
||||
* a Target and attached at least once to it.
|
||||
*/
|
||||
#attachedTargetsByTargetId: Map<string, Target> = new Map();
|
||||
#attachedTargetsByTargetId = new Map<string, Target>();
|
||||
/**
|
||||
* Tracks which sessions attach to which target.
|
||||
*/
|
||||
#attachedTargetsBySessionId: Map<string, Target> = new Map();
|
||||
#attachedTargetsBySessionId = new Map<string, Target>();
|
||||
/**
|
||||
* If a target was filtered out by `targetFilterCallback`, we still receive
|
||||
* events about it from CDP, but we don't forward them to the rest of Puppeteer.
|
||||
@ -69,20 +68,22 @@ export class ChromeTargetManager extends EventEmitter implements TargetManager {
|
||||
#targetFilterCallback: TargetFilterCallback | undefined;
|
||||
#targetFactory: TargetFactory;
|
||||
|
||||
#targetInterceptors: WeakMap<CDPSession | Connection, TargetInterceptor[]> =
|
||||
new WeakMap();
|
||||
#targetInterceptors = new WeakMap<
|
||||
CDPSession | Connection,
|
||||
TargetInterceptor[]
|
||||
>();
|
||||
|
||||
#attachedToTargetListenersBySession: WeakMap<
|
||||
#attachedToTargetListenersBySession = new WeakMap<
|
||||
CDPSession | Connection,
|
||||
(event: Protocol.Target.AttachedToTargetEvent) => Promise<void>
|
||||
> = new WeakMap();
|
||||
#detachedFromTargetListenersBySession: WeakMap<
|
||||
>();
|
||||
#detachedFromTargetListenersBySession = new WeakMap<
|
||||
CDPSession | Connection,
|
||||
(event: Protocol.Target.DetachedFromTargetEvent) => void
|
||||
> = new WeakMap();
|
||||
>();
|
||||
|
||||
#initializeDeferred = Deferred.create<void>();
|
||||
#targetsIdsForInit: Set<string> = new Set();
|
||||
#targetsIdsForInit = new Set<string>();
|
||||
|
||||
constructor(
|
||||
connection: Connection,
|
||||
|
@ -116,7 +116,7 @@ export class Callback {
|
||||
* @internal
|
||||
*/
|
||||
export class CallbackRegistry {
|
||||
#callbacks: Map<number, Callback> = new Map();
|
||||
#callbacks = new Map<number, Callback>();
|
||||
#idGenerator = createIncrementalIdGenerator();
|
||||
|
||||
create(
|
||||
@ -197,7 +197,7 @@ export class Connection extends EventEmitter {
|
||||
#transport: ConnectionTransport;
|
||||
#delay: number;
|
||||
#timeout: number;
|
||||
#sessions: Map<string, CDPSessionImpl> = new Map();
|
||||
#sessions = new Map<string, CDPSessionImpl>();
|
||||
#closed = false;
|
||||
#manuallyAttached = new Set<string>();
|
||||
#callbacks = new CallbackRegistry();
|
||||
|
@ -57,7 +57,7 @@ const applyOffsetsToQuad = (
|
||||
* @internal
|
||||
*/
|
||||
export class CDPElementHandle<
|
||||
ElementType extends Node = Element
|
||||
ElementType extends Node = Element,
|
||||
> extends ElementHandle<ElementType> {
|
||||
#frame: Frame;
|
||||
declare handle: CDPJSHandle<ElementType>;
|
||||
|
@ -105,9 +105,12 @@ export class ExecutionContext {
|
||||
selector: string
|
||||
): Promise<JSHandle<Node[]>> => {
|
||||
const results = ARIAQueryHandler.queryAll(element, selector);
|
||||
return element.executionContext().evaluateHandle((...elements) => {
|
||||
return element.executionContext().evaluateHandle(
|
||||
(...elements) => {
|
||||
return elements;
|
||||
}, ...(await AsyncIterableUtil.collect(results)));
|
||||
},
|
||||
...(await AsyncIterableUtil.collect(results))
|
||||
);
|
||||
}) as (...args: unknown[]) => unknown)
|
||||
),
|
||||
]);
|
||||
@ -181,7 +184,7 @@ export class ExecutionContext {
|
||||
*/
|
||||
async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -240,7 +243,7 @@ export class ExecutionContext {
|
||||
*/
|
||||
async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -250,7 +253,7 @@ export class ExecutionContext {
|
||||
|
||||
async #evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
returnByValue: true,
|
||||
pageFunction: Func | string,
|
||||
@ -258,7 +261,7 @@ export class ExecutionContext {
|
||||
): Promise<Awaited<ReturnType<Func>>>;
|
||||
async #evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
returnByValue: false,
|
||||
pageFunction: Func | string,
|
||||
@ -266,7 +269,7 @@ export class ExecutionContext {
|
||||
): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
async #evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
returnByValue: boolean,
|
||||
pageFunction: Func | string,
|
||||
|
@ -59,19 +59,18 @@ export class FirefoxTargetManager
|
||||
*
|
||||
* `targetFilterCallback` has no effect on this map.
|
||||
*/
|
||||
#discoveredTargetsByTargetId: Map<string, Protocol.Target.TargetInfo> =
|
||||
new Map();
|
||||
#discoveredTargetsByTargetId = new Map<string, Protocol.Target.TargetInfo>();
|
||||
/**
|
||||
* Keeps track of targets that were created via 'Target.targetCreated'
|
||||
* and which one are not filtered out by `targetFilterCallback`.
|
||||
*
|
||||
* The target is removed from here once it's been destroyed.
|
||||
*/
|
||||
#availableTargetsByTargetId: Map<string, Target> = new Map();
|
||||
#availableTargetsByTargetId = new Map<string, Target>();
|
||||
/**
|
||||
* Tracks which sessions attach to which target.
|
||||
*/
|
||||
#availableTargetsBySessionId: Map<string, Target> = new Map();
|
||||
#availableTargetsBySessionId = new Map<string, Target>();
|
||||
/**
|
||||
* If a target was filtered out by `targetFilterCallback`, we still receive
|
||||
* events about it from CDP, but we don't forward them to the rest of Puppeteer.
|
||||
@ -80,16 +79,18 @@ export class FirefoxTargetManager
|
||||
#targetFilterCallback: TargetFilterCallback | undefined;
|
||||
#targetFactory: TargetFactory;
|
||||
|
||||
#targetInterceptors: WeakMap<CDPSession | Connection, TargetInterceptor[]> =
|
||||
new WeakMap();
|
||||
#targetInterceptors = new WeakMap<
|
||||
CDPSession | Connection,
|
||||
TargetInterceptor[]
|
||||
>();
|
||||
|
||||
#attachedToTargetListenersBySession: WeakMap<
|
||||
#attachedToTargetListenersBySession = new WeakMap<
|
||||
CDPSession | Connection,
|
||||
(event: Protocol.Target.AttachedToTargetEvent) => Promise<void>
|
||||
> = new WeakMap();
|
||||
>();
|
||||
|
||||
#initializeDeferred = Deferred.create<void>();
|
||||
#targetsIdsForInit: Set<string> = new Set();
|
||||
#targetsIdsForInit = new Set<string>();
|
||||
|
||||
constructor(
|
||||
connection: Connection,
|
||||
|
@ -231,7 +231,7 @@ export class Frame extends BaseFrame {
|
||||
|
||||
override async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -245,7 +245,7 @@ export class Frame extends BaseFrame {
|
||||
|
||||
override async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -275,7 +275,7 @@ export class Frame extends BaseFrame {
|
||||
Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<
|
||||
NodeFor<Selector>,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
@ -291,7 +291,7 @@ export class Frame extends BaseFrame {
|
||||
Func extends EvaluateFuncWith<
|
||||
Array<NodeFor<Selector>>,
|
||||
Params
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
|
@ -182,7 +182,7 @@ export class IsolatedWorld implements Realm {
|
||||
|
||||
async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -197,7 +197,7 @@ export class IsolatedWorld implements Realm {
|
||||
|
||||
async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -246,7 +246,7 @@ export class IsolatedWorld implements Realm {
|
||||
Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<
|
||||
NodeFor<Selector>,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
@ -263,7 +263,7 @@ export class IsolatedWorld implements Realm {
|
||||
Func extends EvaluateFuncWith<
|
||||
Array<NodeFor<Selector>>,
|
||||
Params
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
@ -444,7 +444,7 @@ export class IsolatedWorld implements Realm {
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<InnerLazyParams<Params>> = EvaluateFunc<
|
||||
InnerLazyParams<Params>
|
||||
>
|
||||
>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
options: {
|
||||
|
@ -71,7 +71,7 @@ export class CDPJSHandle<T = unknown> extends JSHandle<T> {
|
||||
*/
|
||||
override async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -88,7 +88,7 @@ export class CDPJSHandle<T = unknown> extends JSHandle<T> {
|
||||
*/
|
||||
override async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -21,11 +21,11 @@ import {HTTPRequest} from './HTTPRequest.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type QueuedEventGroup = {
|
||||
export interface QueuedEventGroup {
|
||||
responseReceivedEvent: Protocol.Network.ResponseReceivedEvent;
|
||||
loadingFinishedEvent?: Protocol.Network.LoadingFinishedEvent;
|
||||
loadingFailedEvent?: Protocol.Network.LoadingFailedEvent;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -35,10 +35,10 @@ export type FetchRequestId = string;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type RedirectInfo = {
|
||||
export interface RedirectInfo {
|
||||
event: Protocol.Network.RequestWillBeSentEvent;
|
||||
fetchRequestId?: FetchRequestId;
|
||||
};
|
||||
}
|
||||
type RedirectInfoList = RedirectInfo[];
|
||||
|
||||
/**
|
||||
|
@ -495,7 +495,7 @@ export class CDPPage extends Page {
|
||||
|
||||
override async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -1076,7 +1076,7 @@ export class CDPPage extends Page {
|
||||
|
||||
override async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -1090,7 +1090,7 @@ export class CDPPage extends Page {
|
||||
|
||||
override async evaluateOnNewDocument<
|
||||
Params extends unknown[],
|
||||
Func extends (...args: Params) => unknown = (...args: Params) => unknown
|
||||
Func extends (...args: Params) => unknown = (...args: Params) => unknown,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -149,7 +149,7 @@ export class WebWorker extends EventEmitter {
|
||||
*/
|
||||
async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -176,7 +176,7 @@ export class WebWorker extends EventEmitter {
|
||||
*/
|
||||
async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -26,7 +26,7 @@ import {BrowsingContext} from './BrowsingContext.js';
|
||||
const debugProtocolSend = debug('puppeteer:webDriverBiDi:SEND ►');
|
||||
const debugProtocolReceive = debug('puppeteer:webDriverBiDi:RECV ◀');
|
||||
|
||||
type Capability = {
|
||||
interface Capability {
|
||||
// session.CapabilityRequest = {
|
||||
// ? acceptInsecureCerts: bool,
|
||||
// ? browserName: text,
|
||||
@ -47,7 +47,7 @@ type Capability = {
|
||||
acceptInsecureCerts?: boolean;
|
||||
browserName?: string;
|
||||
browserVersion?: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -155,7 +155,7 @@ export class Connection extends EventEmitter {
|
||||
#timeout? = 0;
|
||||
#closed = false;
|
||||
#callbacks = new CallbackRegistry();
|
||||
#browsingContexts: Map<string, BrowsingContext> = new Map();
|
||||
#browsingContexts = new Map<string, BrowsingContext>();
|
||||
|
||||
constructor(
|
||||
url: string,
|
||||
|
@ -32,7 +32,7 @@ import {Realm} from './Realm.js';
|
||||
* @internal
|
||||
*/
|
||||
export class ElementHandle<
|
||||
ElementType extends Node = Element
|
||||
ElementType extends Node = Element,
|
||||
> extends BaseElementHandle<ElementType> {
|
||||
declare handle: JSHandle<ElementType>;
|
||||
#frame: Frame;
|
||||
|
@ -104,7 +104,7 @@ export class Frame extends BaseFrame {
|
||||
|
||||
override async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -114,7 +114,7 @@ export class Frame extends BaseFrame {
|
||||
|
||||
override async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -175,7 +175,7 @@ export class Frame extends BaseFrame {
|
||||
Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<
|
||||
NodeFor<Selector>,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: string | Func,
|
||||
@ -191,7 +191,7 @@ export class Frame extends BaseFrame {
|
||||
Func extends EvaluateFuncWith<
|
||||
Array<NodeFor<Selector>>,
|
||||
Params
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: string | Func,
|
||||
|
@ -46,7 +46,7 @@ export class JSHandle<T = unknown> extends BaseJSHandle<T> {
|
||||
|
||||
override async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -60,7 +60,7 @@ export class JSHandle<T = unknown> extends BaseJSHandle<T> {
|
||||
|
||||
override async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>
|
||||
Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -97,7 +97,7 @@ export class JSHandle<T = unknown> extends BaseJSHandle<T> {
|
||||
}
|
||||
return enumerableKeys;
|
||||
});
|
||||
const map: Map<string, BaseJSHandle> = new Map();
|
||||
const map = new Map<string, BaseJSHandle>();
|
||||
const results = await Promise.all(
|
||||
keys.map(key => {
|
||||
return this.getProperty(key);
|
||||
|
@ -349,7 +349,7 @@ export class Page extends PageBase {
|
||||
|
||||
override async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -363,7 +363,7 @@ export class Page extends PageBase {
|
||||
|
||||
override async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
|
@ -66,7 +66,7 @@ export class Realm extends EventEmitter {
|
||||
|
||||
async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -76,7 +76,7 @@ export class Realm extends EventEmitter {
|
||||
|
||||
async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -86,7 +86,7 @@ export class Realm extends EventEmitter {
|
||||
|
||||
async #evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
returnByValue: true,
|
||||
pageFunction: Func | string,
|
||||
@ -94,7 +94,7 @@ export class Realm extends EventEmitter {
|
||||
): Promise<Awaited<ReturnType<Func>>>;
|
||||
async #evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
returnByValue: false,
|
||||
pageFunction: Func | string,
|
||||
@ -102,7 +102,7 @@ export class Realm extends EventEmitter {
|
||||
): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
async #evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
returnByValue: boolean,
|
||||
pageFunction: Func | string,
|
||||
|
@ -105,7 +105,7 @@ export class Sandbox implements RealmBase {
|
||||
Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<
|
||||
NodeFor<Selector>,
|
||||
Params
|
||||
>
|
||||
>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
@ -122,7 +122,7 @@ export class Sandbox implements RealmBase {
|
||||
Func extends EvaluateFuncWith<
|
||||
Array<NodeFor<Selector>>,
|
||||
Params
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>
|
||||
> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>,
|
||||
>(
|
||||
selector: Selector,
|
||||
pageFunction: Func | string,
|
||||
@ -140,7 +140,7 @@ export class Sandbox implements RealmBase {
|
||||
|
||||
async evaluateHandle<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -154,7 +154,7 @@ export class Sandbox implements RealmBase {
|
||||
|
||||
async evaluate<
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
|
||||
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
...args: Params
|
||||
@ -188,7 +188,7 @@ export class Sandbox implements RealmBase {
|
||||
Params extends unknown[],
|
||||
Func extends EvaluateFunc<InnerLazyParams<Params>> = EvaluateFunc<
|
||||
InnerLazyParams<Params>
|
||||
>
|
||||
>,
|
||||
>(
|
||||
pageFunction: Func | string,
|
||||
options: {
|
||||
|
@ -247,7 +247,7 @@ export class BidiSerializer {
|
||||
|
||||
static deserializeTuple([serializedKey, serializedValue]: [
|
||||
Bidi.CommonDataTypes.RemoteValue | string,
|
||||
Bidi.CommonDataTypes.RemoteValue
|
||||
Bidi.CommonDataTypes.RemoteValue,
|
||||
]): {key: unknown; value: unknown} {
|
||||
const key =
|
||||
typeof serializedKey === 'string'
|
||||
|
@ -22,7 +22,7 @@ import type {LazyArg} from './LazyArg.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type BindingPayload = {
|
||||
export interface BindingPayload {
|
||||
type: string;
|
||||
name: string;
|
||||
seq: number;
|
||||
@ -31,7 +31,7 @@ export type BindingPayload = {
|
||||
* Determines whether the arguments of the payload are trivial.
|
||||
*/
|
||||
isTrivial: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -86,7 +86,7 @@ export type InnerParams<T extends unknown[]> = {
|
||||
* @public
|
||||
*/
|
||||
export type ElementFor<
|
||||
TagName extends keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap
|
||||
TagName extends keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap,
|
||||
> = TagName extends keyof HTMLElementTagNameMap
|
||||
? HTMLElementTagNameMap[TagName]
|
||||
: TagName extends keyof SVGElementTagNameMap
|
||||
@ -144,7 +144,7 @@ type TypeSelectorOfCompoundSelector<CompoundSelector extends string> =
|
||||
|
||||
type Last<Arr extends NonEmptyReadonlyArray<unknown>> = Arr extends [
|
||||
infer Head,
|
||||
...infer Tail
|
||||
...infer Tail,
|
||||
]
|
||||
? Tail extends NonEmptyReadonlyArray<unknown>
|
||||
? Last<Tail>
|
||||
@ -165,7 +165,7 @@ type CompoundSelectorsOfComplexSelector<ComplexSelector extends string> =
|
||||
|
||||
type SplitWithDelemiters<
|
||||
Input extends string,
|
||||
Delemiters extends readonly string[]
|
||||
Delemiters extends readonly string[],
|
||||
> = Delemiters extends [infer FirstDelemiter, ...infer RestDelemiters]
|
||||
? FirstDelemiter extends string
|
||||
? RestDelemiters extends readonly string[]
|
||||
@ -181,7 +181,7 @@ type CombinatorTokens = [' ', '>', '+', '~', '|', '|'];
|
||||
type Drop<
|
||||
Arr extends readonly unknown[],
|
||||
Remove,
|
||||
Acc extends unknown[] = []
|
||||
Acc extends unknown[] = [],
|
||||
> = Arr extends [infer Head, ...infer Tail]
|
||||
? Head extends Remove
|
||||
? Drop<Tail, Remove>
|
||||
@ -191,7 +191,7 @@ type Drop<
|
||||
type FlatmapSplitWithDelemiters<
|
||||
Inputs extends readonly string[],
|
||||
Delemiters extends readonly string[],
|
||||
Acc extends string[] = []
|
||||
Acc extends string[] = [],
|
||||
> = Inputs extends [infer FirstInput, ...infer RestInputs]
|
||||
? FirstInput extends string
|
||||
? RestInputs extends readonly string[]
|
||||
@ -207,7 +207,7 @@ type FlatmapSplitWithDelemiters<
|
||||
type Split<
|
||||
Input extends string,
|
||||
Delimiter extends string,
|
||||
Acc extends string[] = []
|
||||
Acc extends string[] = [],
|
||||
> = Input extends `${infer Prefix}${Delimiter}${infer Suffix}`
|
||||
? Split<Suffix, Delimiter, [...Acc, Prefix]>
|
||||
: [...Acc, Input];
|
||||
|
@ -244,7 +244,7 @@ export const withSourcePuppeteerURLIfNone = <T extends NonNullable<unknown>>(
|
||||
* @internal
|
||||
*/
|
||||
export const getSourcePuppeteerURLIfAvailable = <
|
||||
T extends NonNullable<unknown>
|
||||
T extends NonNullable<unknown>,
|
||||
>(
|
||||
object: T
|
||||
): PuppeteerURL | undefined => {
|
||||
|
@ -17,10 +17,10 @@
|
||||
import {Token, tokenize, TOKENS, stringify} from 'parsel-js';
|
||||
|
||||
export type CSSSelector = string;
|
||||
export type PPseudoSelector = {
|
||||
export interface PPseudoSelector {
|
||||
name: string;
|
||||
value: string;
|
||||
};
|
||||
}
|
||||
export const enum PCombinator {
|
||||
Descendent = '>>>',
|
||||
Child = '>>>>',
|
||||
|
@ -57,12 +57,12 @@ export const isSuitableNodeForTextMatching = (node: Node): boolean => {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type TextContent = {
|
||||
export interface TextContent {
|
||||
// Contains the full text of the node.
|
||||
full: string;
|
||||
// Contains the text immediately beneath the node.
|
||||
immediate: string[];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps {@link Node}s to their computed {@link TextContent}.
|
||||
|
@ -46,12 +46,12 @@ import {PuppeteerNode} from './PuppeteerNode.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type ResolvedLaunchArgs = {
|
||||
export interface ResolvedLaunchArgs {
|
||||
isTempUserDataDir: boolean;
|
||||
userDataDir: string;
|
||||
executablePath: string;
|
||||
args: string[];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes a launcher - a class that is able to create and launch a browser instance.
|
||||
|
@ -85,7 +85,7 @@ export class Deferred<T> {
|
||||
static async race<R>(
|
||||
awaitables: Array<Promise<R> | Deferred<R>>
|
||||
): Promise<R> {
|
||||
const deferredWithTimeout: Set<Deferred<R>> = new Set();
|
||||
const deferredWithTimeout = new Set<Deferred<R>>();
|
||||
try {
|
||||
const promises = awaitables.map(value => {
|
||||
if (value instanceof Deferred) {
|
||||
|
@ -14,6 +14,10 @@ module.exports = {
|
||||
{
|
||||
files: ['*.spec.ts'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
{argsIgnorePattern: '^_', varsIgnorePattern: '^_'},
|
||||
],
|
||||
'no-restricted-syntax': [
|
||||
'error',
|
||||
{
|
||||
|
@ -583,9 +583,12 @@ describe('AriaQueryHandler', () => {
|
||||
});
|
||||
await page.setContent(`<div aria-label='zombo'>anything</div>`);
|
||||
expect(
|
||||
await page.evaluate(x => {
|
||||
await page.evaluate(
|
||||
x => {
|
||||
return x?.textContent;
|
||||
}, await waitForSelector)
|
||||
},
|
||||
await waitForSelector
|
||||
)
|
||||
).toBe('anything');
|
||||
});
|
||||
|
||||
|
@ -338,7 +338,7 @@ describe('Evaluation specs', function () {
|
||||
const {page} = await getTestState();
|
||||
|
||||
const result = await page.evaluate(() => {
|
||||
const a: {[x: string]: any} = {};
|
||||
const a: Record<string, any> = {};
|
||||
const b = {a};
|
||||
a['b'] = b;
|
||||
return a;
|
||||
|
@ -92,14 +92,20 @@ const compareText = (
|
||||
return;
|
||||
}
|
||||
const result = diffLines(expected, actual);
|
||||
const html = result.reduce((text, change) => {
|
||||
const html = result.reduce(
|
||||
(text, change) => {
|
||||
text += change.added
|
||||
? `<span class='ins'>${change.value}</span>`
|
||||
: change.removed
|
||||
? `<span class='del'>${change.value}</span>`
|
||||
: change.value;
|
||||
return text;
|
||||
}, `<link rel="stylesheet" href="file://${path.join(__dirname, 'diffstyle.css')}">`);
|
||||
},
|
||||
`<link rel="stylesheet" href="file://${path.join(
|
||||
__dirname,
|
||||
'diffstyle.css'
|
||||
)}">`
|
||||
);
|
||||
return {
|
||||
diff: html,
|
||||
ext: '.html',
|
||||
|
@ -286,7 +286,8 @@ describe('headful tests', function () {
|
||||
|
||||
// Navigate to the empty page and add an OOPIF iframe with at least one request.
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.evaluate((frameUrl: string) => {
|
||||
await page.evaluate(
|
||||
(frameUrl: string) => {
|
||||
const frame = document.createElement('iframe');
|
||||
frame.setAttribute('src', frameUrl);
|
||||
document.body.appendChild(frame);
|
||||
@ -294,7 +295,9 @@ describe('headful tests', function () {
|
||||
frame.onload = x;
|
||||
frame.onerror = y;
|
||||
});
|
||||
}, server.PREFIX.replace('localhost', 'oopifdomain') + '/one-style.html');
|
||||
},
|
||||
server.PREFIX.replace('localhost', 'oopifdomain') + '/one-style.html'
|
||||
);
|
||||
await page.waitForSelector('iframe');
|
||||
|
||||
// Ensure we found the iframe session.
|
||||
|
@ -66,7 +66,7 @@ describe('Keyboard', function () {
|
||||
return document.querySelector('textarea')!.value;
|
||||
})
|
||||
).toBe('Hello World!');
|
||||
for (let i = 0; i < 'World!'.length; i++) {
|
||||
for (const _ of 'World!') {
|
||||
page.keyboard.press('ArrowLeft');
|
||||
}
|
||||
await page.keyboard.type('inserted ');
|
||||
@ -76,7 +76,7 @@ describe('Keyboard', function () {
|
||||
})
|
||||
).toBe('Hello inserted World!');
|
||||
page.keyboard.down('Shift');
|
||||
for (let i = 0; i < 'inserted '.length; i++) {
|
||||
for (const _ of 'inserted ') {
|
||||
page.keyboard.press('ArrowLeft');
|
||||
}
|
||||
page.keyboard.up('Shift');
|
||||
@ -515,7 +515,7 @@ describe('Keyboard', function () {
|
||||
const [key, code, metaKey] = (await page.evaluate('result')) as [
|
||||
string,
|
||||
string,
|
||||
boolean
|
||||
boolean,
|
||||
];
|
||||
if (isFirefox && os.platform() !== 'darwin') {
|
||||
expect(key).toBe('OS');
|
||||
|
@ -216,12 +216,12 @@ describeWithDebugLogs('OOPIF', function () {
|
||||
const frame = await framePromise;
|
||||
await frame.evaluate(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
_test = 'Test 123!';
|
||||
});
|
||||
const result = await frame.evaluate(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
return window._test;
|
||||
});
|
||||
expect(result).toBe('Test 123!');
|
||||
|
@ -1432,14 +1432,14 @@ describe('Page', function () {
|
||||
expect(
|
||||
await page.evaluate(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: userAgentData not yet in TypeScript DOM API
|
||||
// @ts-expect-error: userAgentData not yet in TypeScript DOM API
|
||||
return navigator.userAgentData.mobile;
|
||||
})
|
||||
).toBe(false);
|
||||
|
||||
const uaData = await page.evaluate(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: userAgentData not yet in TypeScript DOM API
|
||||
// @ts-expect-error: userAgentData not yet in TypeScript DOM API
|
||||
return navigator.userAgentData.getHighEntropyValues([
|
||||
'architecture',
|
||||
'model',
|
||||
|
@ -715,9 +715,12 @@ describe('waittask specs', function () {
|
||||
const waitForSelector = page.waitForSelector('.zombo');
|
||||
await page.setContent(`<div class='zombo'>anything</div>`);
|
||||
expect(
|
||||
await page.evaluate(x => {
|
||||
await page.evaluate(
|
||||
x => {
|
||||
return x?.textContent;
|
||||
}, await waitForSelector)
|
||||
},
|
||||
await waitForSelector
|
||||
)
|
||||
).toBe('anything');
|
||||
});
|
||||
it('should have correct stack trace for timeout', async () => {
|
||||
@ -748,9 +751,12 @@ describe('waittask specs', function () {
|
||||
'//p[normalize-space(.)="hello world"]'
|
||||
);
|
||||
expect(
|
||||
await page.evaluate(x => {
|
||||
await page.evaluate(
|
||||
x => {
|
||||
return x?.textContent;
|
||||
}, await waitForXPath)
|
||||
},
|
||||
await waitForXPath
|
||||
)
|
||||
).toBe('hello world ');
|
||||
});
|
||||
it('should respect timeout', async () => {
|
||||
@ -836,9 +842,12 @@ describe('waittask specs', function () {
|
||||
const waitForXPath = page.waitForXPath('//*[@class="zombo"]');
|
||||
await page.setContent(`<div class='zombo'>anything</div>`);
|
||||
expect(
|
||||
await page.evaluate(x => {
|
||||
await page.evaluate(
|
||||
x => {
|
||||
return x?.textContent;
|
||||
}, await waitForXPath)
|
||||
},
|
||||
await waitForXPath
|
||||
)
|
||||
).toBe('anything');
|
||||
});
|
||||
it('should allow you to select a text node', async () => {
|
||||
@ -856,9 +865,12 @@ describe('waittask specs', function () {
|
||||
await page.setContent(`<div>some text</div>`);
|
||||
const waitForXPath = page.waitForXPath('/html/body/div');
|
||||
expect(
|
||||
await page.evaluate(x => {
|
||||
await page.evaluate(
|
||||
x => {
|
||||
return x?.textContent;
|
||||
}, await waitForXPath)
|
||||
},
|
||||
await waitForXPath
|
||||
)
|
||||
).toBe('some text');
|
||||
});
|
||||
});
|
||||
|
@ -491,7 +491,7 @@ export class MarkdownDocumenter {
|
||||
]
|
||||
);
|
||||
let needsComma = false;
|
||||
const visited: Set<string> = new Set();
|
||||
const visited = new Set<string>();
|
||||
for (const ref of refs) {
|
||||
if (visited.has(ref.text)) {
|
||||
continue;
|
||||
|
@ -79,7 +79,7 @@ function customBDDInterface(suite: Mocha.Suite) {
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
context['describe'] = describe;
|
||||
|
||||
function it(title: string, fn: Mocha.TestFunction, itOnly = false) {
|
||||
@ -90,7 +90,7 @@ function customBDDInterface(suite: Mocha.Suite) {
|
||||
|
||||
const describeOnly = Boolean(
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
suite.parent?._onlySuites.find(child => {
|
||||
return child === suite;
|
||||
})
|
||||
@ -119,7 +119,7 @@ function customBDDInterface(suite: Mocha.Suite) {
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
context.it = it;
|
||||
}
|
||||
);
|
||||
|
@ -40,21 +40,21 @@ export type TestSuiteFile = z.infer<typeof zTestSuiteFile>;
|
||||
|
||||
export type TestResult = 'PASS' | 'FAIL' | 'TIMEOUT' | 'SKIP';
|
||||
|
||||
export type TestExpectation = {
|
||||
export interface TestExpectation {
|
||||
testIdPattern: string;
|
||||
platforms: NodeJS.Platform[];
|
||||
parameters: string[];
|
||||
expectations: TestResult[];
|
||||
};
|
||||
}
|
||||
|
||||
export type MochaTestResult = {
|
||||
export interface MochaTestResult {
|
||||
fullTitle: string;
|
||||
title: string;
|
||||
file: string;
|
||||
err?: {code: string};
|
||||
};
|
||||
}
|
||||
|
||||
export type MochaResults = {
|
||||
export interface MochaResults {
|
||||
stats: {tests: number};
|
||||
pending: MochaTestResult[];
|
||||
passes: MochaTestResult[];
|
||||
@ -64,4 +64,4 @@ export type MochaResults = {
|
||||
parameters?: string[];
|
||||
platform?: string;
|
||||
date?: string;
|
||||
};
|
||||
}
|
||||
|
@ -114,11 +114,11 @@ export function findEffectiveExpectationForTest(
|
||||
});
|
||||
}
|
||||
|
||||
export type RecommendedExpectation = {
|
||||
export interface RecommendedExpectation {
|
||||
expectation: TestExpectation;
|
||||
action: 'remove' | 'add' | 'update';
|
||||
basedOn?: TestExpectation;
|
||||
};
|
||||
}
|
||||
|
||||
export function isWildCardPattern(testIdPattern: string): boolean {
|
||||
return testIdPattern.includes('*');
|
||||
@ -132,7 +132,7 @@ export function getExpectationUpdates(
|
||||
parameters: string[];
|
||||
}
|
||||
): RecommendedExpectation[] {
|
||||
const output: Map<string, RecommendedExpectation> = new Map();
|
||||
const output = new Map<string, RecommendedExpectation>();
|
||||
|
||||
for (const pass of results.passes) {
|
||||
const expectationEntry = findEffectiveExpectationForTest(
|
||||
|
@ -19,7 +19,7 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const prettier = require('prettier');
|
||||
const prettier = require('@prettier/sync');
|
||||
|
||||
const source = 'test/TestExpectations.json';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user