Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(bidi): make browserType.connect work (#34461)

Yury Semikhatskydcff914040d5
diff --git a/.gitignore b/.gitignore
index aadc481067..8e41e31810 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,3 +35,4 @@ test-results
.cache/
.eslintcache
playwright.env
+/firefox/
diff --git a/packages/playwright-core/src/remote/playwrightConnection.ts b/packages/playwright-core/src/remote/playwrightConnection.ts
index ea607bdb17..5f39be5671 100644
--- a/packages/playwright-core/src/remote/playwrightConnection.ts
+++ b/packages/playwright-core/src/remote/playwrightConnection.ts
@@ -118,7 +118,14 @@ export class PlaywrightConnection {
const playwright = createPlaywright({ sdkLanguage: options.sdkLanguage, isServer: true });
const ownedSocksProxy = await this._createOwnedSocksProxy(playwright);
- const browser = await playwright[this._options.browserName as 'chromium'].launch(serverSideCallMetadata(), this._options.launchOptions);
+ let browserName = this._options.browserName;
+ if ('bidi' === browserName) {
+ if (this._options.launchOptions?.channel?.toLocaleLowerCase().includes('firefox'))
+ browserName = 'bidiFirefox';
+ else
+ browserName = 'bidiChromium';
+ }
+ const browser = await playwright[browserName as 'chromium'].launch(serverSideCallMetadata(), this._options.launchOptions);
this._cleanups.push(async () => {
for (const browser of playwright.allBrowsers())
diff --git a/tests/bidi/expectationReporter.ts b/tests/bidi/expectationReporter.ts
index c31cb74aaf..d88875f031 100644
--- a/tests/bidi/expectationReporter.ts
+++ b/tests/bidi/expectationReporter.ts
@@ -58,6 +58,8 @@ class ExpectationReporter implements Reporter {
const key = test.titlePath().slice(2).join(' › ');
if (outcome === 'timeout')
expectations.set(key, outcome);
+ else if (expectations.has(key) && test.outcome() !== 'skipped')
+ expectations.delete(key); // Remove tests that no longer timeout.
}
const keys = Array.from(expectations.keys());
keys.sort();
diff --git a/tests/bidi/expectations/bidi-firefox-nightly-library.txt b/tests/bidi/expectations/bidi-firefox-nightly-library.txt
index f527d5fb61..1db4abda86 100644
--- a/tests/bidi/expectations/bidi-firefox-nightly-library.txt
+++ b/tests/bidi/expectations/bidi-firefox-nightly-library.txt
@@ -15,43 +15,8 @@ library/browsercontext-page-event.spec.ts › should have about:blank for empty
library/browsercontext-proxy.spec.ts › should use proxy for https urls [timeout]
library/browsercontext-service-worker-policy.spec.ts › block › blocks service worker registration [timeout]
library/browsercontext-timezone-id.spec.ts › should work for multiple pages sharing same process [timeout]
-library/browsertype-connect.spec.ts › launchServer only › should be able to reconnect to a browser 12 times without warnings [timeout]
-library/browsertype-connect.spec.ts › launchServer only › should properly disconnect when connection closes from the server side [timeout]
-library/browsertype-connect.spec.ts › launchServer only › should work with cluster [timeout]
-library/browsertype-connect.spec.ts › launchServer › disconnected event should be emitted when browser is closed or server is closed [timeout]
-library/browsertype-connect.spec.ts › launchServer › disconnected event should have browser as argument [timeout]
-library/browsertype-connect.spec.ts › launchServer › setInputFiles should preserve lastModified timestamp [timeout]
library/browsertype-connect.spec.ts › launchServer › should be able to connect 20 times to a single server without warnings [timeout]
-library/browsertype-connect.spec.ts › launchServer › should be able to connect two browsers at the same time [timeout]
-library/browsertype-connect.spec.ts › launchServer › should be able to connect when the wsEndpoint is passed as an option [timeout]
-library/browsertype-connect.spec.ts › launchServer › should be able to reconnect to a browser [timeout]
-library/browsertype-connect.spec.ts › launchServer › should be able to visit ipv6 [timeout]
-library/browsertype-connect.spec.ts › launchServer › should be able to visit ipv6 through localhost [timeout]
-library/browsertype-connect.spec.ts › launchServer › should connect over http [timeout]
-library/browsertype-connect.spec.ts › launchServer › should connect over wss [timeout]
-library/browsertype-connect.spec.ts › launchServer › should emit close events on pages and contexts [timeout]
-library/browsertype-connect.spec.ts › launchServer › should error when saving download after deletion [timeout]
-library/browsertype-connect.spec.ts › launchServer › should filter launch options [timeout]
-library/browsertype-connect.spec.ts › launchServer › should fulfill with global fetch result [timeout]
-library/browsertype-connect.spec.ts › launchServer › should handle exceptions during connect [timeout]
-library/browsertype-connect.spec.ts › launchServer › should ignore page.pause when headed [timeout]
-library/browsertype-connect.spec.ts › launchServer › should not throw on close after disconnect [timeout]
-library/browsertype-connect.spec.ts › launchServer › should properly disconnect when connection closes from the client side [timeout]
-library/browsertype-connect.spec.ts › launchServer › should record trace with sources [timeout]
-library/browsertype-connect.spec.ts › launchServer › should reject navigation when browser closes [timeout]
-library/browsertype-connect.spec.ts › launchServer › should reject waitForEvent before browser.close finishes [timeout]
-library/browsertype-connect.spec.ts › launchServer › should reject waitForEvent before browser.onDisconnect fires [timeout]
-library/browsertype-connect.spec.ts › launchServer › should reject waitForSelector when browser closes [timeout]
-library/browsertype-connect.spec.ts › launchServer › should respect selectors [timeout]
-library/browsertype-connect.spec.ts › launchServer › should save download [timeout]
-library/browsertype-connect.spec.ts › launchServer › should save har [timeout]
library/browsertype-connect.spec.ts › launchServer › should saveAs videos from remote browser [timeout]
-library/browsertype-connect.spec.ts › launchServer › should set the browser connected state [timeout]
-library/browsertype-connect.spec.ts › launchServer › should support slowmo option [timeout]
-library/browsertype-connect.spec.ts › launchServer › should terminate network waiters [timeout]
-library/browsertype-connect.spec.ts › launchServer › should throw when calling waitForNavigation after disconnect [timeout]
-library/browsertype-connect.spec.ts › launchServer › should throw when used after isConnected returns false [timeout]
-library/browsertype-connect.spec.ts › launchServer › should upload large file [timeout]
library/channels.spec.ts › should work with the domain module [timeout]
library/chromium/chromium.spec.ts › PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1 › serviceWorker(), and fromServiceWorker() work [timeout]
library/chromium/chromium.spec.ts › PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1 › setExtraHTTPHeaders [timeout]