Skip to content

Commit 820fd7f

Browse files
committed
try fixing types
1 parent bd45268 commit 820fd7f

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

packages/playwright-core/src/browserServerImpl.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import type { LaunchOptions, LaunchServerOptions, Logger, Env } from './client/t
3030
import type { ProtocolLogger } from './server/types';
3131
import type { WebSocketEventEmitter } from './utilsBundle';
3232
import type { Browser } from './server/browser';
33+
import type { Browser as ClientBrowser } from './client/browser';
3334

3435
export class BrowserServerLauncherImpl implements BrowserServerLauncher {
3536
private _browserName: 'chromium' | 'firefox' | 'webkit' | '_bidiFirefox' | '_bidiChromium';
@@ -78,10 +79,17 @@ export class BrowserServerLauncherImpl implements BrowserServerLauncher {
7879
throw e;
7980
}
8081

81-
return this.launchServerOnExistingBrowser(browser, options);
82+
return this._launchServerOnExistingBrowser(browser, options);
8283
}
8384

84-
async launchServerOnExistingBrowser(browser: Browser, options: LaunchServerOptions): Promise<BrowserServer> {
85+
async launchServerOnExistingBrowser(browser: ClientBrowser, options: LaunchServerOptions): Promise<BrowserServer> {
86+
const browserImpl = browser._connection.toImpl?.(browser);
87+
if (!browserImpl)
88+
throw new Error('Launch server is not supported');
89+
return this._launchServerOnExistingBrowser(browserImpl, options);
90+
}
91+
92+
private async _launchServerOnExistingBrowser(browser: Browser, options: LaunchServerOptions): Promise<BrowserServer> {
8593
const path = options.wsPath ? (options.wsPath.startsWith('/') ? options.wsPath : `/${options.wsPath}`) : `/${createGuid()}`;
8694

8795
// 2. Start the server

packages/playwright-core/src/client/browser.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { isTargetClosedError } from './errors';
2222
import { Events } from './events';
2323
import { mkdirIfNeeded } from './fileUtils';
2424

25-
import type { Browser as BrowserImpl } from '../server/browser';
2625
import type { BrowserType } from './browserType';
2726
import type { Page } from './page';
2827
import type { BrowserContextOptions, LaunchOptions, LaunchServerOptions, Logger } from './types';
@@ -148,11 +147,9 @@ export class Browser extends ChannelOwner<channels.BrowserChannel> implements ap
148147
}
149148

150149
async _launchServer(options: LaunchServerOptions = {}) {
151-
const serverLauncher = this._browserType._serverLauncher;
152-
const browser: BrowserImpl = this._connection.toImpl?.(this);
153-
if (!serverLauncher || !browser)
150+
if (!this._browserType._serverLauncher)
154151
throw new Error('Launching server is not supported');
155-
return await serverLauncher.launchServerOnExistingBrowser(browser, {
152+
return await this._browserType._serverLauncher.launchServerOnExistingBrowser(this, {
156153
_sharedBrowser: true,
157154
...options,
158155
});

packages/playwright-core/src/client/browserType.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { raceAgainstDeadline } from '../utils/isomorphic/timeoutRunner';
2626
import { connectOverWebSocket } from './webSocket';
2727
import { TimeoutSettings } from './timeoutSettings';
2828

29-
import type { Browser as BrowserImpl } from '../server/browser';
3029
import type { Playwright } from './playwright';
3130
import type { ConnectOptions, LaunchOptions, LaunchPersistentContextOptions, LaunchServerOptions } from './types';
3231
import type * as api from '../../types/types';
@@ -35,7 +34,7 @@ import type { ChildProcess } from 'child_process';
3534

3635
export interface BrowserServerLauncher {
3736
launchServer(options?: LaunchOptions & LaunchServerOptions): Promise<api.BrowserServer>;
38-
launchServerOnExistingBrowser(browser: BrowserImpl, options?: LaunchServerOptions): Promise<api.BrowserServer>;
37+
launchServerOnExistingBrowser(browser: Browser, options?: LaunchServerOptions): Promise<api.BrowserServer>;
3938
}
4039

4140
// This is here just for api generation and checking.

0 commit comments

Comments
 (0)