address comments
This commit is contained in:
parent
e942ad4869
commit
e9014f2b6e
|
|
@ -47,7 +47,7 @@ export const kNoXServerRunningError = 'Looks like you launched a headed browser
|
|||
export interface BrowserReadyState {
|
||||
onBrowserOutput(message: string): void;
|
||||
onBrowserExit(): void;
|
||||
ready(): Promise<string|undefined>;
|
||||
waitUntilReady(): Promise<{ wsEndpoint?: string }>;
|
||||
}
|
||||
|
||||
export abstract class BrowserType extends SdkObject {
|
||||
|
|
@ -250,7 +250,7 @@ export abstract class BrowserType extends SdkObject {
|
|||
kill
|
||||
};
|
||||
progress.cleanupWhenAborted(() => closeOrKill(progress.timeUntilDeadline()));
|
||||
const wsEndpoint = await readyState?.ready();
|
||||
const wsEndpoint = (await readyState?.waitUntilReady())?.wsEndpoint;
|
||||
if (options.useWebSocket) {
|
||||
transport = await WebSocketTransport.connect(progress, wsEndpoint!);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -369,8 +369,9 @@ class ChromiumReadyState implements BrowserReadyState {
|
|||
onBrowserExit(): void {
|
||||
this._wsEndpoint.reject(new Error('Browser exited'));
|
||||
}
|
||||
async ready(): Promise<string|undefined> {
|
||||
return this._wsEndpoint;
|
||||
async waitUntilReady(): Promise<{ wsEndpoint?: string }> {
|
||||
const wsEndpoint = await this._wsEndpoint;
|
||||
return { wsEndpoint };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,11 +104,11 @@ class JugglerReadyState implements BrowserReadyState {
|
|||
}
|
||||
onBrowserExit(): void {
|
||||
// Unblock launch when browser prematurely exits.
|
||||
this._jugglerPromise.resolve();
|
||||
this._jugglerPromise.reject(new Error('Browser exited'));
|
||||
}
|
||||
async ready(): Promise<string | undefined> {
|
||||
async waitUntilReady(): Promise<{ wsEndpoint?: string }> {
|
||||
await this._jugglerPromise;
|
||||
return undefined;
|
||||
return { };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue