feat(chromium-tip-of-tree): roll to r1159 (#27605)

This commit is contained in:
Playwright Service 2023-10-17 13:41:23 -07:00 committed by GitHub
parent a005064cc8
commit 5262e5ab35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 18 deletions

View file

@ -15,9 +15,9 @@
}, },
{ {
"name": "chromium-tip-of-tree", "name": "chromium-tip-of-tree",
"revision": "1158", "revision": "1159",
"installByDefault": false, "installByDefault": false,
"browserVersion": "120.0.6057.0" "browserVersion": "120.0.6062.0"
}, },
{ {
"name": "firefox", "name": "firefox",

View file

@ -34,7 +34,8 @@ export const chromiumSwitches = [
'--disable-extensions', '--disable-extensions',
// AvoidUnnecessaryBeforeUnloadCheckSync - https://github.com/microsoft/playwright/issues/14047 // AvoidUnnecessaryBeforeUnloadCheckSync - https://github.com/microsoft/playwright/issues/14047
// Translate - https://github.com/microsoft/playwright/issues/16126 // Translate - https://github.com/microsoft/playwright/issues/16126
'--disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate', // HttpsUpgrades - https://github.com/microsoft/playwright/pull/27605
'--disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades',
'--allow-pre-commit-input', '--allow-pre-commit-input',
'--disable-hang-monitor', '--disable-hang-monitor',
'--disable-ipc-flooding-protection', '--disable-ipc-flooding-protection',

View file

@ -171,6 +171,7 @@ export abstract class APIRequestContext extends SdkObject {
} else { } else {
if (proxy.username) if (proxy.username)
proxyOpts.auth = `${proxy.username}:${proxy.password || ''}`; proxyOpts.auth = `${proxy.username}:${proxy.password || ''}`;
// TODO: We should use HttpProxyAgent conditional on proxyOpts.protocol instead of always using CONNECT method.
agent = new HttpsProxyAgent(proxyOpts); agent = new HttpsProxyAgent(proxyOpts);
} }
} }

View file

