diff --git a/types/puppeteer/index.d.ts b/types/puppeteer/index.d.ts index 9f06866b3f..7ad088a68e 100644 --- a/types/puppeteer/index.d.ts +++ b/types/puppeteer/index.d.ts @@ -863,7 +863,7 @@ export interface ElementHandle extends JSHandle, /** The class represents a context for JavaScript execution. */ export interface ExecutionContext extends JSEvalable { - queryObjects(prototypeHandle: JSHandle): JSHandle; + queryObjects(prototypeHandle: JSHandle): Promise; } /** 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; /** Returns `true` if the frame has been detached, or `false` otherwise. */ isDetached(): boolean; /** Returns frame's name attribute as specified in the tag. */ diff --git a/types/puppeteer/puppeteer-tests.ts b/types/puppeteer/puppeteer-tests.ts index 529f429ac1..5871a9e7bd 100644 --- a/types/puppeteer/puppeteer-tests.ts +++ b/types/puppeteer/puppeteer-tests.ts @@ -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(() => {}); +})();