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
Revert "chore: migrate away from ps1 in install-deps on Windows (#9876)"
Max Schmittdd1d3c3ed971
diff --git a/packages/playwright-core/bin/install_media_pack.ps1 b/packages/playwright-core/bin/install_media_pack.ps1new file mode 100644index 0000000000..6170754291--- /dev/null+++ b/packages/playwright-core/bin/install_media_pack.ps1@@ -0,0 +1,5 @@+$osInfo = Get-WmiObject -Class Win32_OperatingSystem+# check if running on Windows Server+if ($osInfo.ProductType -eq 3) {+ Install-WindowsFeature Server-Media-Foundation+}diff --git a/packages/playwright-core/src/utils/dependencies.ts b/packages/playwright-core/src/utils/dependencies.tsindex 08bf296f49..d52e4b6df3 100644--- a/packages/playwright-core/src/utils/dependencies.ts+++ b/packages/playwright-core/src/utils/dependencies.ts@@ -22,6 +22,8 @@ import { getUbuntuVersion } from './ubuntuVersion';import * as utils from './utils';import { buildPlaywrightCLICommand } from './registry';+const BIN_DIRECTORY = path.join(__dirname, '..', '..', 'bin');+const checkExecutable = (filePath: string) => fs.promises.access(filePath, fs.constants.X_OK).then(() => true).catch(e => false);function isSupportedWindowsVersion(): boolean {@@ -37,33 +39,11 @@ function isSupportedWindowsVersion(): boolean {export type DependencyGroup = 'chromium' | 'firefox' | 'webkit' | 'tools';export async function installDependenciesWindows(targets: Set<DependencyGroup>) {- if (!targets.has('chromium'))- return;- if (!await isWindowsServer())- return;- const { code } = await utils.spawnAsync('dism.exe', ['/Online', '/Enable-Feature', '/FeatureName:ServerMediaFoundation', '/Quiet'], { stdio: 'inherit' });- if (code !== 0)- throw new Error('Failed to install windows dependencies!');-}--async function isWindowsServer(): Promise<boolean> {- /**- * ProductType Enum:- * 0 = Unknown - Product type is unknown- * 1 = WorkStation - System is a workstation- * 2 = DomainController - System is a domain controller- * 3 = Server - System is a server- * @see https://docs.microsoft.com/en-us/dotnet/api/microsoft.powershell.commands.producttype?view=powershellsdk-1.1.0- */- const { code, stdout } = await utils.spawnAsync('wmic.exe', ['path', 'Win32_OperatingSystem', 'get', 'ProductType', '/VALUE']);- if (code !== 0)- throw new Error('Failed to get product type version!');- for (const line of stdout.trim().split('\n')) {- const [key, value] = line.split('=');- if (key === 'ProductType')- return parseInt(value, 10) === 3;+ if (targets.has('chromium')) {+ const { code } = await utils.spawnAsync('powershell.exe', ['-File', path.join(BIN_DIRECTORY, 'install_media_pack.ps1')], { cwd: BIN_DIRECTORY, stdio: 'inherit' });+ if (code !== 0)+ throw new Error('Failed to install windows dependencies!');}- throw new Error('Failed to parse product type version!\nstdout:' + stdout);}export async function installDependenciesLinux(targets: Set<DependencyGroup>) {