Skip to content

Commit

Permalink
fix!: internalize execution context (#8844)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf committed Aug 25, 2022
1 parent d070a73 commit 2f33237
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 368 deletions.
67 changes: 33 additions & 34 deletions docs/api/index.md

Large diffs are not rendered by default.

67 changes: 0 additions & 67 deletions docs/api/puppeteer.executioncontext.evaluate.md

This file was deleted.

75 changes: 0 additions & 75 deletions docs/api/puppeteer.executioncontext.evaluatehandle.md

This file was deleted.

23 changes: 0 additions & 23 deletions docs/api/puppeteer.executioncontext.frame.md

This file was deleted.

38 changes: 0 additions & 38 deletions docs/api/puppeteer.executioncontext.md

This file was deleted.

44 changes: 0 additions & 44 deletions docs/api/puppeteer.executioncontext.queryobjects.md

This file was deleted.

23 changes: 0 additions & 23 deletions docs/api/puppeteer.frame.executioncontext.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/api/puppeteer.frame.md
Expand Up @@ -75,7 +75,6 @@ console.log(text);
| [content()](./puppeteer.frame.content.md) | | |
| [evaluate(pageFunction, args)](./puppeteer.frame.evaluate.md) | | Behaves identically to [Page.evaluate()](./puppeteer.page.evaluate.md) except it's run within the the context of this frame. |
| [evaluateHandle(pageFunction, args)](./puppeteer.frame.evaluatehandle.md) | | Behaves identically to [Page.evaluateHandle()](./puppeteer.page.evaluatehandle.md) except it's run within the context of this frame. |
| [executionContext()](./puppeteer.frame.executioncontext.md) | | |
| [focus(selector)](./puppeteer.frame.focus.md) | | Focuses the first element that matches the <code>selector</code>. |
| [goto(url, options)](./puppeteer.frame.goto.md) | | Navigates a frame to the given url. |
| [hover(selector)](./puppeteer.frame.hover.md) | | Hovers the pointer over the center of the first element that matches the <code>selector</code>. |
Expand Down
19 changes: 0 additions & 19 deletions docs/api/puppeteer.jshandle.executioncontext.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/api/puppeteer.jshandle.md
Expand Up @@ -40,7 +40,6 @@ const windowHandle = await page.evaluateHandle(() => window);
| [dispose()](./puppeteer.jshandle.dispose.md) | | Releases the object referenced by the handle for garbage collection. |
| [evaluate(pageFunction, args)](./puppeteer.jshandle.evaluate.md) | | Evaluates the given function with the current handle as its first argument. |
| [evaluateHandle(pageFunction, args)](./puppeteer.jshandle.evaluatehandle.md) | | Evaluates the given function with the current handle as its first argument. |
| [executionContext()](./puppeteer.jshandle.executioncontext.md) | | |
| [getProperties()](./puppeteer.jshandle.getproperties.md) | | Gets a map of handles representing the properties of the current handle. |
| [getProperty(propertyName)](./puppeteer.jshandle.getproperty.md) | | Fetches a single property from the referenced object. |
| [getProperty(propertyName)](./puppeteer.jshandle.getproperty_1.md) | | |
Expand Down
4 changes: 0 additions & 4 deletions docs/api/puppeteer.page.queryobjects.md
Expand Up @@ -28,10 +28,6 @@ Promise&lt;[JSHandle](./puppeteer.jshandle.md)&lt;Prototype\[\]&gt;&gt;

Promise which resolves to a handle to an array of objects with this prototype.

## Remarks

Shortcut for [page.mainFrame().executionContext().queryObjects(prototypeHandle)](./puppeteer.executioncontext.queryobjects.md).

## Example

```ts
Expand Down
23 changes: 0 additions & 23 deletions docs/api/puppeteer.webworker.executioncontext.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/api/puppeteer.webworker.md
Expand Up @@ -42,5 +42,4 @@ for (const worker of page.workers()) {
| ----------------------------------------------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [evaluate(pageFunction, args)](./puppeteer.webworker.evaluate.md) | | If the function passed to the <code>worker.evaluate</code> returns a Promise, then <code>worker.evaluate</code> would wait for the promise to resolve and return its value. If the function passed to the <code>worker.evaluate</code> returns a non-serializable value, then <code>worker.evaluate</code> resolves to <code>undefined</code>. DevTools Protocol also supports transferring some additional values that are not serializable by <code>JSON</code>: <code>-0</code>, <code>NaN</code>, <code>Infinity</code>, <code>-Infinity</code>, and bigint literals. Shortcut for <code>await worker.executionContext()).evaluate(pageFunction, ...args)</code>. |
| [evaluateHandle(pageFunction, args)](./puppeteer.webworker.evaluatehandle.md) | | The only difference between <code>worker.evaluate</code> and <code>worker.evaluateHandle</code> is that <code>worker.evaluateHandle</code> returns in-page object (JSHandle). If the function passed to the <code>worker.evaluateHandle</code> returns a <code>Promise</code>, then <code>worker.evaluateHandle</code> would wait for the promise to resolve and return its value. Shortcut for <code>await worker.executionContext()).evaluateHandle(pageFunction, ...args)</code> |
| [executionContext()](./puppeteer.webworker.executioncontext.md) | | |
| [url()](./puppeteer.webworker.url.md) | | |
4 changes: 2 additions & 2 deletions src/common/ExecutionContext.ts
Expand Up @@ -35,8 +35,6 @@ 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
Expand All @@ -55,6 +53,8 @@ const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;
* @remarks
* Besides pages, execution contexts can be found in
* {@link WebWorker | workers}.
*
* @internal
*/
export class ExecutionContext {
/**
Expand Down
4 changes: 1 addition & 3 deletions src/common/Frame.ts
Expand Up @@ -398,9 +398,7 @@ export class Frame {
}

/**
* @deprecated Do not use the execution context directly.
*
* @returns a promise that resolves to the frame's default execution context.
* @internal
*/
executionContext(): Promise<ExecutionContext> {
return this.worlds[MAIN_WORLD].executionContext();
Expand Down
2 changes: 1 addition & 1 deletion src/common/JSHandle.ts
Expand Up @@ -108,7 +108,7 @@ export class JSHandle<T = unknown> {
}

/**
* @returns The execution context the handle belongs to.
* @internal
*/
executionContext(): ExecutionContext {
return this.#context;
Expand Down

0 comments on commit 2f33237

Please sign in to comment.