chore: fix s2 mode (#24525)

This commit is contained in:
Pavel Feldman 2023-07-31 11:24:04 -07:00 committed by GitHub
parent f135b5f7a8
commit 744eb6823f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 78 additions and 57 deletions

View file

@ -23,9 +23,19 @@ export type PlatformWorkerFixtures = {
isLinux: boolean; isLinux: boolean;
}; };
function platform(): 'win32' | 'darwin' | 'linux' {
if (process.env.PLAYWRIGHT_SERVICE_OS === 'linux')
return 'linux';
if (process.env.PLAYWRIGHT_SERVICE_OS === 'windows')
return 'win32';
if (process.env.PLAYWRIGHT_SERVICE_OS === 'macos')
return 'darwin';
return process.platform as 'win32' | 'darwin' | 'linux';
}
export const platformTest = test.extend<{}, PlatformWorkerFixtures>({ export const platformTest = test.extend<{}, PlatformWorkerFixtures>({
platform: [process.platform as 'win32' | 'darwin' | 'linux', { scope: 'worker' }], platform: [platform(), { scope: 'worker' }],
isWindows: [process.platform === 'win32', { scope: 'worker' }], isWindows: [platform() === 'win32', { scope: 'worker' }],
isMac: [process.platform === 'darwin', { scope: 'worker' }], isMac: [platform() === 'darwin', { scope: 'worker' }],
isLinux: [process.platform === 'linux', { scope: 'worker' }], isLinux: [platform() === 'linux', { scope: 'worker' }],
}); });

View file

