Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(download): fix second browser download of channels (#33429)
Max Schmittba6386e0aef4
diff --git a/packages/playwright-core/browsers.json b/packages/playwright-core/browsers.jsonindex 05c0ee8381..b01f52fbd8 100644--- a/packages/playwright-core/browsers.json+++ b/packages/playwright-core/browsers.json@@ -7,6 +7,12 @@"installByDefault": true,"browserVersion": "131.0.6778.24"},+ {+ "name": "chromium-headless-shell",+ "revision": "1146",+ "installByDefault": false,+ "browserVersion": "131.0.6778.24"+ },{"name": "chromium-tip-of-tree","revision": "1274",diff --git a/packages/playwright-core/src/server/registry/index.ts b/packages/playwright-core/src/server/registry/index.tsindex 2c94b7f381..bf871e63c8 100644--- a/packages/playwright-core/src/server/registry/index.ts+++ b/packages/playwright-core/src/server/registry/index.ts@@ -352,7 +352,7 @@ export const registryDirectory = (() => {function isBrowserDirectory(browserDirectory: string): boolean {const baseName = path.basename(browserDirectory);for (const browserName of allDownloadable) {- if (baseName.startsWith(browserName + '-'))+ if (baseName.startsWith(browserName.replace(/-/g, '_') + '-'))return true;}return false;@@ -406,7 +406,7 @@ export type BrowserName = 'chromium' | 'firefox' | 'webkit' | 'bidi';type InternalTool = 'ffmpeg' | 'firefox-beta' | 'chromium-tip-of-tree' | 'chromium-headless-shell' |'android';type BidiChannel = 'bidi-firefox-stable' | 'bidi-firefox-beta' | 'bidi-firefox-nightly' | 'bidi-chrome-canary' | 'bidi-chrome-stable' | 'bidi-chromium';type ChromiumChannel = 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary';-const allDownloadable = ['chromium', 'firefox', 'webkit', 'ffmpeg', 'firefox-beta', 'chromium-tip-of-tree', 'chromium-headless-shell'];+const allDownloadable = ['android', 'chromium', 'firefox', 'webkit', 'ffmpeg', 'firefox-beta', 'chromium-tip-of-tree', 'chromium-headless-shell'];export interface Executable {type: 'browser' | 'tool' | 'channel';@@ -489,27 +489,20 @@ export class Registry {_isHermeticInstallation: true,});- const chromiumHeadlessShellDescriptor: BrowsersJSONDescriptor = {- name: 'chromium-headless-shell',- revision: chromium.revision,- browserVersion: chromium.browserVersion,- dir: chromium.dir.replace(/(.*)(-\d+)$/, '$1-headless-shell$2'),- installByDefault: false,- hasRevisionOverride: false,- };- const chromiumHeadlessShellExecutable = findExecutablePath(chromiumHeadlessShellDescriptor.dir, 'chromium-headless-shell');+ const chromiumHeadlessShell = descriptors.find(d => d.name === 'chromium-headless-shell')!;+ const chromiumHeadlessShellExecutable = findExecutablePath(chromiumHeadlessShell.dir, 'chromium-headless-shell');this._executables.push({type: 'tool',name: 'chromium-headless-shell',browserName: 'chromium',- directory: chromiumHeadlessShellDescriptor.dir,+ directory: chromiumHeadlessShell.dir,executablePath: () => chromiumHeadlessShellExecutable,executablePathOrDie: (sdkLanguage: string) => executablePathOrDie('chromium-headless-shell', chromiumHeadlessShellExecutable, false, sdkLanguage),- installType: 'download-on-demand',- _validateHostRequirements: (sdkLanguage: string) => this._validateHostRequirements(sdkLanguage, chromiumHeadlessShellDescriptor.dir, ['chrome-linux'], [], ['chrome-win']),- downloadURLs: this._downloadURLs(chromiumHeadlessShellDescriptor),+ installType: chromiumHeadlessShell.installByDefault ? 'download-by-default' : 'download-on-demand',+ _validateHostRequirements: (sdkLanguage: string) => this._validateHostRequirements(sdkLanguage, chromiumHeadlessShell.dir, ['chrome-linux'], [], ['chrome-win']),+ downloadURLs: this._downloadURLs(chromiumHeadlessShell),browserVersion: chromium.browserVersion,- _install: () => this._downloadExecutable(chromiumHeadlessShellDescriptor, chromiumHeadlessShellExecutable),+ _install: () => this._downloadExecutable(chromiumHeadlessShell, chromiumHeadlessShellExecutable),_dependencyGroup: 'chromium',_isHermeticInstallation: true,});diff --git a/utils/roll_browser.js b/utils/roll_browser.jsindex a57b4f5004..4d9167f0f7 100755--- a/utils/roll_browser.js+++ b/utils/roll_browser.js@@ -94,6 +94,14 @@ Example:console.log('\nUpdating browser version in browsers.json...');for (const descriptor of descriptors)descriptor.browserVersion = browserVersion;++ // 4.1 chromium-headless-shell is equal to chromium version.+ if (browserName === 'chromium') {+ const headlessShellBrowser = await browsersJSON.browsers.find(b => b.name === 'chromium-headless-shell');+ headlessShellBrowser.revision = revision;+ headlessShellBrowser.browserVersion = browserVersion;+ }+fs.writeFileSync(path.join(CORE_PATH, 'browsers.json'), JSON.stringify(browsersJSON, null, 2) + '\n');}