Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf59d10c

Browse files
committed
chore: custom title for browser downloads
- `Chrome for Testing`- `Chrome Headless Shell`- `Firefox`- `Firefox Beta`- `WebKit`Example output:```Downloading Chrome for Testing 143.0.7499.25 (playwright chromium v1202) fromhttps://cdn.playwright.dev/dbazure/download/playwright/builds/chromium/1202/chromium-mac-arm64.zip160 MiB [====================] 100% 0.0sChrome for Testing 143.0.7499.25 (playwright chromium v1202) downloaded to /Users/dgozman/Library/Caches/ms-playwright/chromium-1202```
1 parent16ddf81 commitf59d10c

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

‎packages/playwright-core/browsers.json‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,43 @@
55
"name":"chromium",
66
"revision":"1202",
77
"installByDefault":true,
8-
"browserVersion":"143.0.7499.25"
8+
"browserVersion":"143.0.7499.25",
9+
"title":"Chrome for Testing"
910
},
1011
{
1112
"name":"chromium-headless-shell",
1213
"revision":"1202",
1314
"installByDefault":true,
14-
"browserVersion":"143.0.7499.25"
15+
"browserVersion":"143.0.7499.25",
16+
"title":"Chrome Headless Shell"
1517
},
1618
{
1719
"name":"chromium-tip-of-tree",
1820
"revision":"1384",
1921
"installByDefault":false,
20-
"browserVersion":"143.0.7499.25"
22+
"browserVersion":"143.0.7499.25",
23+
"title":"Chrome Canary for Testing"
2124
},
2225
{
2326
"name":"chromium-tip-of-tree-headless-shell",
2427
"revision":"1384",
2528
"installByDefault":false,
26-
"browserVersion":"143.0.7499.25"
29+
"browserVersion":"143.0.7499.25",
30+
"title":"Chrome Canary Headless Shell"
2731
},
2832
{
2933
"name":"firefox",
3034
"revision":"1497",
3135
"installByDefault":true,
32-
"browserVersion":"144.0.2"
36+
"browserVersion":"144.0.2",
37+
"title":"Firefox"
3338
},
3439
{
3540
"name":"firefox-beta",
3641
"revision":"1493",
3742
"installByDefault":false,
38-
"browserVersion":"145.0b10"
43+
"browserVersion":"145.0b10",
44+
"title":"Firefox Beta"
3945
},
4046
{
4147
"name":"webkit",
@@ -55,7 +61,8 @@
5561
"ubuntu20.04-x64":"2092",
5662
"ubuntu20.04-arm64":"2092"
5763
},
58-
"browserVersion":"26.0"
64+
"browserVersion":"26.0",
65+
"title":"WebKit"
5966
},
6067
{
6168
"name":"ffmpeg",

‎packages/playwright-core/src/server/registry/index.ts‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ type BrowsersJSON = {
486486
name:string,
487487
revision:string,
488488
browserVersion?:string,
489+
title?:string,
489490
installByDefault:boolean,
490491
revisionOverrides?:{[os:string]:string},
491492
}[]
@@ -496,6 +497,7 @@ type BrowsersJSONDescriptor = {
496497
revision:string,
497498
hasRevisionOverride:boolean
498499
browserVersion?:string,
500+
title?:string,
499501
installByDefault:boolean,
500502
dir:string,
501503
};
@@ -519,6 +521,7 @@ function readDescriptors(browsersJSON: BrowsersJSON): BrowsersJSONDescriptor[] {
519521
hasRevisionOverride:!!revisionOverride,
520522
// We only put browser version for the supported operating systems.
521523
browserVersion:revisionOverride ?undefined :obj.browserVersion,
524+
title:obj['title'],
522525
installByDefault:!!obj.installByDefault,
523526
// Method `isBrowserDirectory` determines directory to be browser iff
524527
// it starts with some browser name followed by '-'. Some browser names
@@ -1247,13 +1250,7 @@ export class Registry {
12471250
logPolitely(message);
12481251
}
12491252

1250-
constdisplayName=descriptor.name.split('-').map(word=>{
1251-
returnword==='ffmpeg' ?'FFMPEG' :word.charAt(0).toUpperCase()+word.slice(1);
1252-
}).join(' ');
1253-
consttitle=descriptor.browserVersion
1254-
?`${displayName}${descriptor.browserVersion} (playwright build v${descriptor.revision})`
1255-
:`${displayName} playwright build v${descriptor.revision}`;
1256-
1253+
consttitle=calculateDownloadTitle(descriptor);
12571254
constdownloadFileName=`playwright-download-${descriptor.name}-${hostPlatform}-${descriptor.revision}.zip`;
12581255
// PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT is a misnomer, it actually controls the socket's
12591256
// max idle timeout. Unfortunately, we cannot rename it without breaking existing user workflows.
@@ -1523,4 +1520,12 @@ function lowercaseAllKeys(json: any): any {
15231520
returnresult;
15241521
}
15251522

1523+
functioncalculateDownloadTitle(descriptor:BrowsersJSONDescriptor){
1524+
consttitle=descriptor.title??descriptor.name.split('-').map(word=>{
1525+
returnword==='ffmpeg' ?'FFMPEG' :word.charAt(0).toUpperCase()+word.slice(1);
1526+
}).join(' ');
1527+
constversion=descriptor.browserVersion ?' '+descriptor.browserVersion :'';
1528+
return`${title}${version} (playwright${descriptor.name} v${descriptor.revision})`;
1529+
}
1530+
15261531
exportconstregistry=newRegistry(require('../../../browsers.json'));

‎tests/installation/npmTest.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const expect = _expect.extend({
3838
constdownloaded=newSet();
3939
letindex=0;
4040
while(true){
41-
constmatch=received.substring(index).match(/(chromium|chromiumheadlessshell|firefox|webkit|winldd|ffmpeg)[\s\d\.]+\(?playwrightbuildv\d+\)?downloaded/im);
41+
constmatch=received.substring(index).match(/\(playwright(chromium|chromium-headless-shell|firefox|webkit|winldd|ffmpeg)v\d+\)downloaded/im);
4242
if(!match)
4343
break;
4444
downloaded.add(match[1].replace(/\s/g,'-').toLowerCase());

‎tests/installation/playwright-cdn.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const CDNS = [
2424
'https://cdn.playwright.dev',
2525
];
2626

27-
constDL_STAT_BLOCK=/^.*fromurl:(.*)$\n^.*tolocation:(.*)$\n^.*responsestatuscode:(.*)$\n^.*ischunked:(.*)$\n^.*totalbytes:(\d+)$\n^.*downloadcomplete,size:(\d+)$\n^.*SUCCESSdownloading(\w+).*$/gm;
27+
constDL_STAT_BLOCK=/^.*fromurl:(.*)$\n^.*tolocation:(.*)$\n^.*responsestatuscode:(.*)$\n^.*ischunked:(.*)$\n^.*totalbytes:(\d+)$\n^.*downloadcomplete,size:(\d+)$\n^.*SUCCESSdownloading.*\(playwright([a-zA-Z-]+)v\d+\).*$/gm;
2828

2929
constparsedDownloads=(rawLogs:string)=>{
3030
constout:{url:string,status:number,name:string}[]=[];
@@ -123,7 +123,7 @@ test(`playwright cdn should not timeout on redirect`, {
123123
expectToExitWithError:true
124124
});
125125
// Steps after the extraction will fail, but the download should succeed without timeouts.
126-
expect(result).toContain(`pw:install SUCCESS downloadingChromium`);
126+
expect(result).toContain(`pw:install SUCCESS downloadingChrome`);
127127
expect(result).not.toContain(`timed out after 1000ms`);
128128
}finally{
129129
awaitnewPromise(resolve=>server.close(resolve));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp