diff --git a/packages/playwright-core/src/cli/driver.ts b/packages/playwright-core/src/cli/driver.ts index 9c306ca7a6..67e4c2d08f 100644 --- a/packages/playwright-core/src/cli/driver.ts +++ b/packages/playwright-core/src/cli/driver.ts @@ -119,6 +119,10 @@ class ProtocolHandler { await this._controller.hideHighlightAll(); } + async closeAllBrowsers() { + await this._controller.closeAllBrowsers(); + } + async kill() { await this._controller.kill(); } diff --git a/packages/playwright-core/src/protocol/channels.ts b/packages/playwright-core/src/protocol/channels.ts index 0e74ff3be0..463e0a56e2 100644 --- a/packages/playwright-core/src/protocol/channels.ts +++ b/packages/playwright-core/src/protocol/channels.ts @@ -575,6 +575,7 @@ export interface ReuseControllerChannel extends ReuseControllerEventTarget, Chan highlightAll(params: ReuseControllerHighlightAllParams, metadata?: Metadata): Promise; hideHighlightAll(params?: ReuseControllerHideHighlightAllParams, metadata?: Metadata): Promise; kill(params?: ReuseControllerKillParams, metadata?: Metadata): Promise; + closeAllBrowsers(params?: ReuseControllerCloseAllBrowsersParams, metadata?: Metadata): Promise; } export type ReuseControllerInspectRequestedEvent = { selector: string, @@ -640,6 +641,9 @@ export type ReuseControllerHideHighlightAllResult = void; export type ReuseControllerKillParams = {}; export type ReuseControllerKillOptions = {}; export type ReuseControllerKillResult = void; +export type ReuseControllerCloseAllBrowsersParams = {}; +export type ReuseControllerCloseAllBrowsersOptions = {}; +export type ReuseControllerCloseAllBrowsersResult = void; export interface ReuseControllerEvents { 'inspectRequested': ReuseControllerInspectRequestedEvent; diff --git a/packages/playwright-core/src/protocol/protocol.yml b/packages/playwright-core/src/protocol/protocol.yml index 3ed1dbc889..285653c25a 100644 --- a/packages/playwright-core/src/protocol/protocol.yml +++ b/packages/playwright-core/src/protocol/protocol.yml @@ -663,6 +663,8 @@ ReuseController: kill: + closeAllBrowsers: + events: inspectRequested: parameters: diff --git a/packages/playwright-core/src/protocol/validator.ts b/packages/playwright-core/src/protocol/validator.ts index cf40dedfd8..7ed51dca8e 100644 --- a/packages/playwright-core/src/protocol/validator.ts +++ b/packages/playwright-core/src/protocol/validator.ts @@ -351,6 +351,8 @@ scheme.ReuseControllerHideHighlightAllParams = tOptional(tObject({})); scheme.ReuseControllerHideHighlightAllResult = tOptional(tObject({})); scheme.ReuseControllerKillParams = tOptional(tObject({})); scheme.ReuseControllerKillResult = tOptional(tObject({})); +scheme.ReuseControllerCloseAllBrowsersParams = tOptional(tObject({})); +scheme.ReuseControllerCloseAllBrowsersResult = tOptional(tObject({})); scheme.SocksSupportInitializer = tOptional(tObject({})); scheme.SocksSupportSocksRequestedEvent = tObject({ uid: tString, diff --git a/packages/playwright-core/src/server/dispatchers/reuseControllerDispatcher.ts b/packages/playwright-core/src/server/dispatchers/reuseControllerDispatcher.ts index 6b98475678..38ab0acb30 100644 --- a/packages/playwright-core/src/server/dispatchers/reuseControllerDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/reuseControllerDispatcher.ts @@ -69,6 +69,10 @@ export class ReuseControllerDispatcher extends Dispatcher browser.close())); + } + private _emitSnapshot() { const browsers = []; for (const browser of this._playwright.allBrowsers()) {