@ -51,14 +51,14 @@ export async function verifyViewport(page: Page, width: number, height: number)
expect(await page.evaluate('window.innerHeight')).toBe(height); expect(await page.evaluate('window.innerHeight')).toBe(height);
} }
export function expectedSSLError(browserName: string): string { export function expectedSSLError(browserName: string, platform: string): string {
let expectedSSLError: string; let expectedSSLError: string;
if (browserName === 'chromium') { if (browserName === 'chromium') {
expectedSSLError = 'net::ERR_CERT_AUTHORITY_INVALID'; expectedSSLError = 'net::ERR_CERT_AUTHORITY_INVALID';
} else if (browserName === 'webkit') { } else if (browserName === 'webkit') {
if (process.platform === 'darwin') if (platform === 'darwin')
expectedSSLError = 'The certificate for this server is invalid'; expectedSSLError = 'The certificate for this server is invalid';
else if (process.platform === 'win32') else if (platform === 'win32')
expectedSSLError = 'SSL peer certificate or SSH remote key was not OK'; expectedSSLError = 'SSL peer certificate or SSH remote key was not OK';
else else
expectedSSLError = 'Unacceptable TLS certificate'; expectedSSLError = 'Unacceptable TLS certificate';

View file

@ -16,7 +16,8 @@
import { playwrightTest as it, expect } from '../../config/browserTest'; import { playwrightTest as it, expect } from '../../config/browserTest';
it('should pass firefox user preferences', async ({ browserType }) => { it('should pass firefox user preferences', async ({ browserType, mode }) => {
it.skip(mode.startsWith('service'));
const browser = await browserType.launch({ const browser = await browserType.launch({
firefoxUserPrefs: { firefoxUserPrefs: {
'network.proxy.type': 1, 'network.proxy.type': 1,

View file

@ -53,7 +53,7 @@ it('should have version and creator', async ({ contextFactory, server }, testInf
const log = await getLog(); const log = await getLog();
expect(log.version).toBe('1.2'); expect(log.version).toBe('1.2');
expect(log.creator.name).toBe('Playwright'); expect(log.creator.name).toBe('Playwright');
expect(log.creator.version).toBe(process.env.PW_VERSION_OVERRIDE || require('../../package.json')['version']); expect(log.creator.version).toContain(process.env.PW_VERSION_OVERRIDE || require('../../package.json')['version']);
}); });
it('should have browser', async ({ browserName, browser, contextFactory, server }, testInfo) => { it('should have browser', async ({ browserName, browser, contextFactory, server }, testInfo) => {
@ -583,9 +583,10 @@ it('should have connection details', async ({ contextFactory, server, browserNam
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
const log = await getLog(); const log = await getLog();
const { serverIPAddress, _serverPort: port, _securityDetails: securityDetails } = log.entries[0]; const { serverIPAddress, _serverPort: port, _securityDetails: securityDetails } = log.entries[0];
expect(serverIPAddress).toMatch(/^127\.0\.0\.1|\[::1\]/); if (!mode.startsWith('service')) {
if (!mode.startsWith('service')) expect(serverIPAddress).toMatch(/^127\.0\.0\.1|\[::1\]/);
expect(port).toBe(server.PORT); expect(port).toBe(server.PORT);
}
expect(securityDetails).toEqual({}); expect(securityDetails).toEqual({});
}); });
@ -597,9 +598,10 @@ it('should have security details', async ({ contextFactory, httpsServer, browser
await page.goto(httpsServer.EMPTY_PAGE); await page.goto(httpsServer.EMPTY_PAGE);
const log = await getLog(); const log = await getLog();
const { serverIPAddress, _serverPort: port, _securityDetails: securityDetails } = log.entries[0]; const { serverIPAddress, _serverPort: port, _securityDetails: securityDetails } = log.entries[0];
expect(serverIPAddress).toMatch(/^127\.0\.0\.1|\[::1\]/); if (!mode.startsWith('service')) {
if (!mode.startsWith('service')) expect(serverIPAddress).toMatch(/^127\.0\.0\.1|\[::1\]/);
expect(port).toBe(httpsServer.PORT); expect(port).toBe(httpsServer.PORT);
}
if (browserName === 'webkit' && platform === 'darwin') if (browserName === 'webkit' && platform === 'darwin')
expect(securityDetails).toEqual({ protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863 }); expect(securityDetails).toEqual({ protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863 });
else else
@ -618,16 +620,16 @@ it('should have connection details for redirects', async ({ contextFactory, serv
if (browserName === 'webkit') { if (browserName === 'webkit') {
expect(detailsFoo.serverIPAddress).toBeUndefined(); expect(detailsFoo.serverIPAddress).toBeUndefined();
expect(detailsFoo._serverPort).toBeUndefined(); expect(detailsFoo._serverPort).toBeUndefined();
} else { } else if (!mode.startsWith('service')) {
expect(detailsFoo.serverIPAddress).toMatch(/^127\.0\.0\.1|\[::1\]/); expect(detailsFoo.serverIPAddress).toMatch(/^127\.0\.0\.1|\[::1\]/);
if (!mode.startsWith('service')) expect(detailsFoo._serverPort).toBe(server.PORT);
expect(detailsFoo._serverPort).toBe(server.PORT);
} }
const detailsEmpty = log.entries[1]; if (!mode.startsWith('service')) {
expect(detailsEmpty.serverIPAddress).toMatch(/^127\.0\.0\.1|\[::1\]/); const detailsEmpty = log.entries[1];
if (!mode.startsWith('service')) expect(detailsEmpty.serverIPAddress).toMatch(/^127\.0\.0\.1|\[::1\]/);
expect(detailsEmpty._serverPort).toBe(server.PORT); expect(detailsEmpty._serverPort).toBe(server.PORT);
}
}); });
it('should have connection details for failed requests', async ({ contextFactory, server, browserName, platform, mode }, testInfo) => { it('should have connection details for failed requests', async ({ contextFactory, server, browserName, platform, mode }, testInfo) => {
@ -638,18 +640,20 @@ it('should have connection details for failed requests', async ({ contextFactory
const { page, getLog } = await pageWithHar(contextFactory, testInfo); const { page, getLog } = await pageWithHar(contextFactory, testInfo);
await page.goto(server.PREFIX + '/one-style.html'); await page.goto(server.PREFIX + '/one-style.html');
const log = await getLog(); const log = await getLog();
const { serverIPAddress, _serverPort: port } = log.entries[0]; if (!mode.startsWith('service')) {
expect(serverIPAddress).toMatch(/^127\.0\.0\.1|\[::1\]/); const { serverIPAddress, _serverPort: port } = log.entries[0];
if (!mode.startsWith('service')) expect(serverIPAddress).toMatch(/^127\.0\.0\.1|\[::1\]/);
expect(port).toBe(server.PORT); expect(port).toBe(server.PORT);
}
}); });
it('should return server address directly from response', async ({ page, server, mode }) => { it('should return server address directly from response', async ({ page, server, mode }) => {
const response = await page.goto(server.EMPTY_PAGE); const response = await page.goto(server.EMPTY_PAGE);
const { ipAddress, port } = await response.serverAddr(); if (!mode.startsWith('service')) {
expect(ipAddress).toMatch(/^127\.0\.0\.1|\[::1\]/); const { ipAddress, port } = await response.serverAddr();
if (!mode.startsWith('service')) expect(ipAddress).toMatch(/^127\.0\.0\.1|\[::1\]/);
expect(port).toBe(server.PORT); expect(port).toBe(server.PORT);
}
}); });
it('should return security details directly from response', async ({ contextFactory, httpsServer, browserName, platform }) => { it('should return security details directly from response', async ({ contextFactory, httpsServer, browserName, platform }) => {

View file

@ -60,7 +60,7 @@ let connectOptions: any;
if (mode === 'service') if (mode === 'service')
connectOptions = { wsEndpoint: 'ws://localhost:3333/' }; connectOptions = { wsEndpoint: 'ws://localhost:3333/' };
if (mode === 'service2') { if (mode === 'service2') {
process.env.PW_VERSION_OVERRIDE = '1.36.0'; process.env.PW_VERSION_OVERRIDE = '1.37';
connectOptions = { connectOptions = {
wsEndpoint: `${process.env.PLAYWRIGHT_SERVICE_URL}?accessKey=${process.env.PLAYWRIGHT_SERVICE_ACCESS_KEY}&cap=${JSON.stringify({ os, runId })}`, wsEndpoint: `${process.env.PLAYWRIGHT_SERVICE_URL}?accessKey=${process.env.PLAYWRIGHT_SERVICE_ACCESS_KEY}&cap=${JSON.stringify({ os, runId })}`,
timeout: 3 * 60 * 1000, timeout: 3 * 60 * 1000,

View file

@ -137,30 +137,31 @@ test('should render console', async ({ showTraceViewer, browserName }) => {
const traceViewer = await showTraceViewer([traceFile]); const traceViewer = await showTraceViewer([traceFile]);
await traceViewer.showConsoleTab(); await traceViewer.showConsoleTab();
await expect(traceViewer.consoleLineMessages).toHaveText([ await expect(traceViewer.consoleLineMessages.nth(0)).toHaveText('Info');
'Info', await expect(traceViewer.consoleLineMessages.nth(1)).toHaveText('Warning');
'Warning', await expect(traceViewer.consoleLineMessages.nth(2)).toHaveText('Error');
'Error', await expect(traceViewer.consoleLineMessages.nth(3)).toHaveText('Unhandled exception');
'Unhandled exception', // Firefox can insert layout error here.
'Cheers!' await expect(traceViewer.consoleLineMessages.last()).toHaveText('Cheers!');
]);
await expect(traceViewer.consoleLines.locator('.codicon')).toHaveClass([ const icons = traceViewer.consoleLines.locator('.codicon');
'codicon codicon-blank', await expect(icons.nth(0)).toHaveClass('codicon codicon-blank');
'codicon codicon-warning', await expect(icons.nth(1)).toHaveClass('codicon codicon-warning');
'codicon codicon-error', await expect(icons.nth(2)).toHaveClass('codicon codicon-error');
'codicon codicon-error', await expect(icons.nth(3)).toHaveClass('codicon codicon-error');
'codicon codicon-blank', // Firefox can insert layout error here.
]); await expect(icons.last()).toHaveClass('codicon codicon-blank');
await expect(traceViewer.consoleStacks.first()).toContainText('Error: Unhandled exception'); await expect(traceViewer.consoleStacks.first()).toContainText('Error: Unhandled exception');
await traceViewer.selectAction('page.evaluate'); await traceViewer.selectAction('page.evaluate');
await expect(traceViewer.page.locator('.console-tab').locator('.list-view-entry')).toHaveClass([
'list-view-entry highlighted', const listViews = traceViewer.page.locator('.console-tab').locator('.list-view-entry');
'list-view-entry highlighted warning', await expect(listViews.nth(0)).toHaveClass('list-view-entry highlighted');
'list-view-entry highlighted error', await expect(listViews.nth(1)).toHaveClass('list-view-entry highlighted warning');
'list-view-entry highlighted error', await expect(listViews.nth(2)).toHaveClass('list-view-entry highlighted error');
'list-view-entry', await expect(listViews.nth(3)).toHaveClass('list-view-entry highlighted error');
]); // Firefox can insert layout error here.
await expect(listViews.last()).toHaveClass('list-view-entry');
}); });
test('should open console errors on click', async ({ showTraceViewer, browserName }) => { test('should open console errors on click', async ({ showTraceViewer, browserName }) => {

View file

@ -236,8 +236,9 @@ test('should respect tracesDir and name', async ({ browserType, server, mode },
} }
}); });
test('should not include trace resources from the previous chunks', async ({ context, page, server, browserName }, testInfo) => { test('should not include trace resources from the previous chunks', async ({ context, page, server, browserName, mode }, testInfo) => {
test.skip(browserName !== 'chromium', 'The number of screenshots is flaky in non-Chromium'); test.skip(browserName !== 'chromium', 'The number of screenshots is flaky in non-Chromium');
test.skip(mode.startsWith('service'), 'The number of screenshots is flaky');
await context.tracing.start({ screenshots: true, snapshots: true, sources: true }); await context.tracing.start({ screenshots: true, snapshots: true, sources: true });
await context.tracing.startChunk(); await context.tracing.startChunk();

View file

@ -43,7 +43,7 @@ it('should reject when frame detaches', async ({ page, server, browserName }) =>
expect(error.message.toLowerCase()).toContain('frame was detached'); expect(error.message.toLowerCase()).toContain('frame was detached');
}); });
it('should continue after client redirect', async ({ page, server, isAndroid }) => { it('should continue after client redirect', async ({ page, server, isAndroid, mode }) => {
it.fixme(isAndroid); it.fixme(isAndroid);
server.setRoute('/frames/script.js', () => {}); server.setRoute('/frames/script.js', () => {});

View file

@ -26,7 +26,8 @@ it('should close page with active dialog', async ({ page }) => {
await page.close(); await page.close();
}); });
it('should not accept after close', async ({ page }) => { it('should not accept after close', async ({ page, mode }) => {
it.fixme(mode.startsWith('service2'), 'Times out');
page.evaluate(() => alert()).catch(() => {}); page.evaluate(() => alert()).catch(() => {});
const dialog = await page.waitForEvent('dialog'); const dialog = await page.waitForEvent('dialog');
await page.close(); await page.close();

View file

@ -69,9 +69,10 @@ it('should report requests and responses handled by service worker', async ({ pa
expect(await failedRequest.response()).toBe(null); expect(await failedRequest.response()).toBe(null);
}); });
it('should report requests and responses handled by service worker with routing', async ({ page, server, isAndroid, isElectron }) => { it('should report requests and responses handled by service worker with routing', async ({ page, server, isAndroid, isElectron, mode, platform }) => {
it.fixme(isAndroid); it.fixme(isAndroid);
it.fixme(isElectron); it.fixme(isElectron);
it.fixme(mode.startsWith('service') && platform === 'linux', 'Times out for no clear reason');
await page.route('**/*', route => route.continue()); await page.route('**/*', route => route.continue());
await page.goto(server.PREFIX + '/serviceworkers/fetchdummy/sw.html'); await page.goto(server.PREFIX + '/serviceworkers/fetchdummy/sw.html');

View file

@ -263,7 +263,7 @@ it('should fail when navigating to bad url', async ({ mode, page, browserName })
expect(error.message).toContain('Invalid url'); expect(error.message).toContain('Invalid url');
}); });
it('should fail when navigating to bad SSL', async ({ page, browserName, httpsServer }) => { it('should fail when navigating to bad SSL', async ({ page, browserName, httpsServer, platform }) => {
// Make sure that network events do not emit 'undefined'. // Make sure that network events do not emit 'undefined'.
// @see https://crbug.com/750469 // @see https://crbug.com/750469
page.on('request', request => expect(request).toBeTruthy()); page.on('request', request => expect(request).toBeTruthy());
@ -271,15 +271,15 @@ it('should fail when navigating to bad SSL', async ({ page, browserName, httpsSe
page.on('requestfailed', request => expect(request).toBeTruthy()); page.on('requestfailed', request => expect(request).toBeTruthy());
let error = null; let error = null;
await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e); await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e);
expect(error.message).toContain(expectedSSLError(browserName)); expect(error.message).toContain(expectedSSLError(browserName, platform));
}); });
it('should fail when navigating to bad SSL after redirects', async ({ page, browserName, server, httpsServer }) => { it('should fail when navigating to bad SSL after redirects', async ({ page, browserName, server, httpsServer, platform }) => {
server.setRedirect('/redirect/1.html', '/redirect/2.html'); server.setRedirect('/redirect/1.html', '/redirect/2.html');
server.setRedirect('/redirect/2.html', '/empty.html'); server.setRedirect('/redirect/2.html', '/empty.html');
let error = null; let error = null;
await page.goto(httpsServer.PREFIX + '/redirect/1.html').catch(e => error = e); await page.goto(httpsServer.PREFIX + '/redirect/1.html').catch(e => error = e);
expect(error.message).toContain(expectedSSLError(browserName)); expect(error.message).toContain(expectedSSLError(browserName, platform));
}); });
it('should not crash when navigating to bad SSL after a cross origin navigation', async ({ page, server, httpsServer }) => { it('should not crash when navigating to bad SSL after a cross origin navigation', async ({ page, server, httpsServer }) => {
@ -307,6 +307,8 @@ it('should fail when main resources failed to load', async ({ page, browserName,
expect(error.message).toContain('net::ERR_SOCKS_CONNECTION_FAILED'); expect(error.message).toContain('net::ERR_SOCKS_CONNECTION_FAILED');
else else
expect(error.message).toContain('net::ERR_CONNECTION_REFUSED'); expect(error.message).toContain('net::ERR_CONNECTION_REFUSED');
} else if (browserName === 'webkit' && isWindows && mode === 'service2') {
expect(error.message).toContain(`proxy handshake error`);
} else if (browserName === 'webkit' && isWindows) { } else if (browserName === 'webkit' && isWindows) {
expect(error.message).toContain(`Couldn\'t connect to server`); expect(error.message).toContain(`Couldn\'t connect to server`);
} else if (browserName === 'webkit') { } else if (browserName === 'webkit') {

View file

@ -82,14 +82,14 @@ it('should work with clicking on anchor links', async ({ page, server }) => {
expect(page.url()).toBe(server.EMPTY_PAGE + '#foobar'); expect(page.url()).toBe(server.EMPTY_PAGE + '#foobar');
}); });
it('should work with clicking on links which do not commit navigation', async ({ page, server, httpsServer, browserName }) => { it('should work with clicking on links which do not commit navigation', async ({ page, server, httpsServer, browserName, platform }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await page.setContent(`<a href='${httpsServer.EMPTY_PAGE}'>foobar</a>`); await page.setContent(`<a href='${httpsServer.EMPTY_PAGE}'>foobar</a>`);
const [error] = await Promise.all([ const [error] = await Promise.all([
page.waitForNavigation().catch(e => e), page.waitForNavigation().catch(e => e),
page.click('a'), page.click('a'),
]); ]);
expect(error.message).toContain(expectedSSLError(browserName)); expect(error.message).toContain(expectedSSLError(browserName, platform));
}); });
it('should work with history.pushState()', async ({ page, server }) => { it('should work with history.pushState()', async ({ page, server }) => {