@ -50,7 +50,7 @@ export class TestProxy {
await new Promise(x => this._server.close(x)); await new Promise(x => this._server.close(x));
} }
forwardTo(port: number, options?: { skipConnectRequests: boolean }) { forwardTo(port: number, options?: { allowConnectRequests: boolean }) {
this._prependHandler('request', (req: IncomingMessage) => { this._prependHandler('request', (req: IncomingMessage) => {
this.requestUrls.push(req.url); this.requestUrls.push(req.url);
const url = new URL(req.url); const url = new URL(req.url);
@ -58,12 +58,7 @@ export class TestProxy {
req.url = url.toString(); req.url = url.toString();
}); });
this._prependHandler('connect', (req: IncomingMessage) => { this._prependHandler('connect', (req: IncomingMessage) => {
// If using this proxy at the browser-level, you'll want to skip trying to if (!options?.allowConnectRequests)
// MITM connect requests otherwise, unless the system/browser is configured
// to ignore HTTPS errors (or the host has been configured to trust the test
// certs), Playwright will crash in funny ways. (e.g. CR Headful tries to connect
// to accounts.google.com as part of its startup routine and fatally complains of "Invalid method encountered".)
if (options?.skipConnectRequests)
return; return;
this.connectHosts.push(req.url); this.connectHosts.push(req.url);
req.url = `localhost:${port}`; req.url = `localhost:${port}`;

View file

@ -110,8 +110,10 @@ export class TestServer {
_onSocket(socket: net.Socket) { _onSocket(socket: net.Socket) {
// ECONNRESET and HPE_INVALID_EOF_STATE are legit errors given // ECONNRESET and HPE_INVALID_EOF_STATE are legit errors given
// that tab closing aborts outgoing connections to the server. // that tab closing aborts outgoing connections to the server.
// HPE_INVALID_METHOD is a legit error when a client (e.g. Chromium which
// makes https requests to http sites) makes a https connection to a http server.
socket.on('error', error => { socket.on('error', error => {
if ((error as any).code !== 'ECONNRESET' && (error as any).code !== 'HPE_INVALID_EOF_STATE') if (!['ECONNRESET', 'HPE_INVALID_EOF_STATE', 'HPE_INVALID_METHOD'].includes((error as any).code))
throw error; throw error;
}); });
} }

View file

@ -97,7 +97,7 @@ it('should use proxy', async ({ contextFactory, server, proxyServer }) => {
it('should set cookie for top-level domain', async ({ contextFactory, server, proxyServer, browserName, isLinux }) => { it('should set cookie for top-level domain', async ({ contextFactory, server, proxyServer, browserName, isLinux }) => {
it.fixme(browserName === 'webkit' && isLinux); it.fixme(browserName === 'webkit' && isLinux);
proxyServer.forwardTo(server.PORT); proxyServer.forwardTo(server.PORT, { allowConnectRequests: true });
const context = await contextFactory({ const context = await contextFactory({
proxy: { server: `localhost:${proxyServer.PORT}` } proxy: { server: `localhost:${proxyServer.PORT}` }
}); });
@ -216,7 +216,7 @@ it('should use proxy for https urls', async ({ contextFactory, httpsServer, prox
httpsServer.setRoute('/target.html', async (req, res) => { httpsServer.setRoute('/target.html', async (req, res) => {
res.end('<html><title>Served by https server via proxy</title></html>'); res.end('<html><title>Served by https server via proxy</title></html>');
}); });
proxyServer.forwardTo(httpsServer.PORT); proxyServer.forwardTo(httpsServer.PORT, { allowConnectRequests: true });
const context = await contextFactory({ const context = await contextFactory({
ignoreHTTPSErrors: true, ignoreHTTPSErrors: true,
proxy: { server: `localhost:${proxyServer.PORT}` } proxy: { server: `localhost:${proxyServer.PORT}` }

View file

@ -28,7 +28,7 @@ it.use({
it.skip(({ mode }) => mode !== 'default'); it.skip(({ mode }) => mode !== 'default');
it('context request should pick up proxy credentials', async ({ browserType, server, proxyServer }) => { it('context request should pick up proxy credentials', async ({ browserType, server, proxyServer }) => {
proxyServer.forwardTo(server.PORT); proxyServer.forwardTo(server.PORT, { allowConnectRequests: true });
let auth; let auth;
proxyServer.setAuthHandler(req => { proxyServer.setAuthHandler(req => {
auth = req.headers['proxy-authorization']; auth = req.headers['proxy-authorization'];
@ -46,7 +46,7 @@ it('context request should pick up proxy credentials', async ({ browserType, ser
}); });
it('global request should pick up proxy credentials', async ({ playwright, server, proxyServer }) => { it('global request should pick up proxy credentials', async ({ playwright, server, proxyServer }) => {
proxyServer.forwardTo(server.PORT); proxyServer.forwardTo(server.PORT, { allowConnectRequests: true });
let auth; let auth;
proxyServer.setAuthHandler(req => { proxyServer.setAuthHandler(req => {
auth = req.headers['proxy-authorization']; auth = req.headers['proxy-authorization'];
@ -67,7 +67,7 @@ it('should work with context level proxy', async ({ contextFactory, contextOptio
res.end('<title>Served by the proxy</title>'); res.end('<title>Served by the proxy</title>');
}); });
proxyServer.forwardTo(server.PORT); proxyServer.forwardTo(server.PORT, { allowConnectRequests: true });
const context = await contextFactory({ const context = await contextFactory({
proxy: { server: `localhost:${proxyServer.PORT}` } proxy: { server: `localhost:${proxyServer.PORT}` }
}); });
@ -88,7 +88,7 @@ it(`should support proxy.bypass`, async ({ contextFactory, contextOptions, serve
// that resolves everything to some weird search results page. // that resolves everything to some weird search results page.
// //
// @see https://gist.github.com/CollinChaffin/24f6c9652efb3d6d5ef2f5502720ef00 // @see https://gist.github.com/CollinChaffin/24f6c9652efb3d6d5ef2f5502720ef00
proxyServer.forwardTo(server.PORT); proxyServer.forwardTo(server.PORT, { allowConnectRequests: true });
const context = await contextFactory({ const context = await contextFactory({
...contextOptions, ...contextOptions,
proxy: { server: `localhost:${proxyServer.PORT}`, bypass: `1.non.existent.domain.for.the.test, 2.non.existent.domain.for.the.test, .another.test` } proxy: { server: `localhost:${proxyServer.PORT}`, bypass: `1.non.existent.domain.for.the.test, 2.non.existent.domain.for.the.test, .another.test` }

View file

@ -99,7 +99,7 @@ it.describe('should proxy local network requests', () => {
}); });
const url = `http://${params.target}:${server.PORT}${path}`; const url = `http://${params.target}:${server.PORT}${path}`;
proxyServer.forwardTo(server.PORT, { skipConnectRequests: true }); proxyServer.forwardTo(server.PORT);
const browser = await browserType.launch({ const browser = await browserType.launch({
proxy: { server: `localhost:${proxyServer.PORT}`, bypass: additionalBypass ? '1.non.existent.domain.for.the.test' : undefined } proxy: { server: `localhost:${proxyServer.PORT}`, bypass: additionalBypass ? '1.non.existent.domain.for.the.test' : undefined }
}); });
@ -300,6 +300,8 @@ async function setupSocksForwardingServer(port: number, forwardPort: number){
socket.pipe(dstSock).pipe(socket); socket.pipe(dstSock).pipe(socket);
socket.on('close', () => dstSock.end()); socket.on('close', () => dstSock.end());
socket.on('end', () => dstSock.end()); socket.on('end', () => dstSock.end());
dstSock.on('error', () => socket.end());
dstSock.on('end', () => socket.end());
dstSock.setKeepAlive(false); dstSock.setKeepAlive(false);
dstSock.connect(forwardPort, '127.0.0.1'); dstSock.connect(forwardPort, '127.0.0.1');
} }