Skip to content

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

chore: custom title for browser downloads (#38357)

Dmitry Gozmanfe662b3c6618
diff --git a/packages/playwright-core/browsers.json b/packages/playwright-core/browsers.json
index bf87717902..983fc3a4fb 100644
--- a/packages/playwright-core/browsers.json
+++ b/packages/playwright-core/browsers.json
@@ -5,37 +5,43 @@
"name": "chromium",
"revision": "1202",
"installByDefault": true,
- "browserVersion": "143.0.7499.25"
+ "browserVersion": "143.0.7499.25",
+ "title": "Chrome for Testing"
},
{
"name": "chromium-headless-shell",
"revision": "1202",
"installByDefault": true,
- "browserVersion": "143.0.7499.25"
+ "browserVersion": "143.0.7499.25",
+ "title": "Chrome Headless Shell"
},
{
"name": "chromium-tip-of-tree",
"revision": "1384",
"installByDefault": false,
- "browserVersion": "143.0.7499.25"
+ "browserVersion": "143.0.7499.25",
+ "title": "Chrome Canary for Testing"
},
{
"name": "chromium-tip-of-tree-headless-shell",
"revision": "1384",
"installByDefault": false,
- "browserVersion": "143.0.7499.25"
+ "browserVersion": "143.0.7499.25",
+ "title": "Chrome Canary Headless Shell"
},
{
"name": "firefox",
"revision": "1497",
"installByDefault": true,
- "browserVersion": "144.0.2"
+ "browserVersion": "144.0.2",
+ "title": "Firefox"
},
{
"name": "firefox-beta",
"revision": "1493",
"installByDefault": false,
- "browserVersion": "145.0b10"
+ "browserVersion": "145.0b10",
+ "title": "Firefox Beta"
},
{
"name": "webkit",
@@ -55,7 +61,8 @@
"ubuntu20.04-x64": "2092",
"ubuntu20.04-arm64": "2092"
},
- "browserVersion": "26.0"
+ "browserVersion": "26.0",
+ "title": "WebKit"
},
{
"name": "ffmpeg",
diff --git a/packages/playwright-core/src/server/registry/index.ts b/packages/playwright-core/src/server/registry/index.ts
index 76a02fc543..cb34da3624 100644
--- a/packages/playwright-core/src/server/registry/index.ts
+++ b/packages/playwright-core/src/server/registry/index.ts
@@ -486,6 +486,7 @@ type BrowsersJSON = {
name: string,
revision: string,
browserVersion?: string,
+ title?: string,
installByDefault: boolean,
revisionOverrides?: {[os: string]: string},
}[]
@@ -496,6 +497,7 @@ type BrowsersJSONDescriptor = {
revision: string,
hasRevisionOverride: boolean
browserVersion?: string,
+ title?: string,
installByDefault: boolean,
dir: string,
};
@@ -519,6 +521,7 @@ function readDescriptors(browsersJSON: BrowsersJSON): BrowsersJSONDescriptor[] {
hasRevisionOverride: !!revisionOverride,
// We only put browser version for the supported operating systems.
browserVersion: revisionOverride ? undefined : obj.browserVersion,
+ title: obj['title'],
installByDefault: !!obj.installByDefault,
// Method `isBrowserDirectory` determines directory to be browser iff
// it starts with some browser name followed by '-'. Some browser names
@@ -1247,13 +1250,7 @@ export class Registry {
logPolitely(message);
}
- const displayName = descriptor.name.split('-').map(word => {
- return word === 'ffmpeg' ? 'FFMPEG' : word.charAt(0).toUpperCase() + word.slice(1);
- }).join(' ');
- const title = descriptor.browserVersion
- ? `${displayName} ${descriptor.browserVersion} (playwright build v${descriptor.revision})`
- : `${displayName} playwright build v${descriptor.revision}`;
-
+ const title = calculateDownloadTitle(descriptor);
const downloadFileName = `playwright-download-${descriptor.name}-${hostPlatform}-${descriptor.revision}.zip`;
// PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT is a misnomer, it actually controls the socket's
// max idle timeout. Unfortunately, we cannot rename it without breaking existing user workflows.
@@ -1523,4 +1520,12 @@ function lowercaseAllKeys(json: any): any {
return result;
}
+function calculateDownloadTitle(descriptor: BrowsersJSONDescriptor) {
+ const title = descriptor.title ?? descriptor.name.split('-').map(word => {
+ return word === 'ffmpeg' ? 'FFMPEG' : word.charAt(0).toUpperCase() + word.slice(1);
+ }).join(' ');
+ const version = descriptor.browserVersion ? ' ' + descriptor.browserVersion : '';
+ return `${title}${version} (playwright ${descriptor.name} v${descriptor.revision})`;
+}
+
export const registry = new Registry(require('../../../browsers.json'));
diff --git a/tests/installation/npmTest.ts b/tests/installation/npmTest.ts
index fef212c0ca..73cca42fd7 100644
--- a/tests/installation/npmTest.ts
+++ b/tests/installation/npmTest.ts
@@ -38,7 +38,7 @@ const expect = _expect.extend({
const downloaded = new Set();
let index = 0;
while (true) {
- const match = received.substring(index).match(/(chromium|chromium headless shell|firefox|webkit|winldd|ffmpeg)[\s\d\.]+\(?playwright build v\d+\)? downloaded/im);
+ const match = received.substring(index).match(/\(playwright (chromium|chromium-headless-shell|firefox|webkit|winldd|ffmpeg) v\d+\) downloaded/im);
if (!match)
break;
downloaded.add(match[1].replace(/\s/g, '-').toLowerCase());
diff --git a/tests/installation/playwright-cdn.spec.ts b/tests/installation/playwright-cdn.spec.ts
index a0d2ae6d6e..ac03a4b92e 100644
--- a/tests/installation/playwright-cdn.spec.ts
+++ b/tests/installation/playwright-cdn.spec.ts
@@ -24,7 +24,7 @@ const CDNS = [
'https://cdn.playwright.dev',
];
-const DL_STAT_BLOCK = /^.*from url: (.*)$\n^.*to location: (.*)$\n^.*response status code: (.*)$\n^.*is chunked: (.*)$\n^.*total bytes: (\d+)$\n^.*download complete, size: (\d+)$\n^.*SUCCESS downloading (\w+) .*$/gm;
+const DL_STAT_BLOCK = /^.*from url: (.*)$\n^.*to location: (.*)$\n^.*response status code: (.*)$\n^.*is chunked: (.*)$\n^.*total bytes: (\d+)$\n^.*download complete, size: (\d+)$\n^.*SUCCESS downloading.*\(playwright ([a-zA-Z-]+) v\d+\).*$/gm;
const parsedDownloads = (rawLogs: string) => {
const out: { url: string, status: number, name: string }[] = [];
@@ -123,7 +123,7 @@ test(`playwright cdn should not timeout on redirect`, {
expectToExitWithError: true
});
// Steps after the extraction will fail, but the download should succeed without timeouts.
- expect(result).toContain(`pw:install SUCCESS downloading Chromium`);
+ expect(result).toContain(`pw:install SUCCESS downloading Chrome`);
expect(result).not.toContain(`timed out after 1000ms`);
} finally {
await new Promise(resolve => server.close(resolve));