🤖 Merge PR #45745 [puppeteer] Fixed return type for Frame.executionContext and ExecutionContext.queryObjects by @timocov

- Frame.executionContext returns a Promise
- ExecutionContext.queryObjects returns a Promise
This commit is contained in:
Evgeniy Timokhov 2020-06-27 23:07:05 +03:00 committed by GitHub
parent 58752d5aff
commit eaaf689a26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -863,7 +863,7 @@ export interface ElementHandle<E extends Element = Element> extends JSHandle<E>,
/** The class represents a context for JavaScript execution. */
export interface ExecutionContext extends JSEvalable {
queryObjects(prototypeHandle: JSHandle): JSHandle;
queryObjects(prototypeHandle: JSHandle): Promise<JSHandle>;
}
/** JSHandle represents an in-page JavaScript object. */
@ -1280,7 +1280,7 @@ export interface FrameBase extends Evalable, JSEvalable {
export interface Frame extends FrameBase {
childFrames(): Frame[];
/** Execution context associated with this frame. */
executionContext(): ExecutionContext;
executionContext(): Promise<ExecutionContext>;
/** Returns `true` if the frame has been detached, or `false` otherwise. */
isDetached(): boolean;
/** Returns frame's name attribute as specified in the tag. */

View File

@ -707,3 +707,17 @@ puppeteer.launch().then(async browser => {
const selected: string[] = await elementHandle.select('a', 'b', 'c');
})();
// .executionContext on Frame, and ExecutionContext.queryObjects
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const frame = page.mainFrame();
frame.executionContext().then(() => {});
const context = await frame.executionContext();
const queryObjectsRes = context.queryObjects(await context.evaluateHandle(() => {}));
queryObjectsRes.then(() => {});
})();