Skip to content

Commit

Permalink
chore(bidi): fix signals tests (#34209)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s authored Jan 3, 2025
1 parent 8b45ea6 commit 5a22475
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 25 deletions.
4 changes: 2 additions & 2 deletions packages/playwright-core/src/browserServerImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import { rewriteErrorMessage } from './utils/stackTrace';
import { SocksProxy } from './common/socksProxy';

export class BrowserServerLauncherImpl implements BrowserServerLauncher {
private _browserName: 'chromium' | 'firefox' | 'webkit';
private _browserName: 'chromium' | 'firefox' | 'webkit' | 'bidiFirefox' | 'bidiChromium';

constructor(browserName: 'chromium' | 'firefox' | 'webkit') {
constructor(browserName: 'chromium' | 'firefox' | 'webkit' | 'bidiFirefox' | 'bidiChromium') {
this._browserName = browserName;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/playwright-core/src/inProcessFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export function createInProcessPlaywright(): PlaywrightAPI {
playwrightAPI.firefox._serverLauncher = new BrowserServerLauncherImpl('firefox');
playwrightAPI.webkit._serverLauncher = new BrowserServerLauncherImpl('webkit');
playwrightAPI._android._serverLauncher = new AndroidServerLauncherImpl();
playwrightAPI._bidiChromium._serverLauncher = new BrowserServerLauncherImpl('bidiChromium');
playwrightAPI._bidiFirefox._serverLauncher = new BrowserServerLauncherImpl('bidiFirefox');

// Switch to async dispatch after we got Playwright object.
dispatcherConnection.onmessage = message => setImmediate(() => clientConnection.dispatch(message));
Expand Down
10 changes: 0 additions & 10 deletions tests/bidi/expectations/bidi-chromium-library.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1674,16 +1674,6 @@ library/selectors-register.spec.ts › should work in main and isolated world [p
library/selectors-register.spec.ts › should work when registered on global [pass]
library/selectors-register.spec.ts › should work with path [pass]
library/shared-worker.spec.ts › should survive shared worker restart [timeout]
library/signals.spec.ts › should close the browser when the node process closes [timeout]
library/signals.spec.ts › should remove temp dir on process.exit [timeout]
library/signals.spec.ts › signals › should close the browser on SIGHUP [timeout]
library/signals.spec.ts › signals › should close the browser on SIGINT [timeout]
library/signals.spec.ts › signals › should close the browser on SIGTERM [timeout]
library/signals.spec.ts › signals › should kill the browser on SIGINT + SIGTERM [timeout]
library/signals.spec.ts › signals › should kill the browser on SIGTERM + SIGINT [timeout]
library/signals.spec.ts › signals › should kill the browser on double SIGINT and remove temp dir [timeout]
library/signals.spec.ts › signals › should not prevent default SIGTERM handling after browser close [timeout]
library/signals.spec.ts › signals › should report browser close signal 2 [timeout]
library/slowmo.spec.ts › slowMo › ElementHandle SlowMo check [pass]
library/slowmo.spec.ts › slowMo › ElementHandle SlowMo click [pass]
library/slowmo.spec.ts › slowMo › ElementHandle SlowMo dblclick [pass]
Expand Down
10 changes: 0 additions & 10 deletions tests/bidi/expectations/bidi-firefox-nightly-library.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1726,16 +1726,6 @@ library/selectors-register.spec.ts › should work in main and isolated world [p
library/selectors-register.spec.ts › should work when registered on global [pass]
library/selectors-register.spec.ts › should work with path [pass]
library/shared-worker.spec.ts › should survive shared worker restart [pass]
library/signals.spec.ts › should close the browser when the node process closes [timeout]
library/signals.spec.ts › should remove temp dir on process.exit [timeout]
library/signals.spec.ts › signals › should close the browser on SIGHUP [timeout]
library/signals.spec.ts › signals › should close the browser on SIGINT [timeout]
library/signals.spec.ts › signals › should close the browser on SIGTERM [timeout]
library/signals.spec.ts › signals › should kill the browser on SIGINT + SIGTERM [timeout]
library/signals.spec.ts › signals › should kill the browser on SIGTERM + SIGINT [timeout]
library/signals.spec.ts › signals › should kill the browser on double SIGINT and remove temp dir [timeout]
library/signals.spec.ts › signals › should not prevent default SIGTERM handling after browser close [timeout]
library/signals.spec.ts › signals › should report browser close signal 2 [timeout]
library/slowmo.spec.ts › slowMo › ElementHandle SlowMo check [pass]
library/slowmo.spec.ts › slowMo › ElementHandle SlowMo click [pass]
library/slowmo.spec.ts › slowMo › ElementHandle SlowMo dblclick [pass]
Expand Down
4 changes: 2 additions & 2 deletions tests/config/browserTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>
await persistentContext.close();
},

startRemoteServer: async ({ childProcess, browserType }, run) => {
startRemoteServer: async ({ childProcess, browserType, channel }, run) => {
let server: PlaywrightServer | undefined;
const fn = async (kind: 'launchServer' | 'run-server', options?: RemoteServerOptions) => {
if (server)
throw new Error('can only start one remote server');
if (kind === 'launchServer') {
const remoteServer = new RemoteServer();
await remoteServer._start(childProcess, browserType, options);
await remoteServer._start(childProcess, browserType, channel, options);
server = remoteServer;
} else {
const runServer = new RunServer();
Expand Down
9 changes: 8 additions & 1 deletion tests/config/remoteServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class RemoteServer implements PlaywrightServer {
_browser: Browser | undefined;
_wsEndpoint!: string;

async _start(childProcess: CommonFixtures['childProcess'], browserType: BrowserType, remoteServerOptions: RemoteServerOptions = {}) {
async _start(childProcess: CommonFixtures['childProcess'], browserType: BrowserType, channel: string, remoteServerOptions: RemoteServerOptions = {}) {
this._browserType = browserType;
const browserOptions = (browserType as any)._defaultLaunchOptions;
// Copy options to prevent a large JSON string when launching subprocess.
Expand All @@ -97,9 +97,16 @@ export class RemoteServer implements PlaywrightServer {
};
const options = {
browserTypeName: browserType.name(),
channel,
launchOptions,
...remoteServerOptions,
};
if ('bidi' === browserType.name()) {
if (channel.toLocaleLowerCase().includes('firefox'))
options.browserTypeName = '_bidiFirefox';
else
options.browserTypeName = '_bidiChromium';
}
this._process = childProcess({
command: ['node', path.join(__dirname, 'remote-server-impl.js'), JSON.stringify(options)],
env: { ...process.env, PWTEST_UNDER_TEST: '1' },
Expand Down

0 comments on commit 5a22475

Please sign in to comment.