Skip to content

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

fix(chromium): disable more background requests to Google services (#42909)

Yury Semikhatsky079ad8999ac2
diff --git a/packages/playwright-core/src/server/chromium/chromiumSwitches.ts b/packages/playwright-core/src/server/chromium/chromiumSwitches.ts
index da8d185fa8..65d568e917 100644
--- a/packages/playwright-core/src/server/chromium/chromiumSwitches.ts
+++ b/packages/playwright-core/src/server/chromium/chromiumSwitches.ts
@@ -43,6 +43,10 @@ const disabledFeatures = [
'AutoDeElevate',
// Prevents downloading optimization hints on startup.
'OptimizationHints',
+ // Prevents network time queries to clients2.google.com on startup.
+ 'NetworkTimeServiceQuerying',
+ // Prevents AI Mode eligibility requests to www.google.com on startup.
+ 'AimEnabled',
// Disables forced sign-in in Edge.
'msForceBrowserSignIn',
// Disables updating the preferred version in LaunchServices preferences on mac.
diff --git a/tests/library/client-certificates.spec.ts b/tests/library/client-certificates.spec.ts
index 2574c735bf..c28e60d76b 100644
--- a/tests/library/client-certificates.spec.ts
+++ b/tests/library/client-certificates.spec.ts
@@ -547,6 +547,7 @@ test.describe('browser', () => {
const { origin, hostname, port } = new URL(serverURL);
proxyServer.forwardTo(parseInt(port, 10), { allowConnectRequests: true });
const proxy = { server: `localhost:${proxyServer.PORT}` };
+ const serverHost = `${browserName === 'webkit' && isMac ? 'localhost' : '127.0.0.1'}:${port}`;
const clientCertificates = [{
origin,
certPath: asset('client-certificates/client/trusted/cert.pem'),
@@ -557,8 +558,8 @@ test.describe('browser', () => {
const page = await browser.newPage({ ignoreHTTPSErrors: true, clientCertificates });
await page.goto(serverURL);
await expect(page.getByTestId('message')).toHaveText('Hello Alice, your certificate was issued by localhost!');
- const host = browserName === 'webkit' && isMac ? 'localhost' : '127.0.0.1';
- expect([...new Set(proxyServer.connectHosts)]).toEqual([`${host}:${port}`]);
+ // Headed Chromium also sends its own background requests through the launch proxy.
+ expect(proxyServer.connectHosts).toContain(serverHost);
await page.close();
}
proxyServer.connectHosts = [];
@@ -566,7 +567,7 @@ test.describe('browser', () => {
const page = await browser.newPage({ ignoreHTTPSErrors: true, clientCertificates, proxy: { ...proxy, bypass: hostname } });
await page.goto(serverURL);
await expect(page.getByTestId('message')).toHaveText('Hello Alice, your certificate was issued by localhost!');
- expect(proxyServer.connectHosts).toEqual([]);
+ expect(proxyServer.connectHosts).not.toContain(serverHost);
await page.close();
}
await browser.close();