import { Frame } from './frame'; import { ContentScript } from './inject'; import { RemoteElement } from './remote-element'; import { RemoteObject } from './remote-object'; import { CdpRemoteObject, RemoteExpression } from './types'; /** * In Chrome architecture each page/frame has a default execution context, * but more contexts (aka "isolated worlds") can be created. * Objects do not "see" each other between execution contexts. * * FrameManager keeps track of default execution context of the page, * so in most circumstances you do not need to work with this class directly. * Instead, you use corresponding methods on `Page`, `Frame`, * `RemoteElement` and `RemoteObject` instances. */ export declare class ExecutionContext { readonly frame: Frame; readonly executionContextId: string; /** * Execution context may be destroyed, in which case it's no longer possible to use this. * Frames will have to check if the context is alive and re-initialize them if necessary. */ isAlive: boolean; protected listeners: { onExecutionContextsCleared: () => void; onExecutionContextDestroyed: (ev: { executionContextId: string; }) => void; }; /** * Creates a new execution context. * * @param frame Frame this execution context belongs to. * @param executionContextId Id obtained from CDP methods/events. */ constructor(frame: Frame, executionContextId: string); /** * @returns The page this execution context belongs to. */ get page(): import("./page").Page; /** * @returns The target this execution context belongs to. */ get target(): import("./target").Target; /** * Evaluates `pageFn` in the this execution context, returning a remote reference to result. * This should only be used to hold references to values on the page, which are not JSON-serializable * (e.g. DOM nodes, instances of Date, RegExp, etc). * * Use `evaluateJson` instead if you just need to obtain a JSON value (i.e. a string, a JSON object, etc). * * @param pageFn Function to execute * @param args Array of arguments that will be available in `pageFn`. */ evaluate(pageFn: RemoteExpression, ...args: any[]): Promise; /** * Evaluates `pageFn` in the this execution context, returning a JSON-serialized value * of `pageFn` result. * * @param pageFn Function to execute * @param args Array of arguments that will be available in `pageFn`. */ evaluateJson(pageFn: RemoteExpression, ...args: any[]): Promise; /** * Evaluates `pageFn` in the this execution context and returns `RemoteElement`. * `pageFn` is expected to return a reference to DOM node. * * @param pageFn Function to execute * @param args Array of arguments that will be available in `pageFn`. */ evaluateElement(pageFn: RemoteExpression, ...args: any[]): Promise; /** * Evaluates `pageFn` in the this execution context and returns `RemoteElement`. * `pageFn` is expected to return a reference to `NodeList` or any kind of * enumerable of DOM nodes. * * @param pageFn Function to execute * @param args Array of arguments that will be available in `pageFn`. */ evaluateElementList(pageFn: RemoteExpression, ...args: any[]): Promise; /** * Converts a reference to Iterable into an array of RemoteElement references. * * @internal */ nodeListToElements(nodeList: RemoteObject): Promise; createRemoteObject(cdpRemoteObject: CdpRemoteObject): RemoteObject; protected convertArgument(arg: any): CallArgument; protected convertException(exceptionDetails: ExceptionDetails): Error; protected handleEvaluateError(err: Error): void; initContentScripts(scripts: ContentScript[]): void; protected onExecutionContextsCleared(): void; protected onExecutionContextDestroyed(ev: { executionContextId: string; }): void; protected onDestroyed(): void; } declare type CallArgument = { value: any; } | { objectId: string; }; interface ExceptionDetails { exception?: { description?: string; value: string; }; text: string; stackTrace?: { callFrames: CallFrame[]; }; } interface CallFrame { functionName: string; url: string; lineNumber: number; columnNumber: number; } export {}; //# sourceMappingURL=execution-context.d.ts.map