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
chore: use helper functions to define platforms (#13707)
Andrey Lushnikovec4ebefbd664
diff --git a/browser_patches/chromium/archive.sh b/browser_patches/chromium/archive.shindex 72f1fa593f..c9de582580 100755--- a/browser_patches/chromium/archive.sh+++ b/browser_patches/chromium/archive.sh@@ -5,6 +5,7 @@ set +xtrap "cd $(pwd -P)" EXITcd "$(dirname "$0")"SCRIPT_PATH=$(pwd -P)+source "${SCRIPT_PATH}/../utils.sh"if [[ ("$1" == "-h") || ("$1" == "--help") ]]; thenecho "usage: $(basename "$0") [output-absolute-path]"@@ -44,15 +45,15 @@ fiCHROMIUM_FOLDER_NAME=""CHROMIUM_FILES_TO_ARCHIVE=()-if [[ $(uname) == "Darwin" ]]; then+if is_mac; thenCHROMIUM_FOLDER_NAME="chrome-mac"IFS=$'\n' CHROMIUM_FILES_TO_ARCHIVE=($(node "${SCRIPT_PATH}/compute_files_to_archive.js" "${CR_CHECKOUT_PATH}/src/infra/archive_config/mac-archive-rel.json"))unset IFS-elif [[ $(uname) == "Linux" ]]; then+elif is_linux; thenCHROMIUM_FOLDER_NAME="chrome-linux"IFS=$'\n' CHROMIUM_FILES_TO_ARCHIVE=($(node "${SCRIPT_PATH}/compute_files_to_archive.js" "${CR_CHECKOUT_PATH}/src/infra/archive_config/linux-archive-rel.json"))unset IFS-elif [[ $(uname) == "MINGW"* || "$(uname)" == MSYS* ]]; then+elif is_win; thenCHROMIUM_FOLDER_NAME="chrome-win"IFS=$'\n\r' CHROMIUM_FILES_TO_ARCHIVE=($(node "${SCRIPT_PATH}/compute_files_to_archive.js" "${CR_CHECKOUT_PATH}/src/infra/archive_config/win-archive-rel.json"))unset IFS@@ -68,7 +69,7 @@ mkdir -p "output/${CHROMIUM_FOLDER_NAME}"# On Mac, use 'ditto' to copy directories instead of 'cp'.COPY_COMMAND="cp -R"-if [[ $(uname) == "Darwin" ]]; then+if is_mac; thenCOPY_COMMAND="ditto"fi@@ -78,7 +79,7 @@ for ((i = 0; i < ${#CHROMIUM_FILES_TO_ARCHIVE[@]}; i++)) do$COPY_COMMAND "${CR_CHECKOUT_PATH}/src/out/Default/${file}" "output/${CHROMIUM_FOLDER_NAME}/${file}"done-if [[ $(uname) == "MINGW"* || "$(uname)" == MSYS* ]]; then+if is_win; then$COPY_COMMAND "${CR_CHECKOUT_PATH}/src/out/Default/"*.manifest "output/${CHROMIUM_FOLDER_NAME}/"mkdir -p "output/${CHROMIUM_FOLDER_NAME}/locales"$COPY_COMMAND "${CR_CHECKOUT_PATH}/src/out/Default/locales/"*.pak "output/${CHROMIUM_FOLDER_NAME}/locales/"diff --git a/browser_patches/chromium/build.sh b/browser_patches/chromium/build.shindex 72d66d5e46..32393c8b05 100755--- a/browser_patches/chromium/build.sh+++ b/browser_patches/chromium/build.sh@@ -5,6 +5,7 @@ set +xtrap "cd $(pwd -P)" EXITcd "$(dirname "$0")"SCRIPT_FOLDER=$(pwd -P)+source "${SCRIPT_FOLDER}/../utils.sh"USAGE=$(cat<<EOFusage: $(basename "$0") [--arm64] [--symbols] [--full] [--goma] <custom targets to compile>@@ -54,7 +55,7 @@ compile_chromium() {source "${SCRIPT_FOLDER}/ensure_depot_tools.sh"- if [[ $(uname) == "Darwin" ]]; then+ if is_mac; then# As of Apr, 2022 Chromium mac compilation requires Xcode13.3selectXcodeVersionOrDie "13.3"fi@@ -85,7 +86,7 @@ compile_chromium() {echo "===== ======= ====="if [[ -n "$IS_FULL" ]]; then- if [[ $(uname) == "Linux" ]]; then+ if is_linux; then./build/install-build-deps.shif [[ -n "$IS_ARM64" ]]; then# Install sysroot image, see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/linux/chromium_arm.md@@ -95,7 +96,7 @@ compile_chromium() {fiTARGETS="${args[@]}"- if [[ $(uname) == "MINGW"* || "$(uname)" == MSYS* ]]; then+ if is_win; thenif [[ -n "$TARGETS" ]]; thenecho "ERROR: cannot compile custom targets on windows yet."echo "Requested to compile chromium targets - ${TARGETS}"@@ -108,7 +109,7 @@ compile_chromium() {fielseif [[ -z "$TARGETS" ]]; then- if [[ $(uname) == "Linux" ]]; then+ if is_linux; thenTARGETS="chrome chrome_sandbox clear_key_cdm"elseTARGETS="chrome"diff --git a/browser_patches/chromium/goma.sh b/browser_patches/chromium/goma.shindex 9241899112..426f9896bc 100755--- a/browser_patches/chromium/goma.sh+++ b/browser_patches/chromium/goma.sh@@ -5,6 +5,7 @@ set +xtrap "cd $(pwd -P)" EXITcd "$(dirname "$0")"SCRIPT_FOLDER=$(pwd -P)+source "${SCRIPT_FOLDER}/../utils.sh"ELECTRON_BUILD_TOOLS_REQUIRED_VERSION=6ba8962529c37727a778691b89c92ab0eb1d9d87if [[ -d ./electron-build-tools ]]; then@@ -35,7 +36,7 @@ export GOMA_START_COMPILER_PROXY=truefunction print_gn_args() {PLAYWRIGHT_GOMA_PATH="${SCRIPT_FOLDER}/electron-build-tools/third_party/goma"- if [[ $(uname) == MINGW* || "$(uname)" == MSYS* ]]; then+ if is_win; thenPLAYWRIGHT_GOMA_PATH=$(cygpath -w "${PLAYWRIGHT_GOMA_PATH}")fiecho 'use_goma = true'@@ -48,7 +49,7 @@ if [[ $1 == "--help" ]]; thenelif [[ $1 == "args" ]]; thenprint_gn_argselif [[ $1 == "login" ]]; then- if [[ $(uname) == "MINGW"* || "$(uname)" == MSYS* ]]; then+ if is_win; then/c/Windows/System32/cmd.exe "/c $(cygpath -w $(pwd)/goma_auth.bat) login"elsepython ./goma_auth.py login@@ -67,7 +68,7 @@ elif [[ $1 == "start" ]]; thenecho "run '$(basename "$0") login'"exit 1fi- if [[ $(uname) == "MINGW"* || "$(uname)" == MSYS* ]]; then+ if is_win; then/c/Windows/System32/cmd.exe "/c $(cygpath -w $(pwd)/goma_ctl.bat) ensure_start"elsepython ./goma_ctl.py ensure_start@@ -82,7 +83,7 @@ elif [[ $1 == "start" ]]; thenprint_gn_argsecho "===== ======= ====="elif [[ $1 == "stop" ]]; then- if [[ $(uname) == "MINGW"* || "$(uname)" == MSYS* ]]; then+ if is_win; then/c/Windows/System32/cmd.exe "/c $(cygpath -w $(pwd)/goma_ctl.bat) stop"elsepython ./goma_ctl.py stopdiff --git a/browser_patches/firefox-beta/archive.sh b/browser_patches/firefox-beta/archive.shindex cfd280aef3..a98edfdb19 100755--- a/browser_patches/firefox-beta/archive.sh+++ b/browser_patches/firefox-beta/archive.sh@@ -54,9 +54,9 @@ fi# Copy the libstdc++ version we linked against.# TODO(aslushnikov): this won't be needed with official builds.-if [[ "$(uname)" == "Linux" ]]; then+if is_linux; thencp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 "${OBJ_FOLDER}/dist/firefox/libstdc++.so.6"-elif [[ "$(uname)" == MINGW* || "$(uname)" == MSYS* ]]; then+elif is_win; then# Bundle vcruntime14_1.dll - see https://github.com/microsoft/playwright/issues/9974cd "$(printMSVCRedistDir)"cp -t "${OBJ_FOLDER}/dist/firefox" vcruntime140_1.dlldiff --git a/browser_patches/firefox-beta/build.sh b/browser_patches/firefox-beta/build.shindex 0e774479a5..3b8a68dcab 100755--- a/browser_patches/firefox-beta/build.sh+++ b/browser_patches/firefox-beta/build.sh@@ -20,7 +20,7 @@ firm -rf .mozconfig-if [[ "$(uname)" == "Darwin" ]]; then+if is_mac; thenCURRENT_HOST_OS_VERSION=$(getMacVersion)# As of Oct 2021, building Firefox requires XCode 13if [[ "${CURRENT_HOST_OS_VERSION}" != "10."* ]]; then@@ -30,9 +30,9 @@ if [[ "$(uname)" == "Darwin" ]]; thenexit 1fiecho "-- building on Mac"-elif [[ "$(uname)" == "Linux" ]]; then+elif is_linux; thenecho "-- building on Linux"-elif [[ "$(uname)" == MINGW* || "$(uname)" == MSYS* ]]; then+elif is_win; thenecho "ac_add_options --disable-update-agent" >> .mozconfigecho "ac_add_options --disable-default-browser-agent" >> .mozconfigecho "ac_add_options --disable-maintenance-service" >> .mozconfig@@ -67,7 +67,7 @@ elseecho "ac_add_options --enable-release" >> .mozconfigfi-if [[ "$(uname)" == MINGW* || "$(uname)" == "Darwin" || "$(uname)" == MSYS* ]]; then+if is_mac || is_win; then# This options is only available on win and mac.echo "ac_add_options --disable-update-agent" >> .mozconfigfi@@ -90,7 +90,7 @@ fiif [[ $1 == "--full" || $2 == "--full" || $1 == "--bootstrap" ]]; thenecho "ac_add_options --enable-bootstrap" >> .mozconfig- if [[ "$(uname)" == "Darwin" || "$(uname)" == "Linux" ]]; then+ if is_mac || is_linux; thenSHELL=/bin/sh ./mach --no-interactive bootstrap --application-choice=browserfiif [[ ! -z "${WIN32_REDIST_DIR}" ]]; then@@ -105,7 +105,7 @@ elif [[ $1 == "--bootstrap" ]]; then./mach configureelse./mach build- if [[ "$(uname)" == "Darwin" ]]; then+ if is_mac; thennode "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/distelsenode "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist/bindiff --git a/browser_patches/firefox/archive.sh b/browser_patches/firefox/archive.shindex 78ad1d6526..02b04f9037 100755--- a/browser_patches/firefox/archive.sh+++ b/browser_patches/firefox/archive.sh@@ -56,9 +56,9 @@ fi# Copy the libstdc++ version we linked against.# TODO(aslushnikov): this won't be needed with official builds.-if [[ "$(uname)" == "Linux" ]]; then+if is_linux; thencp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 "${OBJ_FOLDER}/dist/firefox/libstdc++.so.6"-elif [[ "$(uname)" == MINGW* || "$(uname)" == MSYS* ]]; then+elif is_win; then# Bundle vcruntime14_1.dll - see https://github.com/microsoft/playwright/issues/9974cd "$(printMSVCRedistDir)"cp -t "${OBJ_FOLDER}/dist/firefox" vcruntime140_1.dlldiff --git a/browser_patches/firefox/build.sh b/browser_patches/firefox/build.shindex 0b7df1f791..27797de21a 100755--- a/browser_patches/firefox/build.sh+++ b/browser_patches/firefox/build.sh@@ -20,7 +20,7 @@ firm -rf .mozconfig-if [[ "$(uname)" == "Darwin" ]]; then+if is_mac; thenCURRENT_HOST_OS_VERSION=$(getMacVersion)# As of Oct 2021, building Firefox requires XCode 13if [[ "${CURRENT_HOST_OS_VERSION}" != "10."* ]]; then@@ -30,9 +30,9 @@ if [[ "$(uname)" == "Darwin" ]]; thenexit 1fiecho "-- building on Mac"-elif [[ "$(uname)" == "Linux" ]]; then+elif is_linux; thenecho "-- building on Linux"-elif [[ "$(uname)" == MINGW* || "$(uname)" == MSYS* ]]; then+elif is_win; thenecho "ac_add_options --disable-update-agent" >> .mozconfigecho "ac_add_options --disable-default-browser-agent" >> .mozconfigecho "ac_add_options --disable-maintenance-service" >> .mozconfig@@ -67,7 +67,7 @@ elseecho "ac_add_options --enable-release" >> .mozconfigfi-if [[ "$(uname)" == MINGW* || "$(uname)" == "Darwin" || "$(uname)" == MSYS* ]]; then+if is_win || is_mac; then# This options is only available on win and mac.echo "ac_add_options --disable-update-agent" >> .mozconfigfi@@ -89,7 +89,7 @@ if [[ $1 != "--juggler" ]]; thenfiif [[ $1 == "--full" || $2 == "--full" ]]; then- if [[ "$(uname)" == "Linux" ]]; then+ if is_linux; thenecho "ac_add_options --enable-bootstrap" >> .mozconfigSHELL=/bin/sh ./mach --no-interactive bootstrap --application-choice=browserfi@@ -99,7 +99,7 @@ if [[ $1 == "--full" || $2 == "--full" ]]; thenfifi-if [[ "$(uname)" == "Darwin" ]]; then+if is_mac; thenif [[ ! -d "$HOME/.mozbuild/clang" ]]; thenecho "ERROR: build toolchains are not found, specifically \$HOME/.mozbuild/clang is not there!"echo "Since December, 2021, build toolchains have to be predownloaded (see https://github.com/microsoft/playwright/pull/10929)"@@ -118,7 +118,7 @@ if [[ $1 == "--juggler" ]]; then./mach build fasterelse./mach build- if [[ "$(uname)" == "Darwin" ]]; then+ if is_mac; thennode "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/distelsenode "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist/bindiff --git a/browser_patches/prepare_checkout.sh b/browser_patches/prepare_checkout.shindex 1e8fe3b35d..8926b33273 100755--- a/browser_patches/prepare_checkout.sh+++ b/browser_patches/prepare_checkout.sh@@ -6,6 +6,8 @@ trap "cd $(pwd -P)" EXITcd "$(dirname "$0")"SCRIPT_PATH=$(pwd -P)+source "${SCRIPT_PATH}/utils.sh"+REMOTE_BROWSER_UPSTREAM="browser_upstream"BUILD_BRANCH="playwright-build"@@ -28,7 +30,7 @@ if [[ $# == 0 ]]; thenfifunction maybe_cmd {- if [[ $(uname) == MINGW* || "$(uname)" == MSYS* ]]; then+ if is_win; thenlocal args="$@"/c/Windows/System32/cmd.exe "/c $args"else@@ -62,7 +64,7 @@ function prepare_chromium_checkout {cd "${CR_CHECKOUT_PATH}"maybe_cmd fetch --nohooks chromiumcd src- if [[ $(uname) == "Linux" ]]; then+ if is_linux; then./build/install-build-deps.shfimaybe_cmd gclient runhooksdiff --git a/browser_patches/upload.sh b/browser_patches/upload.shindex be47387cdd..70c813e939 100755--- a/browser_patches/upload.sh+++ b/browser_patches/upload.sh@@ -5,6 +5,8 @@ set +xtrap "cd $(pwd -P)" EXITcd "$(dirname "$0")"+source "./utils.sh"+if [[ ($1 == '--help') || ($1 == '-h') ]]; thenecho "usage: $(basename "$0") [BLOB-PATH] [--check|ZIP-PATH]"echo@@ -62,7 +64,7 @@ if [[ "${ZIP_PATH}" != *.zip && "${ZIP_PATH}" != *.gz ]]; thenecho "ERROR: ${ZIP_PATH} is not an archive (must have a .zip or .gz extension)"exit 1fi-if [[ $(uname) == MINGW* || "$(uname)" == MSYS* ]]; then+if is_win; then# Convert POSIX path to MSYSWIN_PATH=$({ cd $(dirname "$ZIP_PATH") && pwd -W; } | sed 's|/|\\|g')WIN_PATH="${WIN_PATH}\\$(basename "$ZIP_PATH")"diff --git a/browser_patches/utils.sh b/browser_patches/utils.shindex a5eba2705b..6f6d0a76eb 100644--- a/browser_patches/utils.sh+++ b/browser_patches/utils.sh@@ -42,3 +42,27 @@ function printMSVCRedistDir() {fiecho "$redist_dir"}++function is_win() {+ if [[ "$(uname)" == MINGW* || "$(uname)" == MSYS* ]]; then+ return 0;+ else+ return 1;+ fi+}++function is_mac() {+ if [[ "$(uname)" == "Darwin" ]]; then+ return 0;+ else+ return 1;+ fi+}++function is_linux() {+ if [[ "$(uname)" == "Linux" ]]; then+ return 0;+ else+ return 1;+ fi+}diff --git a/browser_patches/webkit/archive.sh b/browser_patches/webkit/archive.shindex 6a1e00c6f7..15adba3ba9 100755--- a/browser_patches/webkit/archive.sh+++ b/browser_patches/webkit/archive.sh@@ -37,11 +37,11 @@ main() {fiset -x- if [[ "$(uname)" == "Darwin" ]]; then+ if is_mac; thencreateZipForMac- elif [[ "$(uname)" == "Linux" ]]; then+ elif is_linux; thencreateZipForLinux- elif [[ "$(uname)" == MINGW* || "$(uname)" == MSYS* ]]; then+ elif is_win; thencreateZipForWindowselseecho "ERROR: cannot upload on this platform!" 1>&2diff --git a/browser_patches/webkit/build.sh b/browser_patches/webkit/build.shindex bb70529567..5123366732 100755--- a/browser_patches/webkit/build.sh+++ b/browser_patches/webkit/build.sh@@ -51,7 +51,7 @@ elsecd "$HOME/webkit"fi-if [[ "$(uname)" == "Darwin" ]]; then+if is_mac; thenCURRENT_HOST_OS_VERSION=$(getMacVersion)if [[ "${CURRENT_HOST_OS_VERSION}" == "10.15" ]]; thenselectXcodeVersionOrDie "11.7"@@ -64,7 +64,7 @@ if [[ "$(uname)" == "Darwin" ]]; thenexit 1fi./Tools/Scripts/build-webkit --release --touch-events --orientation-events-elif [[ "$(uname)" == "Linux" ]]; then+elif is_linux; thenif [[ $# == 0 || (-z "$1") ]]; thenechoecho BUILDING: GTK and WPE@@ -89,7 +89,7 @@ elif [[ "$(uname)" == "Linux" ]]; thenechobuild_wpefi-elif [[ "$(uname)" == MINGW* || "$(uname)" == MSYS* ]]; then+elif is_win; then/c/Windows/System32/cmd.exe "/c $(cygpath -w "${SCRIPT_FOLDER}"/buildwin.bat)"elseecho "ERROR: cannot upload on this platform!" 1>&2diff --git a/browser_patches/webkit/clean.sh b/browser_patches/webkit/clean.shindex 0a843871a7..fabc11297a 100755--- a/browser_patches/webkit/clean.sh+++ b/browser_patches/webkit/clean.sh@@ -5,6 +5,8 @@ set +xtrap "cd $(pwd -P)" EXITcd "$(dirname "$0")"+source "../utils.sh"+if [[ ! -z "${WK_CHECKOUT_PATH}" ]]; thencd "${WK_CHECKOUT_PATH}"echo "WARNING: checkout path from WK_CHECKOUT_PATH env: ${WK_CHECKOUT_PATH}"@@ -12,7 +14,7 @@ elsecd "$HOME/webkit"fi-if [[ "$(uname)" == "Darwin" ]]; then+if is_mac; thenrm -rf ./WebKitBuildelseif [[ -d ./WebKitBuild ]]; thendiff --git a/browser_patches/winldd/archive.sh b/browser_patches/winldd/archive.shindex 062dc9186c..46f1d62a34 100755--- a/browser_patches/winldd/archive.sh+++ b/browser_patches/winldd/archive.sh@@ -10,11 +10,6 @@ if [[ ("$1" == "-h") || ("$1" == "--help") ]]; thenexit 0fi-if [[ "$(uname)" != MINGW* || "$(uname)" == MSYS* ]]; then- echo "ERROR: this script only supports MINGW (windows)"- exit 1-fi-ZIP_PATH=$1if [[ $ZIP_PATH != /* ]]; thenecho "ERROR: path $ZIP_PATH is not absolute"@@ -36,6 +31,12 @@ fitrap "cd $(pwd -P)" EXITcd "$(dirname "$0")"+if [[ "$(uname)" != MINGW* ]]; then+ echo "ERROR: this script only supports MINGW (windows)"+ exit 1+fi++# create a TMP directory to copy all necessary filescd ./x64/Releasezip $ZIP_PATH ./PrintDeps.exediff --git a/browser_patches/winldd/build.sh b/browser_patches/winldd/build.shindex 5f02e935a0..790cd84f27 100755--- a/browser_patches/winldd/build.sh+++ b/browser_patches/winldd/build.sh@@ -4,8 +4,9 @@ set +xtrap "cd $(pwd -P)" EXITcd "$(dirname $0)"+source "../utils.sh"-if [[ "$(uname)" == MINGW* || "$(uname)" == MSYS* ]]; then+if is_win; then/c/Windows/System32/cmd.exe "/c buildwin.bat"elseecho "ERROR: cannot upload on this platform!" 1>&2