From 0c8174b987ad4a44abbb5a7d281d588bc9346da0 Mon Sep 17 00:00:00 2001 From: Andreas Opferkuch Date: Tue, 19 Apr 2022 14:48:22 +0200 Subject: [PATCH 1/3] docs: improve custom query handler docs (#8235) --- docs/api.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/api.md b/docs/api.md index f1606dd1d3efb..65ec66ee0482c 100644 --- a/docs/api.md +++ b/docs/api.md @@ -721,7 +721,7 @@ The product is set by the `PUPPETEER_PRODUCT` environment variable or the `produ - `name` <[string]> The name that the custom query handler will be registered under. - `queryHandler` <[CustomQueryHandler]> The [custom query handler](#interface-customqueryhandler) to register. -Registers a [custom query handler](#interface-customqueryhandler). After registration, the handler can be used everywhere where a selector is expected by prepending the selection string with `/`. The name is only allowed to consist of lower and upper case Latin letters. +Registers a [custom query handler](#interface-customqueryhandler). Example: @@ -5525,7 +5525,11 @@ This method is identical to `off` and maintained for compatibility with Node's E ### interface: CustomQueryHandler -Contains two functions `queryOne` and `queryAll` that can be [registered](#puppeteerregistercustomqueryhandlername-queryhandler) as alternative querying strategies. The functions `queryOne` and `queryAll` are executed in the page context. `queryOne` should take an `Element` and a selector string as argument and return a single `Element` or `null` if no element is found. `queryAll` takes the same arguments but should instead return a `NodeList` or `Array` with all the elements that match the given query selector. +After [registration](#puppeteerregistercustomqueryhandlername-queryhandler), the handler can be used everywhere where a selector is expected by prepending the selection string with `/`. The name is only allowed to consist of lower and upper case Latin letters. + +Contains two functions `queryOne` and `queryAll` that are executed in the page context. `queryOne` should take an `Element` and a selector string as argument and return a single `Element` or `null` if no element is found. `queryAll` takes the same arguments but should instead return a `NodeList` or `Array` with all the elements that match the given query selector. + +**NOTE:** Because the function code needs to be serialized, it is **not possible** to access anything outside its scope or use imports. See e.g. [the pierce handler](https://github.com/puppeteer/puppeteer/blob/v13.5.2/src/common/QueryHandler.ts#L115) which has redundancies because of this limitation. ### interface: Selector @@ -5534,7 +5538,7 @@ The default behavior is to regard the string as a [CSS selector] and query using If a selector string contains a forward slash `/` the selector is instead regarded as custom selector where everything before the slash is the [custom handler](#puppeteerregistercustomqueryhandlername-queryhandler) name and everything after is the selector: `/`. Puppeteer ships with two such custom handlers pre-registered: -- `aria/`: Queries the accessibilty tree for computed accessibility properties. +- `aria`: Queries the accessibilty tree for computed accessibility properties. The selectors consist of an accessible name to query for and optionally further aria attributes on the form `[=]`. Currently, we only support the `name` and `role` attribute. From e93faadc21b7fcb1e03b69c451c28b769f9cde51 Mon Sep 17 00:00:00 2001 From: Matheus Marabesi Date: Tue, 19 Apr 2022 15:24:53 +0200 Subject: [PATCH 2/3] fix(network.spec.ts): typo in the word should (#8223) --- test/network.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/network.spec.ts b/test/network.spec.ts index 0df5269814a3d..f776e0589815c 100644 --- a/test/network.spec.ts +++ b/test/network.spec.ts @@ -143,7 +143,7 @@ describe('network', function () { }); describeFailsFirefox('Request.initiator', () => { - it('shoud return the initiator', async () => { + it('should return the initiator', async () => { const { page, server } = getTestState(); const initiators = new Map(); From 4b786c904cbfe3f059322292f3b788b8a5ebd9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Tue, 19 Apr 2022 11:46:40 -0300 Subject: [PATCH 3/3] fix: forget request will be sent from the _requestWillBeSentMap list. (#8226) That forget looked wrong to me. Let me know if this change is correct. --- src/common/NetworkEventManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/NetworkEventManager.ts b/src/common/NetworkEventManager.ts index 704a79dc3ca3f..9743109447815 100644 --- a/src/common/NetworkEventManager.ts +++ b/src/common/NetworkEventManager.ts @@ -140,7 +140,7 @@ export class NetworkEventManager { } forgetRequestWillBeSent(networkRequestId: NetworkRequestId): void { - this._requestPausedMap.delete(networkRequestId); + this._requestWillBeSentMap.delete(networkRequestId); } getRequestPaused(