Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

browser(firefox): use pre-downloaded toolchains for release builds (#10929)

Andrey Lushnikovcb79cd88a91e
diff --git a/browser_patches/firefox-beta/BUILD_NUMBER b/browser_patches/firefox-beta/BUILD_NUMBER
index dfb2bc3514..5d63b9cc79 100644
--- a/browser_patches/firefox-beta/BUILD_NUMBER
+++ b/browser_patches/firefox-beta/BUILD_NUMBER
@@ -1,2 +1,2 @@
-1310
-Changed: [email protected] Tue Dec 14 15:56:05 PST 2021
+1311
+Changed: [email protected] Tue Dec 14 23:27:53 PST 2021
diff --git a/browser_patches/firefox-beta/build.sh b/browser_patches/firefox-beta/build.sh
index 81278300db..3c75a2597c 100755
--- a/browser_patches/firefox-beta/build.sh
+++ b/browser_patches/firefox-beta/build.sh
@@ -63,6 +63,8 @@ echo "ac_add_options --disable-backgroundtasks" >> .mozconfig
if [[ -n $FF_DEBUG_BUILD ]]; then
echo "ac_add_options --enable-debug" >> .mozconfig
echo "ac_add_options --enable-debug-symbols" >> .mozconfig
+else
+ echo "ac_add_options --enable-release" >> .mozconfig
fi
if [[ "$(uname)" == MINGW* || "$(uname)" == "Darwin" ]]; then
@@ -86,7 +88,7 @@ if [[ $1 != "--juggler" ]]; then
fi
fi
-if [[ $1 == "--full" || $2 == "--full" ]]; then
+if [[ $1 == "--full" || $2 == "--full" || $1 == "--bootstrap" ]]; then
echo "ac_add_options --enable-bootstrap" >> .mozconfig
if [[ "$(uname)" == "Darwin" || "$(uname)" == "Linux" ]]; then
SHELL=/bin/sh ./mach --no-interactive bootstrap --application-choice=browser
@@ -99,13 +101,15 @@ fi
if [[ $1 == "--juggler" ]]; then
./mach build faster
+elif [[ $1 == "--bootstrap" ]]; then
+ ./mach configure
else
./mach build
+ if [[ "$(uname)" == "Darwin" ]]; then
+ node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist
+ else
+ node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist/bin
+ fi
fi
-if [[ "$(uname)" == "Darwin" ]]; then
- node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist
-else
- node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist/bin
-fi
diff --git a/browser_patches/firefox-beta/patches/bootstrap.diff b/browser_patches/firefox-beta/patches/bootstrap.diff
index 3600d59b08..a49063c819 100644
--- a/browser_patches/firefox-beta/patches/bootstrap.diff
+++ b/browser_patches/firefox-beta/patches/bootstrap.diff
@@ -1863,7 +1863,7 @@ index b32d426ba38045d14e6f1e79d17e8e6061e78227..df782034e79466fcc251e9a06e99d2e1
}
diff --git a/js/src/vm/DateTime.cpp b/js/src/vm/DateTime.cpp
-index e8f27fb69691aa6062c860a14ec94660fb9e5189..67715cbbc8257f11927564b45bbc8ee5384f809d 100644
+index e8f27fb69691aa6062c860a14ec94660fb9e5189..83cffc97f12072c24a7ea1bbd7b26ee37d856df3 100644
--- a/js/src/vm/DateTime.cpp
+++ b/js/src/vm/DateTime.cpp
@@ -170,6 +170,11 @@ void js::DateTimeInfo::internalResetTimeZone(ResetTimeZoneMode mode) {
@@ -1903,13 +1903,16 @@ index e8f27fb69691aa6062c860a14ec94660fb9e5189..67715cbbc8257f11927564b45bbc8ee5
#if JS_HAS_INTL_API
# if defined(XP_WIN)
static bool IsOlsonCompatibleWindowsTimeZoneId(std::string_view tz) {
-@@ -719,9 +738,14 @@ void js::ResyncICUDefaultTimeZone() {
+@@ -719,9 +738,17 @@ void js::ResyncICUDefaultTimeZone() {
void js::DateTimeInfo::internalResyncICUDefaultTimeZone() {
#if JS_HAS_INTL_API
+ if (!timeZoneOverride_.empty()) {
+ mozilla::Span<const char> tzid = mozilla::Span(timeZoneOverride_.data(), timeZoneOverride_.length());
-+ mozilla::intl::TimeZone::SetDefaultTimeZone(tzid);
++ auto result = mozilla::intl::TimeZone::SetDefaultTimeZone(tzid);
++ if (result.isErr()) {
++ fprintf(stderr, "ERROR: failed to setup default time zone\n");
++ }
+ return;
+ }
+
diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER
index 00db6f848a..4000f7197a 100644
--- a/browser_patches/firefox/BUILD_NUMBER
+++ b/browser_patches/firefox/BUILD_NUMBER
@@ -1,2 +1,2 @@
-1310
-Changed: [email protected] Mon 13 Dec 2021 07:00:27 PM PST
+1311
+Changed: [email protected] Tue Dec 14 23:26:10 PST 2021
diff --git a/browser_patches/firefox/build.sh b/browser_patches/firefox/build.sh
index d4e65dc653..5548e96b27 100755
--- a/browser_patches/firefox/build.sh
+++ b/browser_patches/firefox/build.sh
@@ -62,6 +62,9 @@ echo "ac_add_options --disable-backgroundtasks" >> .mozconfig
if [[ -n $FF_DEBUG_BUILD ]]; then
echo "ac_add_options --enable-debug" >> .mozconfig
+ echo "ac_add_options --enable-debug-symbols" >> .mozconfig
+else
+ echo "ac_add_options --enable-release" >> .mozconfig
fi
if [[ "$(uname)" == MINGW* || "$(uname)" == "Darwin" ]]; then
@@ -89,25 +92,7 @@ if [[ $1 == "--full" || $2 == "--full" ]]; then
if [[ "$(uname)" == "Darwin" || "$(uname)" == "Linux" ]]; then
SHELL=/bin/sh ./mach --no-interactive bootstrap --application-choice=browser
fi
- if [[ "$(uname)" == "Darwin" ]]; then
- HOMEBREW_LLVM="/opt/homebrew/opt/llvm/bin/clang";
- if [[ ! -f "${HOMEBREW_LLVM}" || $($HOMEBREW_LLVM --version) != *"version 13"* ]]; then
- echo "ERROR: as of Dec, 2021, building release firefox requires HomeBrew LLVM v13"
- echo "Please run:"
- echo
- echo " brew install llvm@13"
- echo
- exit 1
- fi
- echo "CC=${HOMEBREW_LLVM}" >> .mozconfig
- echo "CXX=${HOMEBREW_LLVM}++" >> .mozconfig
-
- # Download wasi toolchain if needed
- if [[ ! -d "$HOME/.mozbuild/sysroot-wasm32-wasi" ]]; then
- ./mach artifact toolchain --from-build toolchain-sysroot-wasm32-wasi
- mv ./sysroot-wasm32-wasi ~/.mozbuild/
- fi
- elif [[ "$(uname)" == "Linux" ]]; then
+ if [[ "$(uname)" == "Linux" ]]; then
echo "ac_add_options --enable-bootstrap" >> .mozconfig
fi
if [[ ! -z "${WIN32_REDIST_DIR}" ]]; then
@@ -116,6 +101,21 @@ if [[ $1 == "--full" || $2 == "--full" ]]; then
fi
fi
+if [[ "$(uname)" == "Darwin" ]]; then
+ if [[ ! -d "$HOME/.mozbuild/clang" ]]; then
+ echo "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)"
+ echo
+ echo "To bootstrap toolchains:"
+ echo " ./browser_patches/prepare_checkout.sh firefox-beta"
+ echo " ./browser_patches/build.sh firefox-beta --bootstrap"
+ echo
+ exit 1
+ fi
+ export MOZ_AUTOMATION=1
+ export MOZ_FETCHES_DIR=$HOME/.mozbuild
+fi
+
if ! [[ -f "$HOME/.mozbuild/_virtualenvs/mach/bin/python" ]]; then
./mach create-mach-environment
fi
diff --git a/browser_patches/firefox/patches/bootstrap.diff b/browser_patches/firefox/patches/bootstrap.diff
index 6cf9452cf9..14107eac52 100644
--- a/browser_patches/firefox/patches/bootstrap.diff
+++ b/browser_patches/firefox/patches/bootstrap.diff
@@ -1871,7 +1871,7 @@ index b32d426ba38045d14e6f1e79d17e8e6061e78227..df782034e79466fcc251e9a06e99d2e1
}
diff --git a/js/src/vm/DateTime.cpp b/js/src/vm/DateTime.cpp
-index e8f27fb69691aa6062c860a14ec94660fb9e5189..67715cbbc8257f11927564b45bbc8ee5384f809d 100644
+index e8f27fb69691aa6062c860a14ec94660fb9e5189..83cffc97f12072c24a7ea1bbd7b26ee37d856df3 100644
--- a/js/src/vm/DateTime.cpp
+++ b/js/src/vm/DateTime.cpp
@@ -170,6 +170,11 @@ void js::DateTimeInfo::internalResetTimeZone(ResetTimeZoneMode mode) {
@@ -1911,13 +1911,16 @@ index e8f27fb69691aa6062c860a14ec94660fb9e5189..67715cbbc8257f11927564b45bbc8ee5
#if JS_HAS_INTL_API
# if defined(XP_WIN)
static bool IsOlsonCompatibleWindowsTimeZoneId(std::string_view tz) {
-@@ -719,9 +738,14 @@ void js::ResyncICUDefaultTimeZone() {
+@@ -719,9 +738,17 @@ void js::ResyncICUDefaultTimeZone() {
void js::DateTimeInfo::internalResyncICUDefaultTimeZone() {
#if JS_HAS_INTL_API
+ if (!timeZoneOverride_.empty()) {
+ mozilla::Span<const char> tzid = mozilla::Span(timeZoneOverride_.data(), timeZoneOverride_.length());
-+ mozilla::intl::TimeZone::SetDefaultTimeZone(tzid);
++ auto result = mozilla::intl::TimeZone::SetDefaultTimeZone(tzid);
++ if (result.isErr()) {
++ fprintf(stderr, "ERROR: failed to setup default time zone\n");
++ }
+ return;
+ }
+
@@ -2559,7 +2562,7 @@ diff --git a/widget/cocoa/NativeKeyBindings.mm b/widget/cocoa/NativeKeyBindings.
index 2b11df66d9445080d4d8a19a915b3e00285c5d32..caef1b65bbcff899f45c3e3cddfe76e88479ec30 100644
--- a/widget/cocoa/NativeKeyBindings.mm
+++ b/widget/cocoa/NativeKeyBindings.mm
-@@ -491,6 +491,13 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType,
+@@ -491,6 +491,13 @@
break;
case KEY_NAME_INDEX_ArrowLeft:
if (aEvent.IsAlt()) {
@@ -2573,7 +2576,7 @@ index 2b11df66d9445080d4d8a19a915b3e00285c5d32..caef1b65bbcff899f45c3e3cddfe76e8
break;
}
if (aEvent.IsMeta() || (aEvent.IsControl() && aEvent.IsShift())) {
-@@ -511,6 +518,13 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType,
+@@ -511,6 +518,13 @@
break;
case KEY_NAME_INDEX_ArrowRight:
if (aEvent.IsAlt()) {
@@ -2587,7 +2590,7 @@ index 2b11df66d9445080d4d8a19a915b3e00285c5d32..caef1b65bbcff899f45c3e3cddfe76e8
break;
}
if (aEvent.IsMeta() || (aEvent.IsControl() && aEvent.IsShift())) {
-@@ -531,6 +545,10 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType,
+@@ -531,6 +545,10 @@
break;
case KEY_NAME_INDEX_ArrowUp:
if (aEvent.IsControl()) {
@@ -2598,7 +2601,7 @@ index 2b11df66d9445080d4d8a19a915b3e00285c5d32..caef1b65bbcff899f45c3e3cddfe76e8
break;
}
if (aEvent.IsMeta()) {
-@@ -540,7 +558,7 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType,
+@@ -540,7 +558,7 @@
instance->AppendEditCommandsForSelector(
!aEvent.IsShift()
? ToObjcSelectorPtr(@selector(moveToBeginningOfDocument:))
@@ -2607,7 +2610,7 @@ index 2b11df66d9445080d4d8a19a915b3e00285c5d32..caef1b65bbcff899f45c3e3cddfe76e8
aCommands);
break;
}
-@@ -563,6 +581,10 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType,
+@@ -563,6 +581,10 @@
break;
case KEY_NAME_INDEX_ArrowDown:
if (aEvent.IsControl()) {