Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 3.34 KB

puppeteer.executioncontext.md

File metadata and controls

38 lines (26 loc) · 3.34 KB
sidebar_label
ExecutionContext

ExecutionContext class

Warning: This API is now obsolete.

Do not use directly.

Represents a context for JavaScript execution.

Signature:

export declare class ExecutionContext

Remarks

Besides pages, execution contexts can be found in workers.

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the ExecutionContext class.

Example

A Page can have several execution contexts:

  • Each Frame of a page has a "default" execution context that is always created after frame is attached to DOM. This context is returned by the Frame.executionContext() method. - Each Chrome extensions creates additional execution contexts to isolate their code.

Methods

Method Modifiers Description
evaluate(pageFunction, args) Evaluates the given function.
evaluateHandle(pageFunction, args)

Evaluates the given function.

Unlike evaluate, this method returns a handle to the result of the function.

This method may be better suited if the object cannot be serialized (e.g. Map) and requires further manipulation.

frame()
queryObjects(prototypeHandle) Iterates through the JavaScript heap and finds all the objects with the given prototype.