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 client-certificate tests pass (#36934)

Max Schmitt8a399e5a0cdd
diff --git a/packages/playwright-core/src/server/bidi/bidiBrowser.ts b/packages/playwright-core/src/server/bidi/bidiBrowser.ts
index d91b3b6ade..ce55d0fb1e 100644
--- a/packages/playwright-core/src/server/bidi/bidiBrowser.ts
+++ b/packages/playwright-core/src/server/bidi/bidiBrowser.ts
@@ -50,8 +50,8 @@ export class BidiBrowser extends Browser {
browser._bidiSessionInfo = await browser._browserSession.send('session.new', {
capabilities: {
alwaysMatch: {
- acceptInsecureCerts: false,
- proxy: getProxyConfiguration(options.proxy),
+ acceptInsecureCerts: options.persistent?.internalIgnoreHTTPSErrors || options.persistent?.ignoreHTTPSErrors,
+ proxy: getProxyConfiguration(options.originalLaunchOptions.proxyOverride ?? options.proxy),
unhandledPromptBehavior: {
default: bidi.Session.UserPromptHandlerType.Ignore,
},
@@ -95,9 +95,10 @@ export class BidiBrowser extends Browser {
}
async doCreateNewContext(options: types.BrowserContextOptions): Promise<BrowserContext> {
+ const proxy = options.proxyOverride || options.proxy;
const { userContext } = await this._browserSession.send('browser.createUserContext', {
- acceptInsecureCerts: options.ignoreHTTPSErrors,
- proxy: getProxyConfiguration(options.proxy),
+ acceptInsecureCerts: options.internalIgnoreHTTPSErrors || options.ignoreHTTPSErrors,
+ proxy: getProxyConfiguration(proxy),
});
const context = new BidiBrowserContext(this, userContext, options);
await context._initialize();
@@ -458,8 +459,9 @@ function getProxyConfiguration(proxySettings?: types.ProxySettings): bidi.Sessio
default:
throw new Error('Invalid proxy server protocol: ' + proxySettings.server);
}
- if (proxySettings.bypass)
- proxy.noProxy = proxySettings.bypass.split(',');
+ const bypass = proxySettings.bypass ?? process.env.PLAYWRIGHT_PROXY_BYPASS_FOR_TESTING;
+ if (bypass)
+ proxy.noProxy = bypass.split(',');
// TODO: support authentication.
return proxy;
diff --git a/tests/bidi/playwright.config.ts b/tests/bidi/playwright.config.ts
index 761a0f52d0..d8c7e65105 100644
--- a/tests/bidi/playwright.config.ts
+++ b/tests/bidi/playwright.config.ts
@@ -36,6 +36,7 @@ function firefoxUserPrefs() {
return defaultPrefs;
return { ...defaultPrefs, ...JSON.parse(prefsString) };
}
+process.env.PLAYWRIGHT_PROXY_BYPASS_FOR_TESTING = '<-loopback>';
const outputDir = path.join(__dirname, '..', '..', 'test-results');
const testDir = path.join(__dirname, '..');