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

chore: custom title for browser downloads#38357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dgozman wants to merge1 commit intomicrosoft:main
base:main
Choose a base branch
Loading
fromdgozman:chore-download-title
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletionspackages/playwright-core/browsers.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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",
Expand All@@ -55,7 +61,8 @@
"ubuntu20.04-x64": "2092",
"ubuntu20.04-arm64": "2092"
},
"browserVersion": "26.0"
"browserVersion": "26.0",
"title": "WebKit"
},
{
"name": "ffmpeg",
Expand Down
19 changes: 12 additions & 7 deletionspackages/playwright-core/src/server/registry/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -486,6 +486,7 @@ type BrowsersJSON = {
name: string,
revision: string,
browserVersion?: string,
title?: string,
installByDefault: boolean,
revisionOverrides?: {[os: string]: string},
}[]
Expand All@@ -496,6 +497,7 @@ type BrowsersJSONDescriptor = {
revision: string,
hasRevisionOverride: boolean
browserVersion?: string,
title?: string,
installByDefault: boolean,
dir: string,
};
Expand All@@ -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
Expand DownExpand Up@@ -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.
Expand DownExpand Up@@ -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'));
2 changes: 1 addition & 1 deletiontests/installation/npmTest.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ const expect = _expect.extend({
const downloaded = new Set();
let index = 0;
while (true) {
const match = received.substring(index).match(/(chromium|chromiumheadlessshell|firefox|webkit|winldd|ffmpeg)[\s\d\.]+\(?playwright buildv\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());
Expand Down
4 changes: 2 additions & 2 deletionstests/installation/playwright-cdn.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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 }[] = [];
Expand DownExpand Up@@ -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 downloadingChromium`);
expect(result).toContain(`pw:install SUCCESS downloadingChrome`);
expect(result).not.toContain(`timed out after 1000ms`);
} finally {
await new Promise(resolve => server.close(resolve));
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp