fix: deprecate ExecutionContext (#8792)

This commit is contained in:
jrandolf 2022-08-16 08:22:45 +02:00 committed by GitHub
parent 90aa628fcc
commit b5da718e2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 57 additions and 33 deletions

View File

@ -21,9 +21,9 @@ sidebar_label: API
| [Dialog](./puppeteer.dialog.md) | Dialog instances are dispatched by the [Page](./puppeteer.page.md) via the <code>dialog</code> event. |
| [ElementHandle](./puppeteer.elementhandle.md) | ElementHandle represents an in-page DOM element. |
| [EventEmitter](./puppeteer.eventemitter.md) | The EventEmitter class that many Puppeteer classes extend. |
| [ExecutionContext](./puppeteer.executioncontext.md) | Represents a context for JavaScript execution. |
| [ExecutionContext](./puppeteer.executioncontext.md) | |
| [FileChooser](./puppeteer.filechooser.md) | File choosers let you react to the page requesting for a file. |
| [Frame](./puppeteer.frame.md) | At every point of time, page exposes its current frame tree via the [page.mainFrame](./puppeteer.page.mainframe.md) and [frame.childFrames](./puppeteer.frame.childframes.md) methods. |
| [Frame](./puppeteer.frame.md) | <p>Represents a DOM frame.</p><p>To understand frames, you can think of frames as <code>&lt;iframe&gt;</code> elements. Just like iframes, frames can be nested, and when JavaScript is executed in a frame, the JavaScript does not effect frames inside the ambient frame the JavaScript executes in.</p> |
| [HTTPRequest](./puppeteer.httprequest.md) | Represents an HTTP request sent by a page. |
| [HTTPResponse](./puppeteer.httpresponse.md) | The HTTPResponse class represents responses which are received by the [Page](./puppeteer.page.md) class. |
| [JSCoverage](./puppeteer.jscoverage.md) | |

View File

@ -4,7 +4,11 @@ sidebar_label: ExecutionContext
# ExecutionContext class
Represents a context for JavaScript execution.
> Warning: This API is now obsolete.
>
> Do not use directly.
>
> Represents a context for JavaScript execution.
**Signature:**

View File

@ -22,10 +22,10 @@ class Frame {
## Parameters
| Parameter | Type | Description |
| ------------ | -------------- | ------------------------------------------ |
| pageFunction | Func \| string | a function that is run within the frame |
| args | Params | arguments to be passed to the pageFunction |
| Parameter | Type | Description |
| ------------ | -------------- | ----------- |
| pageFunction | Func \| string | |
| args | Params | |
**Returns:**

View File

@ -22,10 +22,10 @@ class Frame {
## Parameters
| Parameter | Type | Description |
| ------------ | -------------- | ------------------------------------------ |
| pageFunction | Func \| string | a function that is run within the frame |
| args | Params | arguments to be passed to the pageFunction |
| Parameter | Type | Description |
| ------------ | -------------- | ----------- |
| pageFunction | Func \| string | |
| args | Params | |
**Returns:**

View File

@ -4,6 +4,10 @@ sidebar_label: Frame.executionContext
# Frame.executionContext() method
> Warning: This API is now obsolete.
>
> Do not use the execution context directly.
**Signature:**
```typescript

View File

@ -16,4 +16,4 @@ class Frame {
boolean
`true` if the frame is an OOP frame, or `false` otherwise.
`true` if the frame is an out-of-process (OOP) frame. Otherwise, `false`.

View File

@ -4,7 +4,9 @@ sidebar_label: Frame
# Frame class
At every point of time, page exposes its current frame tree via the [page.mainFrame](./puppeteer.page.mainframe.md) and [frame.childFrames](./puppeteer.frame.childframes.md) methods.
Represents a DOM frame.
To understand frames, you can think of frames as `<iframe>` elements. Just like iframes, frames can be nested, and when JavaScript is executed in a frame, the JavaScript does not effect frames inside the ambient frame the JavaScript executes in.
**Signature:**
@ -14,7 +16,7 @@ export declare class Frame
## Remarks
`Frame` object lifecycles are controlled by three events that are all dispatched on the page object:
Frame lifecycles are controlled by three events that are all dispatched on the parent [page](./puppeteer.frame.page.md):
- [PageEmittedEvents.FrameAttached](./puppeteer.pageemittedevents.md) - [PageEmittedEvents.FrameNavigated](./puppeteer.pageemittedevents.md) - [PageEmittedEvents.FrameDetached](./puppeteer.pageemittedevents.md)
@ -22,6 +24,10 @@ The constructor for this class is marked as internal. Third-party code should no
## Example 1
At any point in time, [pages](./puppeteer.page.md) expose their current frame tree via the [Page.mainFrame()](./puppeteer.page.mainframe.md) and [Frame.childFrames()](./puppeteer.frame.childframes.md) methods.
## Example 2
An example of dumping frame tree:
```ts
@ -43,7 +49,7 @@ const puppeteer = require('puppeteer');
})();
```
## Example 2
## Example 3
An example of getting text from an iframe element:
@ -86,6 +92,6 @@ console.log(text);
| [url()](./puppeteer.frame.url.md) | | |
| [waitForFunction(pageFunction, options, args)](./puppeteer.frame.waitforfunction.md) | | |
| [waitForNavigation(options)](./puppeteer.frame.waitfornavigation.md) | | <p>Waits for the frame to navigate. It is useful for when you run code which will indirectly cause the frame to navigate.</p><p>Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered a navigation.</p> |
| [waitForSelector(selector, options)](./puppeteer.frame.waitforselector.md) | | <p>Wait for an element matching the given selector to appear in the frame.</p><p>This method works across navigations.</p> |
| [waitForSelector(selector, options)](./puppeteer.frame.waitforselector.md) | | <p>Waits for an element matching the given selector to appear in the frame.</p><p>This method works across navigations.</p> |
| [waitForTimeout(milliseconds)](./puppeteer.frame.waitfortimeout.md) | | Causes your script to wait for the given number of milliseconds. |
| [waitForXPath(xpath, options)](./puppeteer.frame.waitforxpath.md) | | |

View File

@ -4,7 +4,7 @@ sidebar_label: Frame.waitForSelector
# Frame.waitForSelector() method
Wait for an element matching the given selector to appear in the frame.
Waits for an element matching the given selector to appear in the frame.
This method works across navigations.

2
package-lock.json generated
View File

@ -54,7 +54,7 @@
"eslint-config-prettier": "8.5.0",
"eslint-formatter-codeframe": "7.32.1",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-local": "^1.0.0",
"eslint-plugin-local": "1.0.0",
"eslint-plugin-mocha": "10.1.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-tsdoc": "0.2.16",

View File

@ -35,6 +35,8 @@ export const EVALUATION_SCRIPT_URL = 'pptr://__puppeteer_evaluation_script__';
const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;
/**
* @deprecated Do not use directly.
*
* Represents a context for JavaScript execution.
*
* @example

View File

@ -602,17 +602,16 @@ export interface FrameAddStyleTagOptions {
}
/**
* At every point of time, page exposes its current frame tree via the
* {@link Page.mainFrame | page.mainFrame} and
* {@link Frame.childFrames | frame.childFrames} methods.
* Represents a DOM frame.
*
* @remarks
* `Frame` object lifecycles are controlled by three events that are all
* dispatched on the page object:
* To understand frames, you can think of frames as `<iframe>` elements. Just
* like iframes, frames can be nested, and when JavaScript is executed in a
* frame, the JavaScript does not effect frames inside the ambient frame the
* JavaScript executes in.
*
* - {@link PageEmittedEvents.FrameAttached}
* - {@link PageEmittedEvents.FrameNavigated}
* - {@link PageEmittedEvents.FrameDetached}
* @example
* At any point in time, {@link Page | pages} expose their current frame
* tree via the {@link Page.mainFrame} and {@link Frame.childFrames} methods.
*
* @example
* An example of dumping frame tree:
@ -645,6 +644,14 @@ export interface FrameAddStyleTagOptions {
* console.log(text);
* ```
*
* @remarks
* Frame lifecycles are controlled by three events that are all dispatched on
* the parent {@link Frame.page | page}:
*
* - {@link PageEmittedEvents.FrameAttached}
* - {@link PageEmittedEvents.FrameNavigated}
* - {@link PageEmittedEvents.FrameDetached}
*
* @public
*/
export class Frame {
@ -740,7 +747,8 @@ export class Frame {
}
/**
* @returns `true` if the frame is an OOP frame, or `false` otherwise.
* @returns `true` if the frame is an out-of-process (OOP) frame. Otherwise,
* `false`.
*/
isOOPFrame(): boolean {
return this.#client !== this._frameManager.client;
@ -915,6 +923,8 @@ export class Frame {
}
/**
* @deprecated Do not use the execution context directly.
*
* @returns a promise that resolves to the frame's default execution context.
*/
executionContext(): Promise<ExecutionContext> {
@ -925,8 +935,7 @@ export class Frame {
* Behaves identically to {@link Page.evaluateHandle} except it's run within
* the context of this frame.
*
* @param pageFunction - a function that is run within the frame
* @param args - arguments to be passed to the pageFunction
* @see {@link Page.evaluateHandle} for details.
*/
async evaluateHandle<
Params extends unknown[],
@ -942,8 +951,7 @@ export class Frame {
* Behaves identically to {@link Page.evaluate} except it's run within the
* the context of this frame.
*
* @param pageFunction - a function that is run within the frame
* @param args - arguments to be passed to the pageFunction
* @see {@link Page.evaluate} for details.
*/
async evaluate<
Params extends unknown[],
@ -1060,7 +1068,7 @@ export class Frame {
}
/**
* Wait for an element matching the given selector to appear in the frame.
* Waits for an element matching the given selector to appear in the frame.
*
* This method works across navigations.
*