chore: update prettier globs and format files (#7856)

* chore: update prettier globs and format files

* fix: remove reference to Markdownlint
This commit is contained in:
Nick Schonning 2022-02-11 14:29:43 -05:00 committed by GitHub
parent 4ce72abcbd
commit b2bf70fc3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 107 additions and 95 deletions

View File

@ -1,6 +1,6 @@
version: 2 version: 2
updates: updates:
- package-ecosystem: npm - package-ecosystem: npm
directory: / directory: /
schedule: schedule:
interval: daily interval: daily

View File

@ -5,7 +5,7 @@ on:
schedule: schedule:
- cron: '23 8 * * 6' - cron: '23 8 * * 6'
push: push:
branches: [ main ] branches: [main]
# Declare default permissions as read only. # Declare default permissions as read only.
permissions: read-all permissions: read-all
@ -21,12 +21,12 @@ jobs:
contents: read contents: read
steps: steps:
- name: "Checkout code" - name: 'Checkout code'
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
with: with:
persist-credentials: false persist-credentials: false
- name: "Run analysis" - name: 'Run analysis'
uses: ossf/scorecard-action@c8416b0b2bf627c349ca92fc8e3de51a64b005cf # v1.0.2 uses: ossf/scorecard-action@c8416b0b2bf627c349ca92fc8e3de51a64b005cf # v1.0.2
with: with:
results_file: results.sarif results_file: results.sarif
@ -37,7 +37,7 @@ jobs:
publish_results: true publish_results: true
# Upload the results as artifacts (optional). # Upload the results as artifacts (optional).
- name: "Upload artifact" - name: 'Upload artifact'
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2.3.1 uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2.3.1
with: with:
name: SARIF file name: SARIF file
@ -45,7 +45,7 @@ jobs:
retention-days: 5 retention-days: 5
# Upload the results to GitHubs code scanning dashboard. # Upload the results to GitHubs code scanning dashboard.
- name: "Upload to code-scanning" - name: 'Upload to code-scanning'
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26 uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
with: with:
sarif_file: results.sarif sarif_file: results.sarif

View File

@ -6,5 +6,11 @@ vendor/
package-lock.json package-lock.json
yarn.lock yarn.lock
package.json package.json
docs-api-json/
docs-dist/ docs-dist/
website/ website/
experimental/
CHANGELOG.md
test/assets/
/.local-chromium/
/.local-firefox/

View File

@ -1,4 +1,5 @@
<!-- prettier-ignore-start --> <!-- prettier-ignore-start -->
<!-- gen:toc --> <!-- gen:toc -->
- [How to Contribute](#how-to-contribute) - [How to Contribute](#how-to-contribute)
* [Contributor License Agreement](#contributor-license-agreement) * [Contributor License Agreement](#contributor-license-agreement)
@ -24,7 +25,9 @@
- [Bisecting upstream changes](#bisecting-upstream-changes) - [Bisecting upstream changes](#bisecting-upstream-changes)
* [Releasing to npm](#releasing-to-npm) * [Releasing to npm](#releasing-to-npm)
<!-- gen:stop --> <!-- gen:stop -->
<!-- prettier-ignore-end --> <!-- prettier-ignore-end -->
# How to Contribute # How to Contribute
First of all, thank you for your interest in Puppeteer! First of all, thank you for your interest in Puppeteer!
@ -128,7 +131,6 @@ We also maintain `test/tsconfig.test.json`. This is **only used to compile the u
The root `tsconfig.json` exists for the API Extractor; it has to find a `tsconfig.json` in the project's root directory. It is _not_ used for anything else. The root `tsconfig.json` exists for the API Extractor; it has to find a `tsconfig.json` in the project's root directory. It is _not_ used for anything else.
## API guidelines ## API guidelines
When authoring new API methods, consider the following: When authoring new API methods, consider the following:
@ -170,7 +172,7 @@ npm run doc
To format the documentation markdown and its code snippets, use: To format the documentation markdown and its code snippets, use:
```bash ```bash
npm run markdownlint-fix npm run prettier-fix
``` ```
## Writing TSDoc Comments ## Writing TSDoc Comments
@ -180,27 +182,26 @@ Each change to Puppeteer should be thoroughly documented using TSDoc comments. R
- Every new method needs to have either `@public` or `@internal` added as a tag depending on if it is part of the public API. - Every new method needs to have either `@public` or `@internal` added as a tag depending on if it is part of the public API.
- Keep each line in a comment to no more than 90 characters (ESLint will warn you if you go over this). If you're a VSCode user the [Rewrap plugin](https://marketplace.visualstudio.com/items?itemName=stkb.rewrap) is highly recommended! - Keep each line in a comment to no more than 90 characters (ESLint will warn you if you go over this). If you're a VSCode user the [Rewrap plugin](https://marketplace.visualstudio.com/items?itemName=stkb.rewrap) is highly recommended!
## Running New Documentation website locally ## Running New Documentation website locally
- In the Puppeteer's folder, install all dependencies with `npm i`. - In the Puppeteer's folder, install all dependencies with `npm i`.
- run `npm run generate-docs` which will generate all the `.md` files on `puppeteer/website/docs`. - run `npm run generate-docs` which will generate all the `.md` files on `puppeteer/website/docs`.
- run `npm i` on `puppeteer/website`. - run `npm i` on `puppeteer/website`.
- run `npm start` on `puppeteer/website`. - run `npm start` on `puppeteer/website`.
## Adding New Dependencies ## Adding New Dependencies
For all dependencies (both installation and development): For all dependencies (both installation and development):
- **Do not add** a dependency if the desired functionality is easily implementable. - **Do not add** a dependency if the desired functionality is easily implementable.
- If adding a dependency, it should be well-maintained and trustworthy. - If adding a dependency, it should be well-maintained and trustworthy.
A barrier for introducing new installation dependencies is especially high: A barrier for introducing new installation dependencies is especially high:
- **Do not add** installation dependency unless it's critical to project success. - **Do not add** installation dependency unless it's critical to project success.
There are additional considerations for dependencies that are environment agonistic. See the [`vendor/README.md`](https://github.com/puppeteer/puppeteer/blob/main/vendor/README.md) for details. There are additional considerations for dependencies that are environment agonistic. See the [`vendor/README.md`](https://github.com/puppeteer/puppeteer/blob/main/vendor/README.md) for details.
## Running & Writing Tests ## Running & Writing Tests
- Every feature should be accompanied by a test. - Every feature should be accompanied by a test.
@ -228,7 +229,7 @@ npm run unit
}); });
``` ```
- To disable a specific test, substitute the `it` with `xit` (mnemonic rule: '*cross it*'): - To disable a specific test, substitute the `it` with `xit` (mnemonic rule: '_cross it_'):
```js ```js
... ...
@ -307,14 +308,14 @@ By default, it will use the Chromium revision in `src/revisions.ts` from the `ma
Releasing to npm consists of the following phases: Releasing to npm consists of the following phases:
1. Source Code: mark a release. 1. Source Code: mark a release.
1. Run `npm run release`. (This automatically bumps the version number in `package.json`, populates the changelog, updates the docs, and creates a Git commit for the next step.) 1. Run `npm run release`. (This automatically bumps the version number in `package.json`, populates the changelog, updates the docs, and creates a Git commit for the next step.)
1. Send a PR for the commit created in the previous step. 1. Send a PR for the commit created in the previous step.
1. Make sure the PR passes **all checks**. 1. Make sure the PR passes **all checks**.
- **WHY**: there are linters in place that help to avoid unnecessary errors, e.g. [like this](https://github.com/puppeteer/puppeteer/pull/2446) - **WHY**: there are linters in place that help to avoid unnecessary errors, e.g. [like this](https://github.com/puppeteer/puppeteer/pull/2446)
1. Merge the PR. 1. Merge the PR.
1. Once merged, publish the release notes from `CHANGELOG.md` using [GitHubs “draft new release tag” option](https://github.com/puppeteer/puppeteer/releases/new). 1. Once merged, publish the release notes from `CHANGELOG.md` using [GitHubs “draft new release tag” option](https://github.com/puppeteer/puppeteer/releases/new).
- **NOTE**: tag names are prefixed with `'v'`, e.g. for version `1.4.0` the tag is `v1.4.0`. - **NOTE**: tag names are prefixed with `'v'`, e.g. for version `1.4.0` the tag is `v1.4.0`.
1. As soon as the Git tag is created by completing the previous step, our CI automatically `npm publish`es the new releases for both the `puppeteer` and `puppeteer-core` packages. 1. As soon as the Git tag is created by completing the previous step, our CI automatically `npm publish`es the new releases for both the `puppeteer` and `puppeteer-core` packages.
1. Source Code: mark post-release. 1. Source Code: mark post-release.
1. Bump `package.json` version to the `-post` version, run `npm run doc` to update the “released APIs” section at the top of `docs/api.md` accordingly, and send a PR titled `'chore: bump version to vXXX.YYY.ZZZ-post'` ([example](https://github.com/puppeteer/puppeteer/pull/6808)) 1. Bump `package.json` version to the `-post` version, run `npm run doc` to update the “released APIs” section at the top of `docs/api.md` accordingly, and send a PR titled `'chore: bump version to vXXX.YYY.ZZZ-post'` ([example](https://github.com/puppeteer/puppeteer/pull/6808))
- **NOTE**: no other commits should be landed in-between release commit and bump commit. - **NOTE**: no other commits should be landed in-between release commit and bump commit.

View File

@ -902,6 +902,7 @@ Closes Chromium and all of its pages (if any were opened). The [Browser] object
During the process of closing the browser, Puppeteer attempts to delete the temp folder created exclusively for this browser instance. If this fails (either because a file in the temp folder is locked by another process or because of insufficient permissions) an error is logged. This implies that: a) the folder and/or its content is not fully deleted; and b) the connection with the browser is not properly disposed (see [browser.disconnect()](#browserdisconnect)). During the process of closing the browser, Puppeteer attempts to delete the temp folder created exclusively for this browser instance. If this fails (either because a file in the temp folder is locked by another process or because of insufficient permissions) an error is logged. This implies that: a) the folder and/or its content is not fully deleted; and b) the connection with the browser is not properly disposed (see [browser.disconnect()](#browserdisconnect)).
#### browser.createIncognitoBrowserContext([options]) #### browser.createIncognitoBrowserContext([options])
- `options` <[Object]> Set of configurable options to set on the browserContext. Can have the following fields: - `options` <[Object]> Set of configurable options to set on the browserContext. Can have the following fields:
- `proxyServer` <[string]> Optional proxy server with optional port to use for all requests. Username and password can be set in [page.authenticate(credentials)](#pageauthenticatecredentials). - `proxyServer` <[string]> Optional proxy server with optional port to use for all requests. Username and password can be set in [page.authenticate(credentials)](#pageauthenticatecredentials).
- `proxyBypassList` <[string]> Optional: Bypass the proxy for the given semi-colon-separated list of hosts. - `proxyBypassList` <[string]> Optional: Bypass the proxy for the given semi-colon-separated list of hosts.
@ -2427,7 +2428,7 @@ page.on('request', (interceptedRequest) => {
if (interceptedRequest.isInterceptResolutionHandled()) return; if (interceptedRequest.isInterceptResolutionHandled()) return;
// It is not strictly necessary to return a promise, but doing so will allow Puppeteer to await this handler. // It is not strictly necessary to return a promise, but doing so will allow Puppeteer to await this handler.
return new Promise(resolve => { return new Promise((resolve) => {
// Continue after 500ms // Continue after 500ms
setTimeout(() => { setTimeout(() => {
// Inside, check synchronously to verify that the intercept wasn't handled already. // Inside, check synchronously to verify that the intercept wasn't handled already.
@ -2439,13 +2440,13 @@ page.on('request', (interceptedRequest) => {
interceptedRequest.continue(); interceptedRequest.continue();
resolve(); resolve();
}, 500); }, 500);
}) });
}); });
page.on('request', async (interceptedRequest) => { page.on('request', async (interceptedRequest) => {
// The interception has not been handled yet. Control will pass through this guard. // The interception has not been handled yet. Control will pass through this guard.
if (interceptedRequest.isInterceptResolutionHandled()) return; if (interceptedRequest.isInterceptResolutionHandled()) return;
await someLongAsyncOperation() await someLongAsyncOperation();
// The interception *MIGHT* have been handled by the first handler, we can't be sure. // The interception *MIGHT* have been handled by the first handler, we can't be sure.
// Therefore, we must check again before calling continue() or we risk Puppeteer raising an exception. // Therefore, we must check again before calling continue() or we risk Puppeteer raising an exception.
if (interceptedRequest.isInterceptResolutionHandled()) return; if (interceptedRequest.isInterceptResolutionHandled()) return;
@ -2467,7 +2468,7 @@ page.on('request', (interceptedRequest) => {
if (action === InterceptResolutionAction.AlreadyHandled) return; if (action === InterceptResolutionAction.AlreadyHandled) return;
// It is not strictly necessary to return a promise, but doing so will allow Puppeteer to await this handler. // It is not strictly necessary to return a promise, but doing so will allow Puppeteer to await this handler.
return new Promise(resolve => { return new Promise((resolve) => {
// Continue after 500ms // Continue after 500ms
setTimeout(() => { setTimeout(() => {
// Inside, check synchronously to verify that the intercept wasn't handled already. // Inside, check synchronously to verify that the intercept wasn't handled already.
@ -2476,20 +2477,28 @@ page.on('request', (interceptedRequest) => {
if (action === InterceptResolutionAction.AlreadyHandled) { if (action === InterceptResolutionAction.AlreadyHandled) {
resolve(); resolve();
return; return;
}; }
interceptedRequest.continue(); interceptedRequest.continue();
resolve(); resolve();
}, 500); }, 500);
}) });
}); });
page.on('request', async (interceptedRequest) => { page.on('request', async (interceptedRequest) => {
// The interception has not been handled yet. Control will pass through this guard. // The interception has not been handled yet. Control will pass through this guard.
if (interceptedRequest.interceptResolutionState().action === InterceptResolutionAction.AlreadyHandled) return; if (
interceptedRequest.interceptResolutionState().action ===
InterceptResolutionAction.AlreadyHandled
)
return;
await someLongAsyncOperation() await someLongAsyncOperation();
// The interception *MIGHT* have been handled by the first handler, we can't be sure. // The interception *MIGHT* have been handled by the first handler, we can't be sure.
// Therefore, we must check again before calling continue() or we risk Puppeteer raising an exception. // Therefore, we must check again before calling continue() or we risk Puppeteer raising an exception.
if (interceptedRequest.interceptResolutionState().action === InterceptResolutionAction.AlreadyHandled) return; if (
interceptedRequest.interceptResolutionState().action ===
InterceptResolutionAction.AlreadyHandled
)
return;
interceptedRequest.continue(); interceptedRequest.continue();
}); });
``` ```
@ -2517,13 +2526,13 @@ In this example, Legacy Mode prevails and the request is aborted immediately bec
// Final outcome: immediate abort() // Final outcome: immediate abort()
page.setRequestInterception(true); page.setRequestInterception(true);
page.on('request', (request) => { page.on('request', (request) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
// Legacy Mode: interception is aborted immediately. // Legacy Mode: interception is aborted immediately.
request.abort('failed'); request.abort('failed');
}); });
page.on('request', (request) => { page.on('request', (request) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
// Control will never reach this point because the request was already aborted in Legacy Mode // Control will never reach this point because the request was already aborted in Legacy Mode
// Cooperative Intercept Mode: votes for continue at priority 0. // Cooperative Intercept Mode: votes for continue at priority 0.
@ -2537,13 +2546,13 @@ In this example, Legacy Mode prevails and the request is continued because at le
// Final outcome: immediate continue() // Final outcome: immediate continue()
page.setRequestInterception(true); page.setRequestInterception(true);
page.on('request', (request) => { page.on('request', (request) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
// Cooperative Intercept Mode: votes to abort at priority 0. // Cooperative Intercept Mode: votes to abort at priority 0.
request.abort('failed', 0); request.abort('failed', 0);
}); });
page.on('request', (request) => { page.on('request', (request) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
// Control reaches this point because the request was cooperatively aborted which postpones resolution. // Control reaches this point because the request was cooperatively aborted which postpones resolution.
@ -2557,7 +2566,6 @@ page.on('request', (request) => {
// { action: InterceptResolutionAction.AlreadyHandled }, because continue in Legacy Mode was called // { action: InterceptResolutionAction.AlreadyHandled }, because continue in Legacy Mode was called
console.log(request.interceptResolutionState()); console.log(request.interceptResolutionState());
}); });
``` ```
In this example, Cooperative Intercept Mode is active because all handlers specify a `priority`. `continue()` wins because it has a higher priority than `abort()`. In this example, Cooperative Intercept Mode is active because all handlers specify a `priority`. `continue()` wins because it has a higher priority than `abort()`.
@ -2566,13 +2574,13 @@ In this example, Cooperative Intercept Mode is active because all handlers speci
// Final outcome: cooperative continue() @ 5 // Final outcome: cooperative continue() @ 5
page.setRequestInterception(true); page.setRequestInterception(true);
page.on('request', (request) => { page.on('request', (request) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
// Cooperative Intercept Mode: votes to abort at priority 10 // Cooperative Intercept Mode: votes to abort at priority 10
request.abort('failed', 0); request.abort('failed', 0);
}); });
page.on('request', (request) => { page.on('request', (request) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
// Cooperative Intercept Mode: votes to continue at priority 5 // Cooperative Intercept Mode: votes to continue at priority 5
request.continue(request.continueRequestOverrides(), 5); request.continue(request.continueRequestOverrides(), 5);
@ -2589,25 +2597,25 @@ In this example, Cooperative Intercept Mode is active because all handlers speci
// Final outcome: cooperative respond() @ 15 // Final outcome: cooperative respond() @ 15
page.setRequestInterception(true); page.setRequestInterception(true);
page.on('request', (request) => { page.on('request', (request) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
// Cooperative Intercept Mode: votes to abort at priority 10 // Cooperative Intercept Mode: votes to abort at priority 10
request.abort('failed', 10); request.abort('failed', 10);
}); });
page.on('request', (request) => { page.on('request', (request) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
// Cooperative Intercept Mode: votes to continue at priority 15 // Cooperative Intercept Mode: votes to continue at priority 15
request.continue(request.continueRequestOverrides(), 15); request.continue(request.continueRequestOverrides(), 15);
}); });
page.on('request', (request) => { page.on('request', (request) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
// Cooperative Intercept Mode: votes to respond at priority 15 // Cooperative Intercept Mode: votes to respond at priority 15
request.respond(request.responseForRequest(), 15); request.respond(request.responseForRequest(), 15);
}); });
page.on('request', (request) => { page.on('request', (request) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
// Cooperative Intercept Mode: votes to respond at priority 12 // Cooperative Intercept Mode: votes to respond at priority 12
request.respond(request.responseForRequest(), 12); request.respond(request.responseForRequest(), 12);
@ -2640,7 +2648,7 @@ If you are package maintainer and your package uses intercept handlers, you can
```ts ```ts
page.on('request', (interceptedRequest) => { page.on('request', (interceptedRequest) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
if ( if (
interceptedRequest.url().endsWith('.png') || interceptedRequest.url().endsWith('.png') ||
interceptedRequest.url().endsWith('.jpg') interceptedRequest.url().endsWith('.jpg')
@ -2654,7 +2662,7 @@ To use Cooperative Intercept Mode, upgrade `continue()` and `abort()`:
```ts ```ts
page.on('request', (interceptedRequest) => { page.on('request', (interceptedRequest) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
if ( if (
interceptedRequest.url().endsWith('.png') || interceptedRequest.url().endsWith('.png') ||
interceptedRequest.url().endsWith('.jpg') interceptedRequest.url().endsWith('.jpg')
@ -2690,7 +2698,7 @@ export const setInterceptResolutionConfig = (priority = 0) =>
* the default priority when your handler has no opinion on the request and the intent is to continue() by default. * the default priority when your handler has no opinion on the request and the intent is to continue() by default.
*/ */
page.on('request', (interceptedRequest) => { page.on('request', (interceptedRequest) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
if ( if (
interceptedRequest.url().endsWith('.png') || interceptedRequest.url().endsWith('.png') ||
interceptedRequest.url().endsWith('.jpg') interceptedRequest.url().endsWith('.jpg')
@ -2699,7 +2707,7 @@ page.on('request', (interceptedRequest) => {
else else
interceptedRequest.continue( interceptedRequest.continue(
interceptedRequest.continueRequestOverrides(), interceptedRequest.continueRequestOverrides(),
DEFAULT_INTERCEPT_RESOLUTION_PRIORITY // Unopinionated continuation DEFAULT_INTERCEPT_RESOLUTION_PRIORITY // Unopinionated continuation
); );
}); });
``` ```
@ -2716,35 +2724,34 @@ interface InterceptResolutionConfig {
// differences. You could, for example, create a config that // differences. You could, for example, create a config that
// allowed separate priorities for PNG vs JPG. // allowed separate priorities for PNG vs JPG.
const DEFAULT_CONFIG: InterceptResolutionConfig = { const DEFAULT_CONFIG: InterceptResolutionConfig = {
abortPriority: undefined, // Default to Legacy Mode abortPriority: undefined, // Default to Legacy Mode
continuePriority: undefined, // Default to Legacy Mode continuePriority: undefined, // Default to Legacy Mode
}; };
// Defaults to undefined which preserves Legacy Mode behavior // Defaults to undefined which preserves Legacy Mode behavior
let _config: Partial<InterceptResolutionConfig> = {}; let _config: Partial<InterceptResolutionConfig> = {};
export const setInterceptResolutionConfig = (config: InterceptResolutionConfig) => export const setInterceptResolutionConfig = (
(_config = { ...DEFAULT_CONFIG, ...config }); config: InterceptResolutionConfig
) => (_config = { ...DEFAULT_CONFIG, ...config });
page.on('request', (interceptedRequest) => { page.on('request', (interceptedRequest) => {
if (request.isInterceptResolutionHandled()) return if (request.isInterceptResolutionHandled()) return;
if ( if (
interceptedRequest.url().endsWith('.png') || interceptedRequest.url().endsWith('.png') ||
interceptedRequest.url().endsWith('.jpg') interceptedRequest.url().endsWith('.jpg')
) { ) {
interceptedRequest.abort('failed', _config.abortPriority); interceptedRequest.abort('failed', _config.abortPriority);
} } else {
else // Here we use a custom-configured priority to allow for Opinionated
{ // continuation.
// Here we use a custom-configured priority to allow for Opinionated // We would only want to allow this if we had a very clear reason why
// continuation. // some use cases required Opinionated continuation.
// We would only want to allow this if we had a very clear reason why interceptedRequest.continue(
// some use cases required Opinionated continuation. interceptedRequest.continueRequestOverrides(),
interceptedRequest.continue( _config.continuePriority // Why would we ever want priority!==0 here?
interceptedRequest.continueRequestOverrides(), );
_config.continuePriority // Why would we ever want priority!==0 here? }
);
}
}); });
``` ```
@ -3046,6 +3053,7 @@ const [response] = await Promise.all([
Shortcut for [page.mainFrame().waitForNavigation(options)](#framewaitfornavigationoptions). Shortcut for [page.mainFrame().waitForNavigation(options)](#framewaitfornavigationoptions).
#### page.waitForNetworkIdle([options]) #### page.waitForNetworkIdle([options])
- `options` <[Object]> Optional waiting parameters - `options` <[Object]> Optional waiting parameters
- `timeout` <[number]> Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be changed by using the [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) method. - `timeout` <[number]> Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be changed by using the [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) method.
- `idleTime` <[number]> How long to wait for no network requests in milliseconds, defaults to 500 milliseconds. - `idleTime` <[number]> How long to wait for no network requests in milliseconds, defaults to 500 milliseconds.
@ -4784,6 +4792,7 @@ This method scrolls element into view if needed, and then uses [page.mouse](#pag
If the element is detached from DOM, the method throws an error. If the element is detached from DOM, the method throws an error.
#### elementHandle.isIntersectingViewport([options]) #### elementHandle.isIntersectingViewport([options])
- `options` <[Object]> - `options` <[Object]>
- `threshold` <[number]> threshold for the intersection between 0 (no intersection) and 1 (full intersection). Defaults to 1. - `threshold` <[number]> threshold for the intersection between 0 (no intersection) and 1 (full intersection). Defaults to 1.
- returns: <[Promise]<[boolean]>> Resolves to true if the element is visible in the current viewport. - returns: <[Promise]<[boolean]>> Resolves to true if the element is visible in the current viewport.
@ -4952,7 +4961,7 @@ await page.setRequestInterception(true);
page.on('request', (request) => { page.on('request', (request) => {
if (request.isInterceptResolutionHandled()) return; if (request.isInterceptResolutionHandled()) return;
// Override headers // Override headers
const headers = Object.assign({}, request.headers(), { const headers = Object.assign({}, request.headers(), {
foo: 'bar', // set "foo" header foo: 'bar', // set "foo" header
origin: undefined, // remove "origin" header origin: undefined, // remove "origin" header

View File

@ -20,10 +20,10 @@ For issues, feature requests, or setup troubles with Puppeteer, file an issue ri
**Tell us about your environment:** **Tell us about your environment:**
* Puppeteer version: - Puppeteer version:
* Platform / OS version: - Platform / OS version:
* URLs (if applicable): - URLs (if applicable):
* Node.js version: - Node.js version:
**What steps will reproduce the problem?** **What steps will reproduce the problem?**
@ -35,6 +35,4 @@ _Please include code that reproduces the issue._
**What is the expected result?** **What is the expected result?**
**What happens instead?** **What happens instead?**

View File

@ -24,9 +24,9 @@
"eslint": "([ \"$CI\" = true ] && eslint --ext js --ext ts --quiet -f codeframe . || eslint --ext js --ext ts .)", "eslint": "([ \"$CI\" = true ] && eslint --ext js --ext ts --quiet -f codeframe . || eslint --ext js --ext ts .)",
"eslint-fix": "eslint --ext js --ext ts --fix .", "eslint-fix": "eslint --ext js --ext ts --fix .",
"commitlint": "commitlint --from=HEAD~1", "commitlint": "commitlint --from=HEAD~1",
"markdownlint": "prettier --check **/README.md docs/troubleshooting.md", "prettier": "prettier --check .",
"markdownlint-fix": "prettier --write **/README.md docs/troubleshooting.md", "prettier-fix": "prettier --write .",
"lint": "npm run eslint && npm run build && npm run doc && npm run markdownlint", "lint": "npm run eslint && npm run build && npm run doc && npm run prettier",
"doc": "node utils/doclint/cli.js", "doc": "node utils/doclint/cli.js",
"clean-lib": "rimraf lib", "clean-lib": "rimraf lib",
"build": "npm run tsc && npm run generate-d-ts", "build": "npm run tsc && npm run generate-d-ts",

View File

@ -5,7 +5,5 @@
"outDir": "../lib/cjs/puppeteer", "outDir": "../lib/cjs/puppeteer",
"module": "CommonJS" "module": "CommonJS"
}, },
"references": [ "references": [{ "path": "../vendor/tsconfig.cjs.json" }]
{ "path": "../vendor/tsconfig.cjs.json"}
]
} }

View File

@ -9,9 +9,9 @@ async function run() {
const browser2 = await puppeteer.launch(); const browser2 = await puppeteer.launch();
// 'foo' is invalid argument // 'foo' is invalid argument
const page = await browser2.newPage('foo'); const page = await browser2.newPage('foo');
const div = (await page.$('div')) as puppeteer.ElementHandle< const div = (await page.$(
HTMLAnchorElement 'div'
>; )) as puppeteer.ElementHandle<HTMLAnchorElement>;
console.log('got a div!', div); console.log('got a div!', div);
} }
run(); run();

View File

@ -8,9 +8,9 @@ async function run() {
page.on('request', (request) => { page.on('request', (request) => {
const resourceType = request.resourceType(); const resourceType = request.resourceType();
}); });
const div = (await page.$('div')) as puppeteer.ElementHandle< const div = (await page.$(
HTMLAnchorElement 'div'
>; )) as puppeteer.ElementHandle<HTMLAnchorElement>;
console.log('got a div!', div); console.log('got a div!', div);
} }
run(); run();

View File

@ -10,9 +10,9 @@ async function run() {
const browser2 = await puppeteer.launch(); const browser2 = await puppeteer.launch();
// 'foo' is invalid argument // 'foo' is invalid argument
const page = await browser2.newPage('foo'); const page = await browser2.newPage('foo');
const div = (await page.$('div')) as puppeteer.ElementHandle< const div = (await page.$(
HTMLAnchorElement 'div'
>; )) as puppeteer.ElementHandle<HTMLAnchorElement>;
console.log('got a div!', div); console.log('got a div!', div);
} }
run(); run();

View File

@ -1,13 +1,13 @@
body { body {
font-family: monospace; font-family: monospace;
white-space: pre; white-space: pre;
} }
ins { ins {
background-color: #9cffa0; background-color: #9cffa0;
text-decoration: none; text-decoration: none;
} }
del { del {
background-color: #ff9e9e; background-color: #ff9e9e;
} }