feat(docker): closeAllBrowsers command for reuseController (#17383)

This commit is contained in:
Andrey Lushnikov 2022-09-15 20:38:28 -07:00 committed by GitHub
parent e92bdce383
commit 7019cc8b97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 0 deletions

View File

@ -119,6 +119,10 @@ class ProtocolHandler {
await this._controller.hideHighlightAll();
}
async closeAllBrowsers() {
await this._controller.closeAllBrowsers();
}
async kill() {
await this._controller.kill();
}

View File

@ -575,6 +575,7 @@ export interface ReuseControllerChannel extends ReuseControllerEventTarget, Chan
highlightAll(params: ReuseControllerHighlightAllParams, metadata?: Metadata): Promise<ReuseControllerHighlightAllResult>;
hideHighlightAll(params?: ReuseControllerHideHighlightAllParams, metadata?: Metadata): Promise<ReuseControllerHideHighlightAllResult>;
kill(params?: ReuseControllerKillParams, metadata?: Metadata): Promise<ReuseControllerKillResult>;
closeAllBrowsers(params?: ReuseControllerCloseAllBrowsersParams, metadata?: Metadata): Promise<ReuseControllerCloseAllBrowsersResult>;
}
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;

View File

@ -663,6 +663,8 @@ ReuseController:
kill:
closeAllBrowsers:
events:
inspectRequested:
parameters:

View File

@ -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,

View File

@ -69,6 +69,10 @@ export class ReuseControllerDispatcher extends Dispatcher<ReuseController, chann
await this._object.kill();
}
async closeAllBrowsers() {
await this._object.closeAllBrowsers();
}
override _dispose() {
super._dispose();
this._object.dispose();

View File

@ -153,6 +153,10 @@ export class ReuseController extends SdkObject {
selfDestruct();
}
async closeAllBrowsers() {
await Promise.all(this.allBrowsers().map(browser => browser.close()));
}
private _emitSnapshot() {
const browsers = [];
for (const browser of this._playwright.allBrowsers()) {