From d9a596511ec559ff40bd45f642486c905537def6 Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Thu, 3 Aug 2023 19:58:28 +0200 Subject: [PATCH] chore: add bringToFront for BiDi (#10685) --- packages/puppeteer-core/src/common/bidi/Connection.ts | 4 ++++ packages/puppeteer-core/src/common/bidi/Page.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/puppeteer-core/src/common/bidi/Connection.ts b/packages/puppeteer-core/src/common/bidi/Connection.ts index 80800d14fbb..2a5265abe2c 100644 --- a/packages/puppeteer-core/src/common/bidi/Connection.ts +++ b/packages/puppeteer-core/src/common/bidi/Connection.ts @@ -48,6 +48,10 @@ interface Commands { returnType: Bidi.Script.AddPreloadScriptResult; }; + 'browsingContext.activate': { + params: Bidi.BrowsingContext.ActivateParameters; + returnType: Bidi.EmptyResult; + }; 'browsingContext.create': { params: Bidi.BrowsingContext.CreateParameters; returnType: Bidi.BrowsingContext.CreateResult; diff --git a/packages/puppeteer-core/src/common/bidi/Page.ts b/packages/puppeteer-core/src/common/bidi/Page.ts index c26e72d370a..ffd439ebffe 100644 --- a/packages/puppeteer-core/src/common/bidi/Page.ts +++ b/packages/puppeteer-core/src/common/bidi/Page.ts @@ -712,6 +712,12 @@ export class Page extends PageBase { }); return new CDPSessionWrapper(this.mainFrame().context(), sessionId); } + + override async bringToFront(): Promise { + await this.#connection.send('browsingContext.activate', { + context: this.mainFrame()._id, + }); + } } function isConsoleLogEntry(