Merge branch 'main' into url-format-whatwg

This commit is contained in:
Simon Knott 2025-10-07 11:20:36 +02:00
commit a1519da231
No known key found for this signature in database
GPG Key ID: 8CEDC00028084AEC
4 changed files with 38 additions and 4 deletions

View File

@ -58,6 +58,7 @@ export function httpRequest(params: HTTPRequestParams, onResponse: (r: http.Inco
path: parsedUrl.href,
host: parsedProxyURL.hostname,
port: parsedProxyURL.port,
protocol: parsedProxyURL.protocol || 'http:',
headers: options.headers,
method: options.method
};

View File

@ -36,13 +36,13 @@
// Best-effort to show the report path in the dialog.
if (isTraceViewerInsidePlaywrightReport) {
const reportPath = (() => {
const base = window.location.pathname.replace(/\/trace\/index\.html$/, '');
const base = decodeURIComponent(window.location.pathname).replace(/\/trace\/index\.html$/, '');
if (navigator.platform === 'Win32')
return base.replace(/^\//, '').replace(/\//g, '\\\\');
return base;
})();
const reportLink = document.createElement('div');
const command = `npx playwright show-report ${reportPath}`;
const command = `npx playwright show-report "${reportPath}"`;
reportLink.innerHTML = `You can open the report via <code>${command}</code> from your Playwright project. <button type="button">Copy Command</button>`;
fallbackErrorDialog.insertBefore(reportLink, fallbackErrorDialog.children[1]);
reportLink.querySelector('button').addEventListener('click', () => navigator.clipboard.writeText(command));

View File

@ -16,7 +16,9 @@
import { test, expect } from './npmTest';
import { chromium } from '@playwright/test';
import path from 'path';
import https from 'https';
import { TestProxy } from '../config/proxy';
import { TestServer } from '../config/testserver';
test.use({ isolateBrowsers: true });
@ -90,6 +92,30 @@ test('install command should ignore HTTP_PROXY', { annotation: { type: 'issue',
});
});
test('install command should work with HTTPS proxy for HTTP downloads', async ({ exec }) => {
await exec('npm i playwright');
const httpsProxyServer = https.createServer(await TestServer.certOptions());
let requestCount = 0;
httpsProxyServer.on('request', (_req, res) => {
requestCount++;
res.statusCode = 502;
res.end();
});
await new Promise<void>(resolve => httpsProxyServer.listen(0, resolve));
await exec('npx playwright install chromium', {
env: {
PLAYWRIGHT_DOWNLOAD_HOST: 'http://example.com',
ALL_PROXY: `https://localhost:${(httpsProxyServer.address() as any).port}`,
NODE_TLS_REJECT_UNAUTHORIZED: '0',
},
expectToExitWithError: true,
});
expect(requestCount).toBeGreaterThan(0);
httpsProxyServer.close();
});
test('should be able to remove browsers', async ({ exec, checkInstalledSoftwareOnDisk }) => {
await exec('npm i playwright');
await exec('npx playwright install chromium');

View File

@ -2943,6 +2943,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
await expect(page.locator('.test-case-path')).toHaveText('Root describe');
});
test('should print a user-friendly warning when opening a trace via file:// protocol', async ({ runInlineTest, showReport, page }) => {
await runInlineTest({
'playwright.config.ts': `
@ -2965,10 +2966,16 @@ for (const useIntermediateMergeReport of [true, false] as const) {
const reportPath = path.join(test.info().outputPath(), 'playwright-report');
await page.goto(url.pathToFileURL(path.join(reportPath, 'index.html')).toString());
await page.getByRole('link', { name: 'View trace' }).click();
await expect(page.locator('#fallback-error')).toContainText('The Playwright Trace Viewer must be loaded over the http:// or https:// protocols.');
await expect(page.locator('#fallback-error')).toContainText(`npx playwright show-report ${reportPath.replace(/\\/g, '\\\\')}`);
await expect(page.locator('#fallback-error')).toContainText(
'The Playwright Trace Viewer must be loaded over the http:// or https:// protocols.'
);
const expectedReportPath = reportPath.replace(/\\/g, '\\\\');
await expect(page.locator('#fallback-error')).toContainText(
`npx playwright show-report "${expectedReportPath}"`
);
});
test('should not collate identical file names in different project directories', async ({ runInlineTest, page }) => {
await runInlineTest({
'playwright.config.ts': `