From cb159d2fffc7c5518b2c85d245a397285e1da53f Mon Sep 17 00:00:00 2001 From: Pier Angelo Vendrame Date: Tue, 29 Apr 2025 16:34:21 +0200 Subject: [PATCH 001/250] Bug 1963354 - Refine the GTK version checked before declaring various GDK_WINDOW_STATE... constants. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D247104 --- widget/gtk/nsWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 3f4e439d9528..68b442b1ff8f 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -142,7 +142,7 @@ using mozilla::gl::GLContextGLX; // out to the bounding-box if there are more #define MAX_RECTS_IN_REGION 100 -#if !GTK_CHECK_VERSION(3, 22, 0) +#if !GTK_CHECK_VERSION(3, 22, 23) constexpr gint GDK_WINDOW_STATE_TOP_TILED = 1 << 9; constexpr gint GDK_WINDOW_STATE_TOP_RESIZABLE = 1 << 10; -- GitLab From 379c900dc42e1050458c60a3ff1b3a81f5957d46 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Mon, 3 Mar 2025 18:59:09 -0800 Subject: [PATCH 002/250] BB 43544: DoH pane undefined error in Privacy and Security From: Sarah Jamie Lewis Date: Fri, 28 Feb 2025 09:30:45 -0800 Subject: [PATCH 1/1] DoH Settings: Check for nulll gParentalControlsService When the parental controls service is disabled in a build, the DoH settings now display the correct stauts when Increased or Max Protection is enabled. Previously, selecting either of these options would cause DoH to be enabled, but the "Status" and "Provider" fields would not be properly populated, due to a check on the gParentalControlsService causing an error. This check is now identical to the same check in DownloadIntegration.sys.mjs Apply 1 suggestion(s) to 1 file(s) Co-authored-by: ma1 --- browser/components/preferences/privacy.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/browser/components/preferences/privacy.js b/browser/components/preferences/privacy.js index 6b4ec7ab4e68..d01e69d03ea4 100644 --- a/browser/components/preferences/privacy.js +++ b/browser/components/preferences/privacy.js @@ -54,11 +54,12 @@ ChromeUtils.defineLazyGetter(lazy, "AboutLoginsL10n", () => { return new Localization(["branding/brand.ftl", "browser/aboutLogins.ftl"]); }); -XPCOMUtils.defineLazyServiceGetter( - lazy, - "gParentalControlsService", - "@mozilla.org/parental-controls-service;1", - "nsIParentalControlsService" +ChromeUtils.defineLazyGetter(lazy, "gParentalControlsService", () => + "@mozilla.org/parental-controls-service;1" in Cc + ? Cc["@mozilla.org/parental-controls-service;1"].createInstance( + Ci.nsIParentalControlsService + ) + : null ); XPCOMUtils.defineLazyPreferenceGetter( @@ -709,7 +710,7 @@ var gPrivacyPane = { mode == Ci.nsIDNSService.MODE_TRRFIRST || mode == Ci.nsIDNSService.MODE_TRRONLY ) { - if (lazy.gParentalControlsService.parentalControlsEnabled) { + if (lazy.gParentalControlsService?.parentalControlsEnabled) { return "preferences-doh-status-not-active"; } let confirmationState = Services.dns.currentTrrConfirmationState; @@ -732,7 +733,7 @@ var gPrivacyPane = { if ( (mode == Ci.nsIDNSService.MODE_TRRFIRST || mode == Ci.nsIDNSService.MODE_TRRONLY) && - lazy.gParentalControlsService.parentalControlsEnabled + lazy.gParentalControlsService?.parentalControlsEnabled ) { errReason = Services.dns.getTRRSkipReasonName( Ci.nsITRRSkipReason.TRR_PARENTAL_CONTROL -- GitLab From 780d21324df7f6768dba5dd31dbd9f5a5c63ef60 Mon Sep 17 00:00:00 2001 From: Henry Wilkes Date: Tue, 15 Nov 2022 11:48:04 +0000 Subject: [PATCH 003/250] BB 41454: Move focus after calling openPreferences for a sub-category. Temporary fix until mozilla bug 1799153 gets a patch upstream. --- browser/components/preferences/preferences.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/browser/components/preferences/preferences.js b/browser/components/preferences/preferences.js index 6386773b287c..89999cee4a0c 100644 --- a/browser/components/preferences/preferences.js +++ b/browser/components/preferences/preferences.js @@ -447,6 +447,26 @@ function scrollAndHighlight(subcategory) { } let header = getClosestDisplayedHeader(element); + // We assign a tabindex=-1 to the element so that we can focus it. This allows + // us to move screen reader's focus to an arbitrary position on the page. + // See tor-browser#41454 and mozilla bug 1799153. + const doFocus = () => { + element.setAttribute("tabindex", "-1"); + Services.focus.setFocus(element, Services.focus.FLAG_NOSCROLL); + // Immediately remove again now that it has focus. + element.removeAttribute("tabindex"); + }; + // The element is not always immediately focusable, so we wait until document + // load. + if (document.readyState === "complete") { + doFocus(); + } else { + // Wait until document load to move focus. + // NOTE: This should be called after DOMContentLoaded, where the searchInput + // is focused. + window.addEventListener("load", doFocus, { once: true }); + } + header.scrollIntoView({ behavior: "smooth", block: "center", -- GitLab From ebb5e25bd073b7f741c62d3e7634543e90f77140 Mon Sep 17 00:00:00 2001 From: Henry Wilkes Date: Thu, 12 Sep 2024 09:53:22 +0100 Subject: [PATCH 004/250] BB 43072: Add aria label and description to moz-message-bar. Ensures that moz-message-bar, including notifications, are announced on Orca. This addresses upstream bugzilla bug 1895857 and should likely be replaced when it is fixed. --- .../moz-message-bar/moz-message-bar.mjs | 31 ++++++++++++++----- toolkit/content/widgets/notificationbox.js | 11 ------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/toolkit/content/widgets/moz-message-bar/moz-message-bar.mjs b/toolkit/content/widgets/moz-message-bar/moz-message-bar.mjs index 069e11fc5278..926abbbb6f81 100644 --- a/toolkit/content/widgets/moz-message-bar/moz-message-bar.mjs +++ b/toolkit/content/widgets/moz-message-bar/moz-message-bar.mjs @@ -65,12 +65,14 @@ export default class MozMessageBar extends MozLitElement { dismissable: { type: Boolean }, messageL10nId: { type: String }, messageL10nArgs: { type: String }, + useAlertRole: { type: Boolean }, }; constructor() { super(); this.type = "info"; this.dismissable = false; + this.useAlertRole = true; } onActionSlotchange() { @@ -85,11 +87,6 @@ export default class MozMessageBar extends MozLitElement { ); } - connectedCallback() { - super.connectedCallback(); - this.setAttribute("role", "alert"); - } - disconnectedCallback() { super.disconnectedCallback(); this.dispatchEvent(new CustomEvent("message-bar:close")); @@ -99,6 +96,17 @@ export default class MozMessageBar extends MozLitElement { return this.supportLinkSlot.assignedElements(); } + setAlertRole() { + // Wait a little for this to render before setting the role for more + // consistent alerts to screen readers. + this.useAlertRole = false; + window.requestAnimationFrame(() => { + window.requestAnimationFrame(() => { + this.useAlertRole = true; + }); + }); + } + iconTemplate() { let iconData = messageTypeToIconData[this.type]; if (iconData) { @@ -119,7 +127,9 @@ export default class MozMessageBar extends MozLitElement { headingTemplate() { if (this.heading) { - return html`${this.heading}`; + return html` + ${this.heading} + `; } return ""; } @@ -145,13 +155,18 @@ export default class MozMessageBar extends MozLitElement { rel="stylesheet" href="chrome://global/content/elements/moz-message-bar.css" /> -
+
${this.iconTemplate()}
${this.headingTemplate()} -
+
{ - window.requestAnimationFrame(() => { - this.setAttribute("role", "alert"); - }); - }); - } - handleEvent(e) { // If clickjacking delay is active, prevent any "click"/"command" from // going through. Also restart the delay if the user tries to click too early. -- GitLab From d9221d620da1a130d1001a3047148dfbf152c934 Mon Sep 17 00:00:00 2001 From: Henry Wilkes Date: Mon, 7 Oct 2024 10:46:23 +0100 Subject: [PATCH 005/250] BB 42739: Use the brand name for profile error messages. Some messages in profileSelection.properties use gAppData->name as variable inputs. However, gAppData->name is still "Firefox" for our base-browser builds, rather than the user-facing browser name. We swap these instances with the displayed brand name instead. --- toolkit/xre/ProfileReset.cpp | 17 +++++++++++++---- toolkit/xre/nsAppRunner.cpp | 27 +++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/toolkit/xre/ProfileReset.cpp b/toolkit/xre/ProfileReset.cpp index 8ed01e6535e2..c8c1e69645dd 100644 --- a/toolkit/xre/ProfileReset.cpp +++ b/toolkit/xre/ProfileReset.cpp @@ -23,8 +23,8 @@ using namespace mozilla; -extern const XREAppData* gAppData; - +static const char kBrandProperties[] = + "chrome://branding/locale/brand.properties"; static const char kProfileProperties[] = "chrome://mozapps/locale/profile/profileSelection.properties"; @@ -49,12 +49,21 @@ nsresult ProfileResetCleanup(nsToolkitProfileService* aService, mozilla::components::StringBundle::Service(); if (!sbs) return NS_ERROR_FAILURE; + nsCOMPtr brandBundle; + Unused << sbs->CreateBundle(kBrandProperties, getter_AddRefs(brandBundle)); + if (!brandBundle) return NS_ERROR_FAILURE; + nsCOMPtr sb; Unused << sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb)); if (!sb) return NS_ERROR_FAILURE; - NS_ConvertUTF8toUTF16 appName(gAppData->name); - AutoTArray params = {appName, appName}; + nsAutoString appName; + rv = brandBundle->GetStringFromName("brandShortName", appName); + if (NS_FAILED(rv)) return rv; + + AutoTArray params; + params.AppendElement(appName); + params.AppendElement(appName); nsAutoString resetBackupDirectoryName; diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 35811056c34e..8fa70cacc475 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -2644,6 +2644,8 @@ nsresult LaunchChild(bool aBlankCommandLine, bool aTryExec) { return NS_ERROR_LAUNCHED_CHILD_PROCESS; } +static const char kBrandProperties[] = + "chrome://branding/locale/brand.properties"; static const char kProfileProperties[] = "chrome://mozapps/locale/profile/profileSelection.properties"; @@ -2717,12 +2719,20 @@ static nsresult ProfileMissingDialog(nsINativeAppSupport* aNative) { mozilla::components::StringBundle::Service(); NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE); + nsCOMPtr brandBundle; + sbs->CreateBundle(kBrandProperties, getter_AddRefs(brandBundle)); + NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE); nsCOMPtr sb; sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb)); NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE); - NS_ConvertUTF8toUTF16 appName(gAppData->name); - AutoTArray params = {appName, appName}; + nsAutoString appName; + rv = brandBundle->GetStringFromName("brandShortName", appName); + NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT); + + AutoTArray params; + params.AppendElement(appName); + params.AppendElement(appName); // profileMissing nsAutoString missingMessage; @@ -2786,12 +2796,21 @@ static ReturnAbortOnError ProfileLockedDialog(nsIFile* aProfileDir, mozilla::components::StringBundle::Service(); NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE); + nsCOMPtr brandBundle; + sbs->CreateBundle(kBrandProperties, getter_AddRefs(brandBundle)); + NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE); nsCOMPtr sb; sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb)); NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE); - NS_ConvertUTF8toUTF16 appName(gAppData->name); - AutoTArray params = {appName, appName, appName}; + nsAutoString appName; + rv = brandBundle->GetStringFromName("brandShortName", appName); + NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT); + + AutoTArray params; + params.AppendElement(appName); + params.AppendElement(appName); + params.AppendElement(appName); nsAutoString killMessage; #ifndef XP_MACOSX -- GitLab From be26eb69d36cc28f076a1dad636fa4fc69693f5c Mon Sep 17 00:00:00 2001 From: hackademix Date: Tue, 7 Nov 2023 12:55:15 +0100 Subject: [PATCH 006/250] BB 42194: Fix blank net error page on failed DNS resolution with active proxy. --- toolkit/actors/NetErrorChild.sys.mjs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/toolkit/actors/NetErrorChild.sys.mjs b/toolkit/actors/NetErrorChild.sys.mjs index 8b9890fd2d1b..6244f325fd4e 100644 --- a/toolkit/actors/NetErrorChild.sys.mjs +++ b/toolkit/actors/NetErrorChild.sys.mjs @@ -133,12 +133,15 @@ export class NetErrorChild extends RemotePageChild { shortDesc.appendChild(span); }, }; - - Services.uriFixup.checkHost( - info.fixedURI, - onLookupCompleteListener, - this.document.nodePrincipal.originAttributes - ); + try { + Services.uriFixup.checkHost( + info.fixedURI, + onLookupCompleteListener, + this.document.nodePrincipal.originAttributes + ); + } catch (e) { + // DNS resolution may fail synchronously if forbidden by proxy + } } // Get the header from the http response of the failed channel. This function -- GitLab From 6f30b4d785ae6acfaaaa7566bb276a2fbb0a9d48 Mon Sep 17 00:00:00 2001 From: Henry Wilkes Date: Tue, 6 Dec 2022 11:10:08 +0000 Subject: [PATCH 007/250] BB 41483: Remove the firefox override for appstrings.properties Remove this patch after upstream bugzilla bug 1790187 --- browser/base/jar.mn | 3 -- .../chrome/overrides/appstrings.properties | 50 ------------------- browser/locales/jar.mn | 2 - 3 files changed, 55 deletions(-) delete mode 100644 browser/locales/en-US/chrome/overrides/appstrings.properties diff --git a/browser/base/jar.mn b/browser/base/jar.mn index 4401c78d3400..9e6003316c28 100644 --- a/browser/base/jar.mn +++ b/browser/base/jar.mn @@ -102,6 +102,3 @@ browser.jar: content/browser/spotlight.html (content/spotlight.html) content/browser/spotlight.js (content/spotlight.js) * content/browser/default-bookmarks.html (content/default-bookmarks.html) - -# L10n resources and overrides. -% override chrome://global/locale/appstrings.properties chrome://browser/locale/appstrings.properties diff --git a/browser/locales/en-US/chrome/overrides/appstrings.properties b/browser/locales/en-US/chrome/overrides/appstrings.properties deleted file mode 100644 index c7d3c0e88c07..000000000000 --- a/browser/locales/en-US/chrome/overrides/appstrings.properties +++ /dev/null @@ -1,50 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -malformedURI2=Please check that the URL is correct and try again. -fileNotFound=Firefox can’t find the file at %S. -fileAccessDenied=The file at %S is not readable. -# %S is replaced by the uri host -httpErrorPage=%S sent back an error. -serverError=%S might have a temporary problem or it could have moved. -dnsNotFound2=We can’t connect to the server at %S. -basicHttpAuthDisabled=Someone pretending to be the site could try to steal things like your username, password, or email. -unknownProtocolFound=Firefox doesn’t know how to open this address, because one of the following protocols (%S) isn’t associated with any program or is not allowed in this context. -connectionFailure=Firefox can’t establish a connection to the server at %S. -netInterrupt=The connection to %S was interrupted while the page was loading. -netTimeout=The server at %S is taking too long to respond. -redirectLoop=Firefox has detected that the server is redirecting the request for this address in a way that will never complete. -## LOCALIZATION NOTE (confirmRepostPrompt): In this item, don’t translate "%S" -confirmRepostPrompt=To display this page, %S must send information that will repeat any action (such as a search or order confirmation) that was performed earlier. -resendButton.label=Resend -unknownSocketType=Firefox doesn’t know how to communicate with the server. -netReset=The connection to the server was reset while the page was loading. -notCached=This document is no longer available. -netOffline=Firefox is currently in offline mode and can’t browse the Web. -isprinting=The document cannot change while Printing or in Print Preview. -deniedPortAccess=This address uses a network port which is normally used for purposes other than Web browsing. Firefox has canceled the request for your protection. -proxyResolveFailure=Firefox is configured to use a proxy server that can’t be found. -proxyConnectFailure=Firefox is configured to use a proxy server that is refusing connections. -contentEncodingError=The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression. -unsafeContentType=The page you are trying to view cannot be shown because it is contained in a file type that may not be safe to open. Please contact the website owners to inform them of this problem. -externalProtocolTitle=External Protocol Request -externalProtocolPrompt=An external application must be launched to handle %1$S: links.\n\n\nRequested link:\n\n%2$S\n\nApplication: %3$S\n\n\nIf you were not expecting this request it may be an attempt to exploit a weakness in that other program. Cancel this request unless you are sure it is not malicious.\n -#LOCALIZATION NOTE (externalProtocolUnknown): The following string is shown if the application name can't be determined -externalProtocolUnknown= -externalProtocolChkMsg=Remember my choice for all links of this type. -externalProtocolLaunchBtn=Launch application -malwareBlocked=The site at %S has been reported as an attack site and has been blocked based on your security preferences. -harmfulBlocked=The site at %S has been reported as a potentially harmful site and has been blocked based on your security preferences. -unwantedBlocked=The site at %S has been reported as serving unwanted software and has been blocked based on your security preferences. -deceptiveBlocked=This web page at %S has been reported as a deceptive site and has been blocked based on your security preferences. -cspBlocked=This page has a content security policy that prevents it from being loaded in this way. -xfoBlocked=This page has an X-Frame-Options policy that prevents it from being loaded in this context. -corruptedContentErrorv2=The site at %S has experienced a network protocol violation that cannot be repaired. -## LOCALIZATION NOTE (sslv3Used) - Do not translate "%S". -sslv3Used=Firefox cannot guarantee the safety of your data on %S because it uses SSLv3, a broken security protocol. -inadequateSecurityError=The website tried to negotiate an inadequate level of security. -blockedByPolicy=Your organization has blocked access to this page or website. -blockedByCORP=Firefox didn’t load this page because it looks like the security configuration doesn’t match the previous page. -invalidHeaderValue=%S sent back a header with empty characters not allowed by web security standards. -networkProtocolError=Firefox has experienced a network protocol violation that cannot be repaired. diff --git a/browser/locales/jar.mn b/browser/locales/jar.mn index b97d6a5ea46d..ff20409266eb 100644 --- a/browser/locales/jar.mn +++ b/browser/locales/jar.mn @@ -36,5 +36,3 @@ locale/browser/safebrowsing/safebrowsing.properties (%chrome/browser/safebrowsing/safebrowsing.properties) locale/browser/feeds/subscribe.properties (%chrome/browser/feeds/subscribe.properties) % locale browser-region @AB_CD@ %locale/browser-region/ -# the following files are browser-specific overrides - locale/browser/appstrings.properties (%chrome/overrides/appstrings.properties) -- GitLab From 00f740177b96257533f9220ebae57688d18109bc Mon Sep 17 00:00:00 2001 From: Marco Simonelli Date: Fri, 10 Mar 2023 11:55:36 +0000 Subject: [PATCH 008/250] BB 41459: WebRTC fails to build under mingw (Part 1) - properly define NOMINMAX for just MSVC builds --- build/moz.configure/windows.configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/moz.configure/windows.configure b/build/moz.configure/windows.configure index da10662efff7..293a08cc818a 100644 --- a/build/moz.configure/windows.configure +++ b/build/moz.configure/windows.configure @@ -624,11 +624,11 @@ with only_when(depends(c_compiler)(lambda c: c.type == "clang-cl")): add_linker_flag("-LARGEADDRESSAWARE") add_linker_flag("-SAFESEH") + # avoid conficts with std::min/max + set_define("NOMINMAX", True) -set_define("WIN32_LEAN_AND_MEAN", True) -# See http://support.microsoft.com/kb/143208 to use STL -set_define("NOMINMAX", True) +set_define("WIN32_LEAN_AND_MEAN", True) with only_when(target_is_windows & depends(c_compiler)(lambda c: c.type != "clang-cl")): -- GitLab From e686e2dd1cd1acde49be87e7377463fbf64473c6 Mon Sep 17 00:00:00 2001 From: Marco Simonelli Date: Fri, 10 Mar 2023 11:50:33 +0000 Subject: [PATCH 009/250] BB 41459: WebRTC fails to build under mingw (Part 2) - fixes required to build third_party/libwebrtc --- .../isac/main/source/os_specific_inline.h | 2 +- .../desktop_capture/desktop_capture_types.h | 10 ++++++---- .../win/desktop_capture_utils.cc | 19 +++++++++++++------ .../video_capture/windows/device_info_ds.h | 2 +- .../rtc_base/platform_thread_types.cc | 3 +++ third_party/libwebrtc/rtc_base/socket.h | 14 ++++++++++++++ .../libwebrtc/rtc_base/system/file_wrapper.cc | 2 +- .../rtc_base/win/create_direct3d_device.h | 14 ++++++++++++-- 8 files changed, 51 insertions(+), 15 deletions(-) diff --git a/third_party/libwebrtc/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h b/third_party/libwebrtc/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h index fe9afa4ba295..5510660083a3 100644 --- a/third_party/libwebrtc/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h +++ b/third_party/libwebrtc/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h @@ -15,7 +15,7 @@ #include "rtc_base/system/arch.h" -#if defined(WEBRTC_POSIX) +#if (defined(WEBRTC_POSIX) || defined(__MINGW32__)) #define WebRtcIsac_lrint lrint #elif (defined(WEBRTC_ARCH_X86) && defined(WIN32)) static __inline long int WebRtcIsac_lrint(double x_dbl) { diff --git a/third_party/libwebrtc/modules/desktop_capture/desktop_capture_types.h b/third_party/libwebrtc/modules/desktop_capture/desktop_capture_types.h index e777a45f92a0..eaa1385c2bbc 100644 --- a/third_party/libwebrtc/modules/desktop_capture/desktop_capture_types.h +++ b/third_party/libwebrtc/modules/desktop_capture/desktop_capture_types.h @@ -11,12 +11,14 @@ #ifndef MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_TYPES_H_ #define MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_TYPES_H_ +// pid_t +#if !defined(XP_WIN) || defined(__MINGW32__) +#include +#else +typedef int pid_t; +#endif #include -#ifdef XP_WIN // Moving this into the global namespace -typedef int pid_t; // matching what used to be in -#endif // video_capture_defines.h - namespace webrtc { enum class CaptureType { kWindow, kScreen, kAnyScreenContent }; diff --git a/third_party/libwebrtc/modules/desktop_capture/win/desktop_capture_utils.cc b/third_party/libwebrtc/modules/desktop_capture/win/desktop_capture_utils.cc index 476ddc4abace..bc429774c123 100644 --- a/third_party/libwebrtc/modules/desktop_capture/win/desktop_capture_utils.cc +++ b/third_party/libwebrtc/modules/desktop_capture/win/desktop_capture_utils.cc @@ -10,7 +10,9 @@ #include "modules/desktop_capture/win/desktop_capture_utils.h" -#include "rtc_base/strings/string_builder.h" +#include +#include +#include "stringapiset.h" namespace webrtc { namespace desktop_capture { @@ -20,11 +22,16 @@ namespace utils { std::string ComErrorToString(const _com_error& error) { char buffer[1024]; rtc::SimpleStringBuilder string_builder(buffer); - // Use _bstr_t to simplify the wchar to char conversion for ErrorMessage(). - _bstr_t error_message(error.ErrorMessage()); - string_builder.AppendFormat("HRESULT: 0x%08X, Message: %s", error.Error(), - static_cast(error_message)); - return string_builder.str(); + string_builder.AppendFormat("HRESULT: 0x%08X, Message: ", error.Error()); +#ifdef _UNICODE + WideCharToMultiByte(CP_UTF8, 0, error.ErrorMessage(), -1, + buffer + string_builder.size(), + sizeof(buffer) - string_builder.size(), nullptr, nullptr); + buffer[sizeof(buffer) - 1] = 0; +#else + string_builder << error.ErrorMessage(); +#endif + return buffer; } } // namespace utils diff --git a/third_party/libwebrtc/modules/video_capture/windows/device_info_ds.h b/third_party/libwebrtc/modules/video_capture/windows/device_info_ds.h index a9a1449b9974..72e9c764c39a 100644 --- a/third_party/libwebrtc/modules/video_capture/windows/device_info_ds.h +++ b/third_party/libwebrtc/modules/video_capture/windows/device_info_ds.h @@ -12,7 +12,7 @@ #define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_DEVICE_INFO_DS_H_ #include -#include +#include #include #include "modules/video_capture/device_info_impl.h" diff --git a/third_party/libwebrtc/rtc_base/platform_thread_types.cc b/third_party/libwebrtc/rtc_base/platform_thread_types.cc index c3c6955a7b27..0c8d77134ae8 100644 --- a/third_party/libwebrtc/rtc_base/platform_thread_types.cc +++ b/third_party/libwebrtc/rtc_base/platform_thread_types.cc @@ -95,6 +95,8 @@ void SetCurrentThreadName(const char* name) { set_thread_description_func(::GetCurrentThread(), wide_thread_name); } +#if defined(_MSC_VER) + // SEH is only impelmented for the MSVC compiler // For details see: // https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code #pragma pack(push, 8) @@ -114,6 +116,7 @@ void SetCurrentThreadName(const char* name) { } __except (EXCEPTION_EXECUTE_HANDLER) { // NOLINT } #pragma warning(pop) +#endif // _MSC_VER #elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID) prctl(PR_SET_NAME, reinterpret_cast(name)); // NOLINT #elif defined(WEBRTC_MAC) || defined(WEBRTC_IOS) diff --git a/third_party/libwebrtc/rtc_base/socket.h b/third_party/libwebrtc/rtc_base/socket.h index 4b9a1699df63..79c01121e734 100644 --- a/third_party/libwebrtc/rtc_base/socket.h +++ b/third_party/libwebrtc/rtc_base/socket.h @@ -66,6 +66,20 @@ #define EHOSTUNREACH WSAEHOSTUNREACH #undef ENETUNREACH #define ENETUNREACH WSAENETUNREACH +#undef ENOTEMPTY +#define ENOTEMPTY WSAENOTEMPTY +#undef EPROCLIM +#define EPROCLIM WSAEPROCLIM +#undef EUSERS +#define EUSERS WSAEUSERS +#undef EDQUOT +#define EDQUOT WSAEDQUOT +#undef ESTALE +#define ESTALE WSAESTALE +#undef EREMOTE +#define EREMOTE WSAEREMOTE +#undef EACCES +#define EACCES WSAEACCES #define SOCKET_EACCES WSAEACCES #endif // WEBRTC_WIN diff --git a/third_party/libwebrtc/rtc_base/system/file_wrapper.cc b/third_party/libwebrtc/rtc_base/system/file_wrapper.cc index 12c27a5a00b1..3203bc694b47 100644 --- a/third_party/libwebrtc/rtc_base/system/file_wrapper.cc +++ b/third_party/libwebrtc/rtc_base/system/file_wrapper.cc @@ -22,7 +22,7 @@ #include "rtc_base/numerics/safe_conversions.h" #ifdef _WIN32 -#include +#include #else #endif diff --git a/third_party/libwebrtc/rtc_base/win/create_direct3d_device.h b/third_party/libwebrtc/rtc_base/win/create_direct3d_device.h index 7c21f8720a43..e1991b3efb96 100644 --- a/third_party/libwebrtc/rtc_base/win/create_direct3d_device.h +++ b/third_party/libwebrtc/rtc_base/win/create_direct3d_device.h @@ -11,8 +11,18 @@ #ifndef RTC_BASE_WIN_CREATE_DIRECT3D_DEVICE_H_ #define RTC_BASE_WIN_CREATE_DIRECT3D_DEVICE_H_ -#include -#include +#include +#ifndef __MINGW32__ +# include +#else +# include +# include +extern "C" { +// This function is only used in decltype(..) +HRESULT __stdcall CreateDirect3D11DeviceFromDXGIDevice( + ::IDXGIDevice* dxgiDevice, ::IInspectable** graphicsDevice); +} +#endif #include #include -- GitLab From 89b9947758c88ce68ced2bcf9c7a08347b781d1f Mon Sep 17 00:00:00 2001 From: Marco Simonelli Date: Fri, 10 Mar 2023 11:51:15 +0000 Subject: [PATCH 010/250] BB 41459: WebRTC fails to build under mingw (Part 3) - fixes required to build third_party/sipcc --- third_party/sipcc/cpr_win_types.h | 13 ++++++++++--- third_party/sipcc/sdp_token.c | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/third_party/sipcc/cpr_win_types.h b/third_party/sipcc/cpr_win_types.h index c4dfa0b72a49..106e551728b9 100644 --- a/third_party/sipcc/cpr_win_types.h +++ b/third_party/sipcc/cpr_win_types.h @@ -40,15 +40,22 @@ typedef uint8_t boolean; * NOTE: size_t should already be declared by both the MinGW and Microsoft * SDKs. */ -#ifndef _SSIZE_T_ + +#if defined(_MSC_VER) && !defined(_SSIZE_T_) #define _SSIZE_T_ -typedef int ssize_t; +#if !defined(_WIN64) +typedef int32_t ssize_t; +#else +typedef int64_t ssize_t; +#endif #endif /* - * Define pid_t. + * Define pid_t for MSVC builds */ +#if defined(_WIN32) && defined (_MSC_VER) typedef int pid_t; +#endif /* * Define min/max diff --git a/third_party/sipcc/sdp_token.c b/third_party/sipcc/sdp_token.c index b570d8169009..70f2a19138ea 100644 --- a/third_party/sipcc/sdp_token.c +++ b/third_party/sipcc/sdp_token.c @@ -4,6 +4,10 @@ #include +#if defined(SIP_OS_WINDOWS) && !defined(_MSC_VER) +#include +#endif + #include "sdp_os_defs.h" #include "sipcc_sdp.h" #include "sdp_private.h" -- GitLab From 7e1d1fb23e1795bf65ab13a8b2b1b155c39fb4e6 Mon Sep 17 00:00:00 2001 From: Marco Simonelli Date: Fri, 10 Mar 2023 11:59:37 +0000 Subject: [PATCH 011/250] BB 41459: WebRTC fails to build under mingw (Part 4) - fixes requried to build netwerk/sctp --- netwerk/sctp/src/moz.build | 2 ++ netwerk/sctp/src/netinet/sctp_cc_functions.c | 4 ++++ netwerk/sctp/src/netinet/sctp_indata.c | 5 +++++ netwerk/sctp/src/netinet/sctp_input.c | 4 ++++ netwerk/sctp/src/netinet/sctp_output.c | 5 +++++ netwerk/sctp/src/netinet/sctp_usrreq.c | 4 ++++ netwerk/sctp/src/netinet/sctputil.c | 4 ++++ netwerk/sctp/src/user_mbuf.c | 4 ++++ netwerk/sctp/src/user_socket.c | 5 ++++- 9 files changed, 36 insertions(+), 1 deletion(-) diff --git a/netwerk/sctp/src/moz.build b/netwerk/sctp/src/moz.build index 94555e683602..8a475415e864 100644 --- a/netwerk/sctp/src/moz.build +++ b/netwerk/sctp/src/moz.build @@ -62,3 +62,5 @@ if CONFIG['OS_TARGET'] in ('Linux', 'Android'): DEFINES['_GNU_SOURCE'] = 1 elif CONFIG['OS_TARGET'] == 'Darwin': DEFINES['__APPLE_USE_RFC_2292'] = 1 +elif CONFIG['OS_TARGET'] == 'WINNT': + DEFINES['_CRT_RAND_S'] = True diff --git a/netwerk/sctp/src/netinet/sctp_cc_functions.c b/netwerk/sctp/src/netinet/sctp_cc_functions.c index 176338a05e71..77193d8f9de6 100644 --- a/netwerk/sctp/src/netinet/sctp_cc_functions.c +++ b/netwerk/sctp/src/netinet/sctp_cc_functions.c @@ -49,6 +49,10 @@ #include #endif +#if defined(_WIN32) && defined(__MINGW32__) +#include +#endif + #define SHIFT_MPTCP_MULTI_N 40 #define SHIFT_MPTCP_MULTI_Z 16 #define SHIFT_MPTCP_MULTI 8 diff --git a/netwerk/sctp/src/netinet/sctp_indata.c b/netwerk/sctp/src/netinet/sctp_indata.c index 115ec1d763e2..8ecb971e8a46 100644 --- a/netwerk/sctp/src/netinet/sctp_indata.c +++ b/netwerk/sctp/src/netinet/sctp_indata.c @@ -53,6 +53,11 @@ #if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif + +#if defined(_WIN32) && !defined(_MSC_VER) +#include +#endif + /* * NOTES: On the outbound side of things I need to check the sack timer to * see if I should generate a sack into the chunk queue (if I have data to diff --git a/netwerk/sctp/src/netinet/sctp_input.c b/netwerk/sctp/src/netinet/sctp_input.c index a3c1476f5b39..29ee1a8f3be3 100644 --- a/netwerk/sctp/src/netinet/sctp_input.c +++ b/netwerk/sctp/src/netinet/sctp_input.c @@ -58,6 +58,10 @@ #include #endif +#if defined(_WIN32) && !defined(_MSC_VER) +#include +#endif + static void sctp_stop_all_cookie_timers(struct sctp_tcb *stcb) { diff --git a/netwerk/sctp/src/netinet/sctp_output.c b/netwerk/sctp/src/netinet/sctp_output.c index 33a6e169d84e..294568080c28 100644 --- a/netwerk/sctp/src/netinet/sctp_output.c +++ b/netwerk/sctp/src/netinet/sctp_output.c @@ -74,6 +74,11 @@ #if defined(__Userspace__) && defined(INET6) #include #endif + +#if defined(_WIN32) && !defined(_MSC_VER) +#include +#endif + #if defined(__APPLE__) && !defined(__Userspace__) #if !(defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD)) #define SCTP_MAX_LINKHDR 16 diff --git a/netwerk/sctp/src/netinet/sctp_usrreq.c b/netwerk/sctp/src/netinet/sctp_usrreq.c index 53aeaa1d4510..f3d20b0e66f8 100644 --- a/netwerk/sctp/src/netinet/sctp_usrreq.c +++ b/netwerk/sctp/src/netinet/sctp_usrreq.c @@ -63,6 +63,10 @@ #include #endif /* HAVE_SCTP_PEELOFF_SOCKOPT */ +#if defined(_WIN32) && !defined(_MSC_VER) +#include +#endif + extern const struct sctp_cc_functions sctp_cc_functions[]; extern const struct sctp_ss_functions sctp_ss_functions[]; diff --git a/netwerk/sctp/src/netinet/sctputil.c b/netwerk/sctp/src/netinet/sctputil.c index bd414141d23e..4a819b9bf737 100644 --- a/netwerk/sctp/src/netinet/sctputil.c +++ b/netwerk/sctp/src/netinet/sctputil.c @@ -77,6 +77,10 @@ #endif #endif +#if defined(_WIN32) && !defined(_MSC_VER) +#include +#endif + extern const struct sctp_cc_functions sctp_cc_functions[]; extern const struct sctp_ss_functions sctp_ss_functions[]; diff --git a/netwerk/sctp/src/user_mbuf.c b/netwerk/sctp/src/user_mbuf.c index 85badc0fa520..83b6ee3d8dd7 100644 --- a/netwerk/sctp/src/user_mbuf.c +++ b/netwerk/sctp/src/user_mbuf.c @@ -35,6 +35,10 @@ * */ +#if defined(_WIN32) && !defined(_MSC_VER) +#include +#endif + #include #include /* #include This defines MSIZE 256 */ diff --git a/netwerk/sctp/src/user_socket.c b/netwerk/sctp/src/user_socket.c index cde6ecc417b5..9bdd51e105d0 100644 --- a/netwerk/sctp/src/user_socket.c +++ b/netwerk/sctp/src/user_socket.c @@ -60,9 +60,12 @@ #endif userland_mutex_t accept_mtx; userland_cond_t accept_cond; -#ifdef _WIN32 +#if defined(_WIN32) #include #include +#if !defined(_MSC_VER) +#include +#endif #endif MALLOC_DEFINE(M_PCB, "sctp_pcb", "sctp pcb"); -- GitLab From f0293377b963da99194f7e05d71d4e6fd705b5b5 Mon Sep 17 00:00:00 2001 From: Marco Simonelli Date: Fri, 10 Mar 2023 12:09:57 +0000 Subject: [PATCH 012/250] BB 41459: WebRTC fails to build under mingw (Part 5) - fixes required to build dom/media/webrtc --- dom/media/webrtc/libwebrtcglue/VideoConduit.cpp | 4 ++-- .../webrtc/sdp/RsdparsaSdpAttributeList.cpp | 1 + .../webrtc/transport/nrinterfaceprioritizer.cpp | 6 +++--- dom/media/webrtc/transport/sigslot.h | 3 ++- dom/media/webrtc/transport/test/ice_unittest.cpp | 8 ++++---- .../third_party/nICEr/src/net/local_addr.c | 6 +++--- .../third_party/nICEr/src/net/local_addr.h | 2 +- .../third_party/nICEr/src/stun/addrs-netlink.c | 16 ++++++++-------- .../third_party/nICEr/src/stun/addrs-win32.c | 8 ++++---- .../transport/third_party/nICEr/src/stun/addrs.c | 2 +- .../third_party/nrappkit/src/log/r_log.c | 2 +- .../third_party/nrappkit/src/registry/registry.c | 2 +- 12 files changed, 31 insertions(+), 29 deletions(-) diff --git a/dom/media/webrtc/libwebrtcglue/VideoConduit.cpp b/dom/media/webrtc/libwebrtcglue/VideoConduit.cpp index adeb31cdc070..73dc61e32fca 100644 --- a/dom/media/webrtc/libwebrtcglue/VideoConduit.cpp +++ b/dom/media/webrtc/libwebrtcglue/VideoConduit.cpp @@ -102,8 +102,8 @@ #endif // for ntohs -#ifdef _MSC_VER -# include "Winsock2.h" +#ifdef WIN32 +# include "winsock2.h" #else # include #endif diff --git a/dom/media/webrtc/sdp/RsdparsaSdpAttributeList.cpp b/dom/media/webrtc/sdp/RsdparsaSdpAttributeList.cpp index e70457687a50..f7eee54bdd67 100644 --- a/dom/media/webrtc/sdp/RsdparsaSdpAttributeList.cpp +++ b/dom/media/webrtc/sdp/RsdparsaSdpAttributeList.cpp @@ -4,6 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include #include "SdpAttribute.h" #include "nsCRT.h" diff --git a/dom/media/webrtc/transport/nrinterfaceprioritizer.cpp b/dom/media/webrtc/transport/nrinterfaceprioritizer.cpp index 76e2f00cb0a3..025b030cd5db 100644 --- a/dom/media/webrtc/transport/nrinterfaceprioritizer.cpp +++ b/dom/media/webrtc/transport/nrinterfaceprioritizer.cpp @@ -41,9 +41,9 @@ class LocalAddress { } addr_ = buf; - is_vpn_ = (local_addr.interface.type & NR_INTERFACE_TYPE_VPN) != 0 ? 1 : 0; - estimated_speed_ = local_addr.interface.estimated_speed; - type_preference_ = GetNetworkTypePreference(local_addr.interface.type); + is_vpn_ = (local_addr.iface.type & NR_INTERFACE_TYPE_VPN) != 0 ? 1 : 0; + estimated_speed_ = local_addr.iface.estimated_speed; + type_preference_ = GetNetworkTypePreference(local_addr.iface.type); ip_version_ = local_addr.addr.ip_version; return true; } diff --git a/dom/media/webrtc/transport/sigslot.h b/dom/media/webrtc/transport/sigslot.h index 448e8137fec7..b5a74e94cec8 100644 --- a/dom/media/webrtc/transport/sigslot.h +++ b/dom/media/webrtc/transport/sigslot.h @@ -114,7 +114,8 @@ # define WIN32_LEAN_AND_MEAN # endif # include "rtc_base/win32.h" -#elif defined(__GNUG__) || defined(SIGSLOT_USE_POSIX_THREADS) +#elif (defined(__GNUG__) || defined(SIGSLOT_USE_POSIX_THREADS)) && \ + !defined(__MINGW32__) # define _SIGSLOT_HAS_POSIX_THREADS # include #else diff --git a/dom/media/webrtc/transport/test/ice_unittest.cpp b/dom/media/webrtc/transport/test/ice_unittest.cpp index eb7d2995d37e..22336c7c8803 100644 --- a/dom/media/webrtc/transport/test/ice_unittest.cpp +++ b/dom/media/webrtc/transport/test/ice_unittest.cpp @@ -1964,8 +1964,8 @@ class WebRtcIcePrioritizerTest : public StunTest { std::string str_addr = "10.0.0." + num; std::string ifname = "eth" + num; nr_local_addr local_addr; - local_addr.interface.type = type; - local_addr.interface.estimated_speed = estimated_speed; + local_addr.iface.type = type; + local_addr.iface.estimated_speed = estimated_speed; int r = nr_str_port_to_transport_addr(str_addr.c_str(), 0, IPPROTO_UDP, &(local_addr.addr)); @@ -2902,8 +2902,8 @@ TEST_F(WebRtcIceConnectTest, // prepare a fake wifi interface nr_local_addr wifi_addr; - wifi_addr.interface.type = NR_INTERFACE_TYPE_WIFI; - wifi_addr.interface.estimated_speed = 1000; + wifi_addr.iface.type = NR_INTERFACE_TYPE_WIFI; + wifi_addr.iface.estimated_speed = 1000; int r = nr_str_port_to_transport_addr(FAKE_WIFI_ADDR, 0, IPPROTO_UDP, &(wifi_addr.addr)); diff --git a/dom/media/webrtc/transport/third_party/nICEr/src/net/local_addr.c b/dom/media/webrtc/transport/third_party/nICEr/src/net/local_addr.c index a0896d5e9d8b..3356b1f3a507 100644 --- a/dom/media/webrtc/transport/third_party/nICEr/src/net/local_addr.c +++ b/dom/media/webrtc/transport/third_party/nICEr/src/net/local_addr.c @@ -44,7 +44,7 @@ int nr_local_addr_copy(nr_local_addr *to, nr_local_addr *from) if (r=nr_transport_addr_copy(&(to->addr), &(from->addr))) { ABORT(r); } - to->interface = from->interface; + to->iface = from->iface; to->flags = from->flags; _status=0; @@ -54,7 +54,7 @@ int nr_local_addr_copy(nr_local_addr *to, nr_local_addr *from) int nr_local_addr_fmt_info_string(nr_local_addr *addr, char *buf, int len) { - int addr_type = addr->interface.type; + int addr_type = addr->iface.type; const char *vpn = (addr_type & NR_INTERFACE_TYPE_VPN) ? "VPN on " : ""; const char *type = (addr_type & NR_INTERFACE_TYPE_WIRED) ? "wired" : @@ -63,7 +63,7 @@ int nr_local_addr_fmt_info_string(nr_local_addr *addr, char *buf, int len) "unknown"; snprintf(buf, len, "%s%s, estimated speed: %d kbps %s", - vpn, type, addr->interface.estimated_speed, + vpn, type, addr->iface.estimated_speed, (addr->flags & NR_ADDR_FLAG_TEMPORARY ? "temporary" : "")); buf[len - 1] = '\0'; return (0); diff --git a/dom/media/webrtc/transport/third_party/nICEr/src/net/local_addr.h b/dom/media/webrtc/transport/third_party/nICEr/src/net/local_addr.h index fb963e111573..5ef40ae4fb47 100644 --- a/dom/media/webrtc/transport/third_party/nICEr/src/net/local_addr.h +++ b/dom/media/webrtc/transport/third_party/nICEr/src/net/local_addr.h @@ -51,7 +51,7 @@ typedef struct nr_interface_ { typedef struct nr_local_addr_ { nr_transport_addr addr; - nr_interface interface; + nr_interface iface; #define NR_ADDR_FLAG_TEMPORARY 0x1 int flags; } nr_local_addr; diff --git a/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs-netlink.c b/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs-netlink.c index 8d22e5979ea3..a512917d01c8 100644 --- a/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs-netlink.c +++ b/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs-netlink.c @@ -139,7 +139,7 @@ stun_convert_netlink(nr_local_addr *addr, struct ifaddrmsg *address_msg, struct int flags = get_siocgifflags(addr); if (flags & IFF_POINTOPOINT) { - addr->interface.type = NR_INTERFACE_TYPE_UNKNOWN | NR_INTERFACE_TYPE_VPN; + addr->iface.type = NR_INTERFACE_TYPE_UNKNOWN | NR_INTERFACE_TYPE_VPN; /* TODO (Bug 896913): find backend network type of this VPN */ } @@ -162,11 +162,11 @@ stun_convert_netlink(nr_local_addr *addr, struct ifaddrmsg *address_msg, struct { /* For wireless network, we won't get ethtool, it's a wired * connection */ - addr->interface.type = NR_INTERFACE_TYPE_WIRED; + addr->iface.type = NR_INTERFACE_TYPE_WIRED; #ifdef DONT_HAVE_ETHTOOL_SPEED_HI - addr->interface.estimated_speed = ecmd.speed; + addr->iface.estimated_speed = ecmd.speed; #else - addr->interface.estimated_speed = ((ecmd.speed_hi << 16) | ecmd.speed) * 1000; + addr->iface.estimated_speed = ((ecmd.speed_hi << 16) | ecmd.speed) * 1000; #endif } @@ -174,15 +174,15 @@ stun_convert_netlink(nr_local_addr *addr, struct ifaddrmsg *address_msg, struct e = ioctl(s, SIOCGIWRATE, &wrq); if (e == 0) { - addr->interface.type = NR_INTERFACE_TYPE_WIFI; - addr->interface.estimated_speed = wrq.u.bitrate.value / 1000; + addr->iface.type = NR_INTERFACE_TYPE_WIFI; + addr->iface.estimated_speed = wrq.u.bitrate.value / 1000; } close(s); #else - addr->interface.type = NR_INTERFACE_TYPE_UNKNOWN; - addr->interface.estimated_speed = 0; + addr->iface.type = NR_INTERFACE_TYPE_UNKNOWN; + addr->iface.estimated_speed = 0; #endif return 0; } diff --git a/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs-win32.c b/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs-win32.c index a1b0cd9f0aba..6af7901fddea 100644 --- a/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs-win32.c +++ b/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs-win32.c @@ -174,14 +174,14 @@ stun_getaddrs_filtered(nr_local_addr addrs[], int maxaddrs, int *count) strlcpy(addrs[n].addr.ifname, hex_hashed_ifname, sizeof(addrs[n].addr.ifname)); if (tmpAddress->IfType == IF_TYPE_ETHERNET_CSMACD) { - addrs[n].interface.type = NR_INTERFACE_TYPE_WIRED; + addrs[n].iface.type = NR_INTERFACE_TYPE_WIRED; } else if (tmpAddress->IfType == IF_TYPE_IEEE80211) { /* Note: this only works for >= Win Vista */ - addrs[n].interface.type = NR_INTERFACE_TYPE_WIFI; + addrs[n].iface.type = NR_INTERFACE_TYPE_WIFI; } else { - addrs[n].interface.type = NR_INTERFACE_TYPE_UNKNOWN; + addrs[n].iface.type = NR_INTERFACE_TYPE_UNKNOWN; } - addrs[n].interface.estimated_speed = tmpAddress->TransmitLinkSpeed / 1000; + addrs[n].iface.estimated_speed = tmpAddress->TransmitLinkSpeed / 1000; if (stun_win32_address_temp_v6(u)) { addrs[n].flags |= NR_ADDR_FLAG_TEMPORARY; } diff --git a/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs.c b/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs.c index 51f72f4179a6..7472c2db81dc 100644 --- a/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs.c +++ b/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs.c @@ -92,7 +92,7 @@ nr_stun_filter_addrs_for_ifname(nr_local_addr src[], const int src_begin, const if (src[i].addr.ip_version == NR_IPV6) { if (nr_transport_addr_is_teredo(&src[i].addr)) { - src[i].interface.type |= NR_INTERFACE_TYPE_TEREDO; + src[i].iface.type |= NR_INTERFACE_TYPE_TEREDO; /* Prefer teredo over mac-based address. Probably will never see * both. */ filter_mac_ipv6 = 1; diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/log/r_log.c b/dom/media/webrtc/transport/third_party/nrappkit/src/log/r_log.c index bb47cda879bf..0206302fa23c 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/log/r_log.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/log/r_log.c @@ -46,7 +46,7 @@ #include #include -#ifndef _MSC_VER +#ifndef WIN32 #include #include #endif diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registry.c b/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registry.c index 3134ad153619..ae802903e7c7 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registry.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registry.c @@ -44,7 +44,7 @@ #include #include -#ifndef _MSC_VER +#ifndef WIN32 #include #include #include -- GitLab From 24338623bf5b342a3b2e6f2096315c23a3544937 Mon Sep 17 00:00:00 2001 From: Marco Simonelli Date: Fri, 10 Mar 2023 12:11:22 +0000 Subject: [PATCH 013/250] BB 41459: WebRTC fails to build under mingw (Part 6) - fixes required to build dom/media/systemservices --- dom/media/systemservices/video_engine/desktop_device_info.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom/media/systemservices/video_engine/desktop_device_info.cc b/dom/media/systemservices/video_engine/desktop_device_info.cc index 52d8656c0f24..892f8d25cd69 100644 --- a/dom/media/systemservices/video_engine/desktop_device_info.cc +++ b/dom/media/systemservices/video_engine/desktop_device_info.cc @@ -25,7 +25,7 @@ namespace webrtc { void DesktopSource::setScreenId(ScreenId aId) { mScreenId = aId; } void DesktopSource::setName(nsCString&& aName) { mName = std::move(aName); } void DesktopSource::setUniqueId(nsCString&& aId) { mUniqueId = std::move(aId); } -void DesktopSource::setPid(const int aPid) { mPid = aPid; } +void DesktopSource::setPid(const pid_t aPid) { mPid = aPid; } ScreenId DesktopSource::getScreenId() const { return mScreenId; } const nsCString& DesktopSource::getName() const { return mName; } -- GitLab From c76e2ad0213b6f9783bc4e162c1da796ddf031fb Mon Sep 17 00:00:00 2001 From: june wilde Date: Wed, 2 Oct 2024 20:19:01 -0700 Subject: [PATCH 014/250] BB 42758: Fix WebRTC build errors. --- .../modules/desktop_capture/win/wgc_capture_session.cc | 10 ++++------ .../modules/desktop_capture/win/wgc_capturer_win.cc | 2 +- .../modules/desktop_capture/win/wgc_capturer_win.h | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/third_party/libwebrtc/modules/desktop_capture/win/wgc_capture_session.cc b/third_party/libwebrtc/modules/desktop_capture/win/wgc_capture_session.cc index 491a67d45fc6..0152cea55301 100644 --- a/third_party/libwebrtc/modules/desktop_capture/win/wgc_capture_session.cc +++ b/third_party/libwebrtc/modules/desktop_capture/win/wgc_capture_session.cc @@ -10,9 +10,9 @@ #include "modules/desktop_capture/win/wgc_capture_session.h" -#include +#include #include -#include +#include #include #include #include @@ -193,9 +193,7 @@ HRESULT WgcCaptureSession::StartCapture(const DesktopCaptureOptions& options) { if (!options.prefer_cursor_embedded()) { ComPtr session2; - if (SUCCEEDED(session_->QueryInterface( - ABI::Windows::Graphics::Capture::IID_IGraphicsCaptureSession2, - &session2))) { + if (SUCCEEDED(session_->QueryInterface(IID_PPV_ARGS(&session2)))) { session2->put_IsCursorCaptureEnabled(false); } } @@ -379,7 +377,7 @@ HRESULT WgcCaptureSession::ProcessFrame() { return hr; } - ComPtr + ComPtr direct3DDxgiInterfaceAccess; hr = d3d_surface->QueryInterface(IID_PPV_ARGS(&direct3DDxgiInterfaceAccess)); if (FAILED(hr)) { diff --git a/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win.cc b/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win.cc index fff2a9ee235c..e39e443c9a50 100644 --- a/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win.cc +++ b/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win.cc @@ -10,7 +10,7 @@ #include "modules/desktop_capture/win/wgc_capturer_win.h" -#include +#include #include #include diff --git a/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win.h b/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win.h index 30253d9db62b..64c50e0cf003 100644 --- a/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win.h +++ b/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win.h @@ -11,7 +11,7 @@ #ifndef MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURER_WIN_H_ #define MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURER_WIN_H_ -#include +#include #include #include -- GitLab From a1a55359a1a595694b834ce2f57ab30d7ea36ad4 Mon Sep 17 00:00:00 2001 From: Pier Angelo Vendrame Date: Mon, 12 May 2025 15:20:18 +0200 Subject: [PATCH 015/250] fixup! BB 42758: Fix WebRTC build errors. MB 436: Link to pthread on mingw. --- media/libaom/moz.build | 3 +++ third_party/abseil-cpp/absl/base/base_gn/moz.build | 3 +++ 2 files changed, 6 insertions(+) diff --git a/media/libaom/moz.build b/media/libaom/moz.build index eb5b22c05423..8d3c046d5d01 100644 --- a/media/libaom/moz.build +++ b/media/libaom/moz.build @@ -143,3 +143,6 @@ LOCAL_INCLUDES += [ # TEST_DIRS += [ # 'test/fuzztest' # ] + +if CONFIG["OS_TARGET"] == "WINNT" and CONFIG["CC_TYPE"] == "clang": + OS_LIBS += ["pthread"] diff --git a/third_party/abseil-cpp/absl/base/base_gn/moz.build b/third_party/abseil-cpp/absl/base/base_gn/moz.build index afd3f9a4eb24..0245102b76bb 100644 --- a/third_party/abseil-cpp/absl/base/base_gn/moz.build +++ b/third_party/abseil-cpp/absl/base/base_gn/moz.build @@ -168,4 +168,7 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64": DEFINES["_GNU_SOURCE"] = True +if CONFIG["OS_TARGET"] == "WINNT" and CONFIG["CC_TYPE"] == "clang": + OS_LIBS += ["pthread"] + Library("base_gn") -- GitLab From 285ef9240240787da552c0a957f293681cb1ef04 Mon Sep 17 00:00:00 2001 From: hackademix Date: Wed, 5 Jul 2023 17:05:40 +0200 Subject: [PATCH 016/250] BB 41854: Allow overriding download spam protection. --- .../downloads/DownloadSpamProtection.sys.mjs | 61 +++++++++++++++++-- .../components/downloads/DownloadCore.sys.mjs | 9 ++- .../downloads/DownloadIntegration.sys.mjs | 5 +- .../exthandler/nsExternalHelperAppService.cpp | 4 +- 4 files changed, 64 insertions(+), 15 deletions(-) diff --git a/browser/components/downloads/DownloadSpamProtection.sys.mjs b/browser/components/downloads/DownloadSpamProtection.sys.mjs index a05c508e628f..9e890edc2830 100644 --- a/browser/components/downloads/DownloadSpamProtection.sys.mjs +++ b/browser/components/downloads/DownloadSpamProtection.sys.mjs @@ -89,8 +89,9 @@ class WindowSpamProtection { * Add a blocked download to the spamList or increment the count of an * existing blocked download, then notify listeners about this. * @param {String} url + * @param {DownloadSpamEnabler} enabler */ - addDownloadSpam(url) { + addDownloadSpam(url, enabler) { this._blocking = true; // Start listening on registered downloads views, if any exist. this._maybeAddViews(); @@ -104,7 +105,7 @@ class WindowSpamProtection { } // Otherwise, create a new DownloadSpam object for the URL, add it to the // spamList, and open the downloads panel. - let downloadSpam = new DownloadSpam(url); + let downloadSpam = new DownloadSpam(url, enabler); this.spamList.add(downloadSpam); this._downloadSpamForUrl.set(url, downloadSpam); this._notifyDownloadSpamAdded(downloadSpam); @@ -188,6 +189,39 @@ class WindowSpamProtection { } } +/** + * Helper to grant a certain principal permission for automatic downloads + * and to clear its download spam messages from the UI + */ +class DownloadSpamEnabler { + /** + * Constructs a DownloadSpamEnabler object + * @param {nsIPrincipal} principal + * @param {DownloadSpamProtection} downloadSpamProtection + */ + constructor(principal, downloadSpamProtection) { + this.principal = principal; + this.downloadSpamProtection = downloadSpamProtection; + } + /** + * Allows a DownloadSpam item + * @param {DownloadSpam} downloadSpam + */ + allow(downloadSpam) { + const pm = Services.perms; + pm.addFromPrincipal( + this.principal, + "automatic-download", + pm.ALLOW_ACTION, + pm.EXPIRE_SESSION + ); + downloadSpam.hasBlockedData = downloadSpam.hasPartialData = false; + const { url } = downloadSpam.source; + for (let window of lazy.BrowserWindowTracker.orderedWindows) { + this.downloadSpamProtection.removeDownloadSpamForWindow(url, window); + } + } +} /** * Responsible for detecting events related to downloads spam and notifying the * relevant window's WindowSpamProtection object. This is a singleton object, @@ -205,9 +239,11 @@ export class DownloadSpamProtection { * download was blocked. This is invoked when a download is blocked by * nsExternalAppHandler::IsDownloadSpam * @param {String} url - * @param {Window} window + * @param {nsILoadInfo} loadInfo */ - update(url, window) { + update(url, loadInfo) { + loadInfo = loadInfo.QueryInterface(Ci.nsILoadInfo); + const window = loadInfo.browsingContext.topChromeWindow; if (window == null) { lazy.DownloadsCommon.log( "Download spam blocked in a non-chrome window. URL: ", @@ -221,7 +257,10 @@ export class DownloadSpamProtection { let wsp = this._forWindowMap.get(window) ?? new WindowSpamProtection(window); this._forWindowMap.set(window, wsp); - wsp.addDownloadSpam(url); + wsp.addDownloadSpam( + url, + new DownloadSpamEnabler(loadInfo.triggeringPrincipal, this) + ); } /** @@ -280,8 +319,9 @@ export class DownloadSpamProtection { * @extends Download */ class DownloadSpam extends Download { - constructor(url) { + constructor(url, downloadSpamEnabler) { super(); + this._downloadSpamEnabler = downloadSpamEnabler; this.hasBlockedData = true; this.stopped = true; this.error = new DownloadError({ @@ -292,4 +332,13 @@ class DownloadSpam extends Download { this.source = { url }; this.blockedDownloadsCount = 1; } + + /** + * Allows the principal which triggered this download to perform automatic downloads + * and clears the UI from messages reporting this download spam + */ + allow() { + this._downloadSpamEnabler.allow(this); + this._notifyChange(); + } } diff --git a/toolkit/components/downloads/DownloadCore.sys.mjs b/toolkit/components/downloads/DownloadCore.sys.mjs index 64ebc66b95aa..0ad998183e6d 100644 --- a/toolkit/components/downloads/DownloadCore.sys.mjs +++ b/toolkit/components/downloads/DownloadCore.sys.mjs @@ -715,6 +715,10 @@ Download.prototype = { } this._promiseUnblock = (async () => { + if (this.allow) { + this.allow(); + return; + } try { await IOUtils.move(this.target.partFilePath, this.target.path); await this.target.refresh(); @@ -723,7 +727,6 @@ Download.prototype = { this._promiseUnblock = null; throw ex; } - this.succeeded = true; this.hasBlockedData = false; this._notifyChange(); @@ -953,7 +956,9 @@ Download.prototype = { await this._promiseCanceled; } // Ask the saver object to remove any partial data. - await this.saver.removeData(); + if (this.saver) { + await this.saver.removeData(); + } // For completeness, clear the number of bytes transferred. if (this.currentBytes != 0 || this.hasPartialData) { this.currentBytes = 0; diff --git a/toolkit/components/downloads/DownloadIntegration.sys.mjs b/toolkit/components/downloads/DownloadIntegration.sys.mjs index c77ba2f4b095..58fa6811efa9 100644 --- a/toolkit/components/downloads/DownloadIntegration.sys.mjs +++ b/toolkit/components/downloads/DownloadIntegration.sys.mjs @@ -1172,10 +1172,7 @@ var DownloadObserver = { case "blocked-automatic-download": if (AppConstants.MOZ_BUILD_APP == "browser") { DownloadIntegration._initializeDownloadSpamProtection(); - DownloadIntegration.downloadSpamProtection.update( - aData, - aSubject.topChromeWindow - ); + DownloadIntegration.downloadSpamProtection.update(aData, aSubject); } break; } diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index e23df8e6f982..5f93306af77b 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -1944,13 +1944,11 @@ bool nsExternalAppHandler::IsDownloadSpam(nsIChannel* aChannel) { if (capability == nsIPermissionManager::PROMPT_ACTION) { nsCOMPtr observerService = mozilla::services::GetObserverService(); - RefPtr browsingContext; - loadInfo->GetBrowsingContext(getter_AddRefs(browsingContext)); nsAutoCString cStringURI; loadInfo->TriggeringPrincipal()->GetPrePath(cStringURI); observerService->NotifyObservers( - browsingContext, "blocked-automatic-download", + loadInfo, "blocked-automatic-download", NS_ConvertASCIItoUTF16(cStringURI.get()).get()); // FIXME: In order to escape memory leaks, currently we cancel blocked // downloads. This is temporary solution, because download data should be -- GitLab From 2c7bcce7d6775133c6e20522c011cb073c37d8b8 Mon Sep 17 00:00:00 2001 From: hackademix Date: Tue, 24 Sep 2024 23:13:21 +0200 Subject: [PATCH 017/250] BB 42832: Download spam prevention exemption for browser extensions. --- uriloader/exthandler/nsExternalHelperAppService.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 5f93306af77b..86efd351a83c 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -1921,6 +1921,12 @@ bool nsExternalAppHandler::IsDownloadSpam(nsIChannel* aChannel) { nsCOMPtr permissionManager = mozilla::services::GetPermissionManager(); nsCOMPtr principal = loadInfo->TriggeringPrincipal(); + + // Always allow WebExtensions + if (principal && principal->SchemeIs("moz-extension")) { + return false; + } + bool exactHostMatch = false; constexpr auto type = "automatic-download"_ns; nsCOMPtr permission; -- GitLab From 2e60551283d5ea3f6906de9e930565b4af81170b Mon Sep 17 00:00:00 2001 From: Pier Angelo Vendrame Date: Tue, 10 Sep 2024 18:54:30 +0200 Subject: [PATCH 018/250] BB 42220: Allow for more file types to be forced-inline. Firefox allows to open some files in the browser without any confirmation, but this will result in a disk leak, because the file will be downloaded to the temporary directory first (and not deleted, in some cases). A preference allows PDFs to be opened without being downloaded to disk. So, we introduce a similar one to do the same for all the files that are set to be opened automatically in the browser. --- modules/libpref/init/StaticPrefList.yaml | 6 ++++ uriloader/base/nsURILoader.cpp | 45 +++++++++++++++--------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 9e947d9d4335..56e7fa6c1f26 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -1601,6 +1601,12 @@ value: false mirror: always +# tor-browser#42220 +- name: browser.download.ignore_content_disposition + type: bool + value: true + mirror: always + # See bug 1811830 - name: browser.download.force_save_internally_handled_attachments type: bool diff --git a/uriloader/base/nsURILoader.cpp b/uriloader/base/nsURILoader.cpp index 7d513c50cb3a..124a511c12f0 100644 --- a/uriloader/base/nsURILoader.cpp +++ b/uriloader/base/nsURILoader.cpp @@ -369,34 +369,42 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest* request) { LOG((" forceExternalHandling: %s", forceExternalHandling ? "yes" : "no")); if (forceExternalHandling && - mozilla::StaticPrefs::browser_download_open_pdf_attachments_inline()) { + (mozilla::StaticPrefs::browser_download_open_pdf_attachments_inline() || + mozilla::StaticPrefs::browser_download_ignore_content_disposition())) { // Check if this is a PDF which should be opened internally. We also handle // octet-streams that look like they might be PDFs based on their extension. bool isPDF = mContentType.LowerCaseEqualsASCII(APPLICATION_PDF); - if (!isPDF && - (mContentType.LowerCaseEqualsASCII(APPLICATION_OCTET_STREAM) || - mContentType.IsEmpty())) { + nsAutoCString ext; + if (mContentType.LowerCaseEqualsASCII(APPLICATION_OCTET_STREAM) || + mContentType.IsEmpty()) { nsAutoString flname; aChannel->GetContentDispositionFilename(flname); - isPDF = StringEndsWith(flname, u".pdf"_ns); - if (!isPDF) { + if (!flname.IsEmpty()) { + int32_t extStart = flname.RFindChar(u'.'); + if (extStart != kNotFound) { + CopyUTF16toUTF8(Substring(flname, extStart + 1), ext); + } + } + if (ext.IsEmpty() || (!mozilla::StaticPrefs:: + browser_download_ignore_content_disposition() && + !ext.EqualsLiteral("pdf"))) { nsCOMPtr uri; aChannel->GetURI(getter_AddRefs(uri)); nsCOMPtr url(do_QueryInterface(uri)); if (url) { - nsAutoCString ext; url->GetFileExtension(ext); - isPDF = ext.EqualsLiteral("pdf"); } } + isPDF = ext.EqualsLiteral("pdf"); } - // For a PDF, check if the preference is set that forces attachments to be - // opened inline. If so, treat it as a non-attachment by clearing - // 'forceExternalHandling' again. This allows it open a PDF directly - // instead of downloading it first. It may still end up being handled by - // a helper app depending anyway on the later checks. - if (isPDF) { + // One of the preferences to forces attachments to be opened inline is set. + // If so, treat it as a non-attachment by clearing 'forceExternalHandling' + // again. This allows it open a file directly instead of downloading it + // first. It may still end up being handled by a helper app depending anyway + // on the later checks. + if (mozilla::StaticPrefs::browser_download_ignore_content_disposition() || + isPDF) { nsCOMPtr loadInfo; aChannel->GetLoadInfo(getter_AddRefs(loadInfo)); @@ -405,8 +413,13 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest* request) { nsCOMPtr mimeSvc( do_GetService(NS_MIMESERVICE_CONTRACTID)); NS_ENSURE_TRUE(mimeSvc, NS_ERROR_FAILURE); - mimeSvc->GetFromTypeAndExtension(nsLiteralCString(APPLICATION_PDF), ""_ns, - getter_AddRefs(mimeInfo)); + if (isPDF) { + mimeSvc->GetFromTypeAndExtension(nsLiteralCString(APPLICATION_PDF), + ""_ns, getter_AddRefs(mimeInfo)); + } else { + mimeSvc->GetFromTypeAndExtension(mContentType, ext, + getter_AddRefs(mimeInfo)); + } if (mimeInfo) { int32_t action = nsIMIMEInfo::saveToDisk; -- GitLab From c35b4c4f9f1199cea93d4d25f5e4a55ca06c0cbd Mon Sep 17 00:00:00 2001 From: hackademix Date: Mon, 29 Jul 2024 19:27:00 +0200 Subject: [PATCH 019/250] BB 42835: Create an actor to filter file data transfers --- toolkit/actors/FilesFilterChild.sys.mjs | 64 ++++++++++++++++++++++ toolkit/actors/FilesFilterParent.sys.mjs | 7 +++ toolkit/actors/moz.build | 2 + toolkit/modules/ActorManagerParent.sys.mjs | 16 ++++++ 4 files changed, 89 insertions(+) create mode 100644 toolkit/actors/FilesFilterChild.sys.mjs create mode 100644 toolkit/actors/FilesFilterParent.sys.mjs diff --git a/toolkit/actors/FilesFilterChild.sys.mjs b/toolkit/actors/FilesFilterChild.sys.mjs new file mode 100644 index 000000000000..6f223567ef75 --- /dev/null +++ b/toolkit/actors/FilesFilterChild.sys.mjs @@ -0,0 +1,64 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const lazy = {}; + +ChromeUtils.defineLazyGetter(lazy, "console", () => { + return console.createInstance({ + prefix: "FilesFilter", + }); +}); + +export class FilesFilterChild extends JSWindowActorChild { + handleEvent(event) { + if (!Services.prefs.getBoolPref("browser.filesfilter.enabled", true)) { + return; + } + // drop or paste + const { composedTarget } = event; + const dt = event.clipboardData || event.dataTransfer; + + if ([...dt.files].some(f => f.mozFullPath)) { + if ( + ["HTMLInputElement", "HTMLTextAreaElement"].includes( + ChromeUtils.getClassName(composedTarget) + ) + ) { + event.preventDefault(); + lazy.console.log( + `Preventing path leak on ${event.type} for ${[...dt.files] + .map(f => `${f.name} (${f.mozFullPath})`) + .join(", ")}.` + ); + } + return; + } + + // "Paste Without Formatting" (ctrl+shift+V) in HTML editors coerces files into paths + if (!(event.clipboardData && /[\/\\]/.test(dt.getData("text")))) { + return; + } + + // check wether the clipboard contains a file + const { clipboard } = Services; + if ( + [clipboard.kSelectionClipboard, clipboard.kGlobalClipboard].some( + clipboardType => + clipboard.isClipboardTypeSupported(clipboardType) && + clipboard.hasDataMatchingFlavors( + ["application/x-moz-file"], + clipboardType + ) + ) + ) { + event.preventDefault(); + event.stopPropagation(); + lazy.console.log( + `Preventing path leak on "Paste Without Formatting" for ${dt.getData( + "text" + )}.` + ); + } + } +} diff --git a/toolkit/actors/FilesFilterParent.sys.mjs b/toolkit/actors/FilesFilterParent.sys.mjs new file mode 100644 index 000000000000..444361d060be --- /dev/null +++ b/toolkit/actors/FilesFilterParent.sys.mjs @@ -0,0 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +export class FilesFilterParent extends JSWindowActorParent { + // just a stub for now +} diff --git a/toolkit/actors/moz.build b/toolkit/actors/moz.build index 9b5d83e11a23..f2f4eebe3523 100644 --- a/toolkit/actors/moz.build +++ b/toolkit/actors/moz.build @@ -49,6 +49,8 @@ FINAL_TARGET_FILES.actors += [ "DateTimePickerChild.sys.mjs", "DateTimePickerParent.sys.mjs", "ExtFindChild.sys.mjs", + "FilesFilterChild.sys.mjs", + "FilesFilterParent.sys.mjs", "FindBarChild.sys.mjs", "FindBarParent.sys.mjs", "FinderChild.sys.mjs", diff --git a/toolkit/modules/ActorManagerParent.sys.mjs b/toolkit/modules/ActorManagerParent.sys.mjs index 97337e8159b8..1efedc49778f 100644 --- a/toolkit/modules/ActorManagerParent.sys.mjs +++ b/toolkit/modules/ActorManagerParent.sys.mjs @@ -354,6 +354,22 @@ let JSWINDOWACTORS = { allFrames: true, }, + FilesFilter: { + parent: { + esModuleURI: "resource://gre/actors/FilesFilterParent.sys.mjs", + }, + + child: { + esModuleURI: "resource://gre/actors/FilesFilterChild.sys.mjs", + events: { + drop: {}, + paste: { capture: true }, + }, + }, + + allFrames: true, + }, + FindBar: { parent: { esModuleURI: "resource://gre/actors/FindBarParent.sys.mjs", -- GitLab From c90863d6414f47c16eafdf7c0c18c15c4bb0eafd Mon Sep 17 00:00:00 2001 From: Beatriz Rizental Date: Wed, 31 Jul 2024 16:24:41 +0200 Subject: [PATCH 020/250] BB 42728: Modify ./mach lint to skip unused linters --- python/mozlint/mozlint/cli.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/python/mozlint/mozlint/cli.py b/python/mozlint/mozlint/cli.py index 21d6d878a4af..51a2a2e4503a 100644 --- a/python/mozlint/mozlint/cli.py +++ b/python/mozlint/mozlint/cli.py @@ -12,6 +12,30 @@ from pathlib import Path from mozlint.errors import NoValidLinter from mozlint.formatters import all_formatters +# We (the Tor Project) do not use all of Mozilla's linters. +# Below is a list of linters we do not use, +# these will be skipped when running `./mach lint` commands. +INACTIVE_LINTERS = [ + "android-api-lint", + "android-checkstyle", + "android-format", + "android-javadoc", + "android-lint", + "android-test", + "clippy", + "codespell", + "condprof-addons", + "file-perm", + "ignorefile", + "license", + "lintpref", + "perfdocs", + "rejected-words", + "rst", + "updatebot", + "wpt", +] + class MozlintParser(ArgumentParser): arguments = [ @@ -319,6 +343,9 @@ def find_linters(config_paths, linters=None): name = name.rsplit(".", 1)[0] + if not linters and name in INACTIVE_LINTERS: + continue + if linters and name not in linters: continue @@ -385,10 +412,14 @@ def run( if list_linters: lint_paths = find_linters(lintargs["config_paths"], linters) - linters = [ + formatted_linters = [ os.path.splitext(os.path.basename(l))[0] for l in lint_paths["lint_paths"] ] - print("\n".join(sorted(linters))) + print("\n".join(sorted(formatted_linters))) + + if not linters: + print("\nINACTIVE -- ".join(sorted(["", *INACTIVE_LINTERS])).strip()) + print( "\nNote that clang-tidy checks are not run as part of this " "command, but using the static-analysis command." -- GitLab From f1b148cca239decfa94698cb6d947e3453cba343 Mon Sep 17 00:00:00 2001 From: Gaba Date: Mon, 28 Jun 2021 11:44:16 -0700 Subject: [PATCH 021/250] Adding issue and merge request templates --- .gitlab/issue_templates/Backport.md | 31 ++++ .../Emergency Security Issue.md | 90 ++++++++++ .gitlab/issue_templates/QA - Android.md | 71 ++++++++ .gitlab/issue_templates/QA - Desktop.md | 164 ++++++++++++++++++ .gitlab/issue_templates/Uplift.md | 26 +++ .gitlab/issue_templates/bug.md | 32 ++++ .gitlab/merge_request_templates/Rebase.md | 23 +++ .gitlab/merge_request_templates/default.md | 91 ++++++++++ 8 files changed, 528 insertions(+) create mode 100644 .gitlab/issue_templates/Backport.md create mode 100644 .gitlab/issue_templates/Emergency Security Issue.md create mode 100644 .gitlab/issue_templates/QA - Android.md create mode 100644 .gitlab/issue_templates/QA - Desktop.md create mode 100644 .gitlab/issue_templates/Uplift.md create mode 100644 .gitlab/issue_templates/bug.md create mode 100644 .gitlab/merge_request_templates/Rebase.md create mode 100644 .gitlab/merge_request_templates/default.md diff --git a/.gitlab/issue_templates/Backport.md b/.gitlab/issue_templates/Backport.md new file mode 100644 index 000000000000..f6d6ab34a7cd --- /dev/null +++ b/.gitlab/issue_templates/Backport.md @@ -0,0 +1,31 @@ + + +## Backport Patchset + +### Book-keeping + +#### Issue(s) +- tor-browser#12345 +- mullvad-browser#123 +- https://bugzilla.mozilla.org/show_bug.cgi?id=1234567 + +#### Merge Request(s) +- tor-browser!123 + +#### Target Channels + +- [ ] Alpha +- [ ] Stable +- [ ] Legacy + +### Notes + + + +/label ~"Apps::Type::Backport" diff --git a/.gitlab/issue_templates/Emergency Security Issue.md b/.gitlab/issue_templates/Emergency Security Issue.md new file mode 100644 index 000000000000..33e6a1d7452a --- /dev/null +++ b/.gitlab/issue_templates/Emergency Security Issue.md @@ -0,0 +1,90 @@ +**NOTE** This is an issue template to standardise our process for responding to and fixing critical security and privacy vulnerabilities, exploits, etc. + +## Information + +### Related Issue +- tor-browser#AAAAA +- mullvad-browser#BBBBB +- tor-browser-build#CCCCC + +#### Affected Platforms + +- [ ] Android +- [ ] Desktop + - [ ] Windows + - [ ] macOS + - [ ] Linux + +### Type of Issue: What are we dealing with? + +- [ ] Security (sandbox escape, remote code execution, etc) +- [ ] Proxy Bypass (traffic contents becoming MITM'able) +- [ ] De-Anonymization (otherwise identifying which website a user is visiting) +- [ ] Cross-Site Linkability (correlating sessions across circuits and websites) +- [ ] Disk Leak (persisting session information to disk) +- [ ] Other (please explain) + +### Involvement: Who needs to be consulted and or involved to fix this? + +- [ ] Applications Developers + - [ ] **boklm** : build, packaging, signing, release + - [ ] **clairehurst** : Android, macOS + - [ ] **dan** : Android, macOS + - [ ] **henry** : accessibility, frontend, localisation + - [ ] **ma1** : firefox internals + - [ ] **pierov** : updater, fonts, localisation, general + - [ ] **richard** : signing, release + - [ ] **thorin** : fingerprinting +- [ ] Other Engineering Teams + - [ ] Networking (**ahf**, **dgoulet**) + - [ ] Anti-Censorship (**meskio**, **cohosh**) + - [ ] UX (**donuts**) + - [ ] TPA (**anarcat**, **lavamind**) +- [ ] External Tor Partners + - [ ] Mozilla + - [ ] Mullvad + - [ ] Brave + - [ ] Guardian Project (Orbot, Onion Browser) + - [ ] Tails + - [ ] Other (please list) + +### Urgency: When do we need to act? + +- [ ] **ASAP** :rotating_light: Emergency release :rotating_light: +- [ ] Next scheduled stable +- [ ] Next scheduled alpha, then backport to stable +- [ ] Next major release +- [ ] Other (please explain) + +#### Justification + + + +### Side-Effects: Who will be affected by a fix for this? +Sometimes fixes have side-effects: users lose their data, roadmaps need to be adjusted, services have to be upgraded, etc. Please enumerate the known downstream consequences a fix to this issue will likely incur. +- [ ] End-Users (please list) +- [ ] Internal Partners (please list) +- [ ] External Partners (please list) + +## Todo: + +### Communications + +- [ ] Start an initial email thread with the following people: + - [ ] **bella** + - [ ] Relevant Applications Developers + - [ ] **(Optional)** **micah** + - if there are considerations or asks outside the Applications Team + - [ ] **(Optional)** Other Team Leads + - if there are considerations or asks outside the Applications Team + - [ ] **(Optional)** **gazebook** + - if there are consequences to the organisation or partners beyond a browser update, then a communication plan may be needed + +/cc @bella +/cc @ma1 +/cc @micah +/cc @richard + +/confidential + +Godspeed! :pray: diff --git a/.gitlab/issue_templates/QA - Android.md b/.gitlab/issue_templates/QA - Android.md new file mode 100644 index 000000000000..3acc5a06dd54 --- /dev/null +++ b/.gitlab/issue_templates/QA - Android.md @@ -0,0 +1,71 @@ +Manual QA test check-list for major android releases. Please copy/paste form into your own comment, fill out relevant info and run through the checklist! +
+ Tor Browser Android QA Checklist +```markdown +# System Information + +- Version: Tor Browser XXX +- OS: Android YYY +- Device + CPU Architecture: ZZZ + +# Features + +## Base functionality +- [ ] Tor Browser launches successfully +- [ ] Connects to the Tor network +- [ ] Localisation (Browser chrome) + - [ ] Check especially the recently added strings +- [ ] Toolbars and menus work +- [ ] Fingerprinting resistance: https://arkenfox.github.io/TZP/tzp.html +- [ ] Security level (Standard, Safer, Safest) + - **TODO**: test pages verifying correct behaviour + +## Proxy safety +- [ ] Tor exit test: https://check.torproject.org +- [ ] Circuit isolation + - Following websites should all report different IP addresses + - https://ifconfig.io + - https://myip.wtf + - https://wtfismyip.com +- [ ] DNS leaks: https://dnsleaktest.com + +## Connectivity + Anti-Censorship +- [ ] Bridges: + - Bootstrap + - Browse: https://check.torproject.org + - [ ] Default bridges: + - [ ] obfs4 + - [ ] meek + - [ ] snowflake + - [ ] User provided bridges: + - [ ] obfs4 from https://bridges.torproject.org + - [ ] webtunnel from https://bridges.torproject.org + - [ ] conjure from [gitlab](https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/conjure/-/blob/main/client/torrc?ref_type=heads#L6) + +## Web Browsing +- [ ] HTTPS-Only: http://http.badssl.com +- [ ] .onion: + - [ ] torproject.org onion: http://2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion/ + - [ ] Onion service errors + - [ ] invalid onion: http://invalid.onion + - [ ] onion offline: http://wfdn32ds656ycma5gvrh7duvdvxbg2ygzr3no3ijsya25qm6nnko4iqd.onion/ + - [ ] onion baddssl: https://gitlab.torproject.org/tpo/applications/team/-/wikis/Development-Information/BadSSL-But-Onion + - **TODO** all the identity block states + - **TODO** client auth +- [ ] **TODO**: .securedrop.tor.onion +- [ ] **TODO**: onion-service alt-svc +- [ ] HTML5 Video: https://tekeye.uk/html/html5-video-test-page + - [ ] MPEG4 + - [ ] WebM + - [ ] Ogg +- [ ] WebSocket Test: https://websocketking.com/ + +## External Components +- [ ] NoScript + - [ ] Latest Version: https://addons.mozilla.org/en-US/firefox/addon/noscript/ + - [ ] Not removable from about:addons + - [ ] Tests: https://test-data.tbb.torproject.org/test-data/noscript/ + - **TODO**: fix test pages +``` + +
diff --git a/.gitlab/issue_templates/QA - Desktop.md b/.gitlab/issue_templates/QA - Desktop.md new file mode 100644 index 000000000000..78ad8c43ec61 --- /dev/null +++ b/.gitlab/issue_templates/QA - Desktop.md @@ -0,0 +1,164 @@ +Manual QA test check-list for major desktop releases. Please copy/paste form into your own comment, fill out relevant info and run through the checklist! + +
+ Tor Browser Desktop QA Checklist + +```markdown +# System Information + +- Version: Tor Browser XXX +- OS: Windows|macOS|Linux YYY +- CPU Architecture: +- Profile: New|Old + +# Features + +## Base functionality +- [ ] Tor Browser launches successfully +- [ ] Connects to the Tor network + - [ ] Homepage loads: + - [ ] about:tor + - [ ] about:blank + - [ ] custom +- [ ] Tor Browser loads URLs passed by command-line after bootstrapped +- [ ] Localisation (Browser chrome) + - [ ] Language notification/message bar + - [ ] Spoof English + - [ ] Check especially the recently added strings +- [ ] UI Customisations: + - [ ] New Identity + - [ ] Toolbar icon + - [ ] Hamburger menu + - [ ] File menu + - [ ] New circuit for this site + - [ ] Circuit display + - [ ] Hamburger menu + - [ ] File menu + - [ ] No Firefox extras (Sync, Pocket, Report broken site, Tracking protection, etc) + - [ ] No unified extensions button (puzzle piece) + - [ ] NoScript button hidden + - [ ] Context Menu Populated +- [ ] Fingerprinting resistance: https://arkenfox.github.io/TZP/tzp.html +- [ ] Security level (Standard, Safer, Safest) + - Displays in: + - toolbar icon + - toolbar panel + - about:preferences#privacy + - [ ] On switch, each UI element is updated + - [ ] On custom config (toggle `svg.disabled`) + - [ ] each UI element displays warning + - [ ] `Restore defaults` reverts custom prefs + - **TODO**: test pages verifying correct behaviour +- [ ] New identity +- [ ] Betterboxing + - [ ] Reuse last window size + - [ ] Content alignment + - [ ] No letterboxing: + - [ ]empty tabs or privileged pages (eg: about:blank, about:about) + - [ ] full-screen video + - [ ] pdf viewer + - [ ] reader-mode +- [ ] Downloads Warning + - [ ] Downloads toolbar panel + - [ ] about:downloads + - [ ] Library window (Ctrl+Shift+o) +- [ ] Drag and Drop protections: + - [ ] Dragging a link from a tab to another tab in the same window works + - [ ] Dragging a link from a tab to another tab in a separate window works + - [ ] Dragging a link into the library creates a bookmark + - [ ] Dragging a link from Tor Browser to Firefox doesn't work + - [ ] Dragging a link from Firefox to Tor Browser works + - [ ] Dragging a link from Tor Browser to another app (e.g., text editor) doesn't work + - [ ] Repeat with page favicon + +## Proxy safety +- [ ] Tor exit test: https://check.torproject.org +- [ ] Circuit isolation + - Following websites should all report different IP addresses + - https://ifconfig.io + - https://myip.wtf + - https://wtfismyip.com +- [ ] DNS leaks: https://dnsleaktest.com +- [ ] Circuit Display + - [ ] Website => circuit + - [ ] Remote PDF => circuit + - [ ] Remote image => circuit + - [ ] .onion Website => circuit with onion-service relays + - [ ] .tor.onion Website => circuit with onion-service relays, link to true onion address + - http://ft.securedrop.tor.onion + - [ ] Website in reader mode => circuit (same as w/o reader mode) + - [ ] Local image => no circuit + - [ ] Local SVG with remote content => catch-all circuit, but not shown + - [ ] Local PDF => no circuit + - [ ] Local HTML `file://` with local resources => no circuit + - [ ] Local HTML `file://` with remote resources => catch-all circuit, but not shown + +## Connectivity + Anti-Censorship +- [ ] Tor daemon config by environment variables + - https://gitlab.torproject.org/tpo/applications/team/-/wikis/Environment-variables-and-related-preferences +- [ ] Internet Test ( about:preferences#connection ) + - [ ] Fails when offline + - [ ] Succeeds when online +- [ ] Bridges: + - Bootstrap + - Browse: https://check.torproject.org + - Bridge node in circuit-display + - Bridge cards + - Disable + - Remove + - [ ] Default bridges: + - [ ] Removable as a group, not editable + - [ ] obfs4 + - [ ] meek + - [ ] snowflake + - [ ] User provided bridges: + - [ ] Removable and editable individually + - [ ] obfs4 from https://bridges.torproject.org + - [ ] webtunnel from https://bridges.torproject.org + - [ ] conjure from [gitlab](https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/conjure/-/blob/main/client/torrc?ref_type=heads#L6) + - [ ] Request bridges... + - [ ] Removable as a group, but not editable + - [ ] Succeeds when bootstrapped + - [ ] Succeeds when not bootstrapped + - **TODO**: Lox +- [ ] Connect Assist + - Useful pref: `torbrowser.debug.censorship_level` + - [ ] Auto-bootstrap updates Tor connection settings on success + - [ ] Auto-bootstrap restore previous Tor connection settings on failure + +## Web Browsing +- [ ] HTTPS-Only: http://http.badssl.com +- [ ] Crypto-currency warning on http website + - **TODO**: we should provide an example page +- [ ] .onion: + - [ ] torproject.org onion: http://2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion/ + - [ ] Onion-Location pill + - [ ] Client authentication + - You can create an ephemeral client-auth onion-service using [onion share](https://onionshare.org) + - [ ] Remember key option saves the key between sessions. + - [ ] Saved keys are viewable in preferences (privacy). + - [ ] Can remove individual keys. + - [ ] Can remove all keys at once. + - [ ] Onion service errors + - [ ] invalid onion: http://invalid.onion + - [ ] onion offline: http://wfdn32ds656ycma5gvrh7duvdvxbg2ygzr3no3ijsya25qm6nnko4iqd.onion/ + - [ ] onion baddssl: https://gitlab.torproject.org/tpo/applications/team/-/wikis/Development-Information/BadSSL-But-Onion + - **TODO** all the identity block states + - **TODO** client auth +- [ ] **TODO**: .securedrop.tor.onion +- [ ] **TODO**: onion-service alt-svc +- [ ] HTML5 Video: https://tekeye.uk/html/html5-video-test-page + - [ ] MPEG4 + - [ ] WebM + - [ ] Ogg +- [ ] WebSocket Test: https://websocketking.com/ + +## External Components +- [ ] NoScript + - [ ] Latest Version: https://addons.mozilla.org/en-US/firefox/addon/noscript/ + - [ ] Not removable from about:addons + - [ ] Tests: https://test-data.tbb.torproject.org/test-data/noscript/ + - **TODO**: fix test pages +``` + +
diff --git a/.gitlab/issue_templates/Uplift.md b/.gitlab/issue_templates/Uplift.md new file mode 100644 index 000000000000..c810a2049889 --- /dev/null +++ b/.gitlab/issue_templates/Uplift.md @@ -0,0 +1,26 @@ + + +## Uplift Patchset + +### Book-keeping + +#### Gitlab Issue(s) +- tor-browser#12345 +- mullvad-browser#123 + +#### Merge Request(s) +- tor-browser!123 + +#### Upstream Mozilla Issue(s): +- https://bugzilla.mozilla.org/show_bug.cgi?id=12345 + +### Notes + + + +/label ~"Apps::Type::Uplift" diff --git a/.gitlab/issue_templates/bug.md b/.gitlab/issue_templates/bug.md new file mode 100644 index 000000000000..257bb00aba3c --- /dev/null +++ b/.gitlab/issue_templates/bug.md @@ -0,0 +1,32 @@ + + +### Summary +**Summarize the bug encountered concisely.** + + +### Steps to reproduce: +**How one can reproduce the issue - this is very important.** + +1. Step 1 +2. Step 2 +3. ... + +### What is the current bug behavior? +**What actually happens.** + + +### What is the expected behavior? +**What you want to see instead** + + + +### Environment +**Which operating system are you using? For example: Debian GNU/Linux 10.1, Windows 10, Ubuntu Xenial, FreeBSD 12.2, etc.** +**Which installation method did you use? Distribution package (apt, pkg, homebrew), from source tarball, from Git, etc.** + +### Relevant logs and/or screenshots + + +/label ~"Apps::Type::Bug" diff --git a/.gitlab/merge_request_templates/Rebase.md b/.gitlab/merge_request_templates/Rebase.md new file mode 100644 index 000000000000..c8269618e782 --- /dev/null +++ b/.gitlab/merge_request_templates/Rebase.md @@ -0,0 +1,23 @@ +## Merge Info + + + +### Rebase Issue +- tor-browser#xxxxx +- mullvad-browser#xxxxx + +### Release Prep Issue +- tor-browser-build#xxxxx + +### Issue Tracking +- [ ] Link rebase issue with appropriate [Release Prep issue](https://gitlab.torproject.org/groups/tpo/applications/-/issues/?sort=updated_desc&state=opened&label_name%5B%5D=Apps%3A%3AType%3A%3AReleasePreparation&first_page_size=20) for changelog generation + +### Review + +#### Request Reviewer + +- [ ] Request review from a release engineer: boklm, dan, ma1, morgan, pierov + +#### Change Description + + diff --git a/.gitlab/merge_request_templates/default.md b/.gitlab/merge_request_templates/default.md new file mode 100644 index 000000000000..59c283fb3730 --- /dev/null +++ b/.gitlab/merge_request_templates/default.md @@ -0,0 +1,91 @@ +## Merge Info + + + +### Issues + +#### Resolves +- tor-browser#xxxxx +- mullvad-browser#xxxxx +- tor-browser-build#xxxxx + +#### Related + +- tor-browser#xxxxx +- mullvad-browser#xxxxx +- tor-browser-build#xxxxx + +### Merging + + + +#### Target Branches + +- [ ] **`tor-browser`** - `!fixups` to `tor-browser`-specific commits, new features, security backports +- [ ] **`base-browser`** *and* **`mullvad-browser`** - `!fixups` to `base-browser`-specific commits, new features to be shared with `mullvad-browser`, and security backports + - ⚠️ **IMPORTANT**: Please list the `base-browser`-specific commits which need to be cherry-picked to the `base-browser` and `mullvad-browser` branches here + +#### Target Channels + +- [ ] **Alpha**: esr128-14.5 +- [ ] **Stable**: esr128-14.0 +- [ ] **Legacy**: esr115-13.5 + +### Backporting + +#### Timeline +- [ ] **No Backport (preferred)**: patchset for the next major stable +- [ ] **Immediate**: patchset needed as soon as possible (fixes CVEs, 0-days, etc) +- [ ] **Next Minor Stable Release**: patchset that needs to be verified in nightly before backport +- [ ] **Eventually**: patchset that needs to be verified in alpha before backport + +#### (Optional) Justification +- [ ] **Security update**: patchset contains a security fix (be sure to select the correct item in _Timeline_) +- [ ] **Censorship event**: patchset enables censorship circumvention +- [ ] **Critical bug-fix**: patchset fixes a bug in core-functionality +- [ ] **Consistency**: patchset which would make development easier if it were in both the alpha and release branches; developer tools, build system changes, etc +- [ ] **Sponsor required**: patchset required for sponsor +- [ ] **Localization**: typos and other localization changes that should be also in the release branch +- [ ] **Other**: please explain + +### Upstream +- [ ] Patchset is a candidate for uplift to Firefox +- [ ] Patchset is a backport from Firefox + - Bugzilla link: + - Upstream commit: + +### Issue Tracking +- [ ] Link resolved issues with appropriate [Release Prep issue](https://gitlab.torproject.org/groups/tpo/applications/-/issues/?sort=updated_desc&state=opened&label_name%5B%5D=Apps%3A%3AType%3A%3AReleasePreparation&first_page_size=100) for changelog generation + +### Review + +#### Request Reviewer + +- [ ] Request review from an applications developer depending on modified system: + - **NOTE**: if the MR modifies multiple areas, please `/cc` all the relevant reviewers (since Gitlab only allows 1 reviewer) + - **accessibility** : henry + - **android** : clairehurst, dan + - **build system** : boklm + - **extensions** : ma1 + - **firefox internals (XUL/JS/XPCOM)** : jwilde, ma1 + - **fonts** : pierov + - **frontend (implementation)** : henry + - **frontend (review)** : donuts, morgan + - **localization** : henry, pierov + - **macOS** : clairehurst, dan + - **nightly builds** : boklm + - **rebases/release-prep** : dan, ma1, pierov, morgan + - **security** : jwilde, ma1 + - **signing** : boklm, morgan + - **updater** : pierov + - **windows** : jwilde, morgan + - **misc/other** : pierov, morgan + +#### Change Description + + + + +#### How Tested + + -- GitLab From d0609239e358a2e3cfaa1a30c99a98e016f901c2 Mon Sep 17 00:00:00 2001 From: Morgan Date: Thu, 3 Apr 2025 12:22:07 +0000 Subject: [PATCH 022/250] fixup! Adding issue and merge request templates revert --- .gitlab/issue_templates/Backport.md | 31 ---- .../Emergency Security Issue.md | 90 ---------- .gitlab/issue_templates/QA - Android.md | 71 -------- .gitlab/issue_templates/QA - Desktop.md | 164 ------------------ .gitlab/issue_templates/Uplift.md | 26 --- .gitlab/issue_templates/bug.md | 32 ---- .gitlab/merge_request_templates/Rebase.md | 23 --- .gitlab/merge_request_templates/default.md | 91 ---------- 8 files changed, 528 deletions(-) delete mode 100644 .gitlab/issue_templates/Backport.md delete mode 100644 .gitlab/issue_templates/Emergency Security Issue.md delete mode 100644 .gitlab/issue_templates/QA - Android.md delete mode 100644 .gitlab/issue_templates/QA - Desktop.md delete mode 100644 .gitlab/issue_templates/Uplift.md delete mode 100644 .gitlab/issue_templates/bug.md delete mode 100644 .gitlab/merge_request_templates/Rebase.md delete mode 100644 .gitlab/merge_request_templates/default.md diff --git a/.gitlab/issue_templates/Backport.md b/.gitlab/issue_templates/Backport.md deleted file mode 100644 index f6d6ab34a7cd..000000000000 --- a/.gitlab/issue_templates/Backport.md +++ /dev/null @@ -1,31 +0,0 @@ - - -## Backport Patchset - -### Book-keeping - -#### Issue(s) -- tor-browser#12345 -- mullvad-browser#123 -- https://bugzilla.mozilla.org/show_bug.cgi?id=1234567 - -#### Merge Request(s) -- tor-browser!123 - -#### Target Channels - -- [ ] Alpha -- [ ] Stable -- [ ] Legacy - -### Notes - - - -/label ~"Apps::Type::Backport" diff --git a/.gitlab/issue_templates/Emergency Security Issue.md b/.gitlab/issue_templates/Emergency Security Issue.md deleted file mode 100644 index 33e6a1d7452a..000000000000 --- a/.gitlab/issue_templates/Emergency Security Issue.md +++ /dev/null @@ -1,90 +0,0 @@ -**NOTE** This is an issue template to standardise our process for responding to and fixing critical security and privacy vulnerabilities, exploits, etc. - -## Information - -### Related Issue -- tor-browser#AAAAA -- mullvad-browser#BBBBB -- tor-browser-build#CCCCC - -#### Affected Platforms - -- [ ] Android -- [ ] Desktop - - [ ] Windows - - [ ] macOS - - [ ] Linux - -### Type of Issue: What are we dealing with? - -- [ ] Security (sandbox escape, remote code execution, etc) -- [ ] Proxy Bypass (traffic contents becoming MITM'able) -- [ ] De-Anonymization (otherwise identifying which website a user is visiting) -- [ ] Cross-Site Linkability (correlating sessions across circuits and websites) -- [ ] Disk Leak (persisting session information to disk) -- [ ] Other (please explain) - -### Involvement: Who needs to be consulted and or involved to fix this? - -- [ ] Applications Developers - - [ ] **boklm** : build, packaging, signing, release - - [ ] **clairehurst** : Android, macOS - - [ ] **dan** : Android, macOS - - [ ] **henry** : accessibility, frontend, localisation - - [ ] **ma1** : firefox internals - - [ ] **pierov** : updater, fonts, localisation, general - - [ ] **richard** : signing, release - - [ ] **thorin** : fingerprinting -- [ ] Other Engineering Teams - - [ ] Networking (**ahf**, **dgoulet**) - - [ ] Anti-Censorship (**meskio**, **cohosh**) - - [ ] UX (**donuts**) - - [ ] TPA (**anarcat**, **lavamind**) -- [ ] External Tor Partners - - [ ] Mozilla - - [ ] Mullvad - - [ ] Brave - - [ ] Guardian Project (Orbot, Onion Browser) - - [ ] Tails - - [ ] Other (please list) - -### Urgency: When do we need to act? - -- [ ] **ASAP** :rotating_light: Emergency release :rotating_light: -- [ ] Next scheduled stable -- [ ] Next scheduled alpha, then backport to stable -- [ ] Next major release -- [ ] Other (please explain) - -#### Justification - - - -### Side-Effects: Who will be affected by a fix for this? -Sometimes fixes have side-effects: users lose their data, roadmaps need to be adjusted, services have to be upgraded, etc. Please enumerate the known downstream consequences a fix to this issue will likely incur. -- [ ] End-Users (please list) -- [ ] Internal Partners (please list) -- [ ] External Partners (please list) - -## Todo: - -### Communications - -- [ ] Start an initial email thread with the following people: - - [ ] **bella** - - [ ] Relevant Applications Developers - - [ ] **(Optional)** **micah** - - if there are considerations or asks outside the Applications Team - - [ ] **(Optional)** Other Team Leads - - if there are considerations or asks outside the Applications Team - - [ ] **(Optional)** **gazebook** - - if there are consequences to the organisation or partners beyond a browser update, then a communication plan may be needed - -/cc @bella -/cc @ma1 -/cc @micah -/cc @richard - -/confidential - -Godspeed! :pray: diff --git a/.gitlab/issue_templates/QA - Android.md b/.gitlab/issue_templates/QA - Android.md deleted file mode 100644 index 3acc5a06dd54..000000000000 --- a/.gitlab/issue_templates/QA - Android.md +++ /dev/null @@ -1,71 +0,0 @@ -Manual QA test check-list for major android releases. Please copy/paste form into your own comment, fill out relevant info and run through the checklist! -
- Tor Browser Android QA Checklist -```markdown -# System Information - -- Version: Tor Browser XXX -- OS: Android YYY -- Device + CPU Architecture: ZZZ - -# Features - -## Base functionality -- [ ] Tor Browser launches successfully -- [ ] Connects to the Tor network -- [ ] Localisation (Browser chrome) - - [ ] Check especially the recently added strings -- [ ] Toolbars and menus work -- [ ] Fingerprinting resistance: https://arkenfox.github.io/TZP/tzp.html -- [ ] Security level (Standard, Safer, Safest) - - **TODO**: test pages verifying correct behaviour - -## Proxy safety -- [ ] Tor exit test: https://check.torproject.org -- [ ] Circuit isolation - - Following websites should all report different IP addresses - - https://ifconfig.io - - https://myip.wtf - - https://wtfismyip.com -- [ ] DNS leaks: https://dnsleaktest.com - -## Connectivity + Anti-Censorship -- [ ] Bridges: - - Bootstrap - - Browse: https://check.torproject.org - - [ ] Default bridges: - - [ ] obfs4 - - [ ] meek - - [ ] snowflake - - [ ] User provided bridges: - - [ ] obfs4 from https://bridges.torproject.org - - [ ] webtunnel from https://bridges.torproject.org - - [ ] conjure from [gitlab](https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/conjure/-/blob/main/client/torrc?ref_type=heads#L6) - -## Web Browsing -- [ ] HTTPS-Only: http://http.badssl.com -- [ ] .onion: - - [ ] torproject.org onion: http://2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion/ - - [ ] Onion service errors - - [ ] invalid onion: http://invalid.onion - - [ ] onion offline: http://wfdn32ds656ycma5gvrh7duvdvxbg2ygzr3no3ijsya25qm6nnko4iqd.onion/ - - [ ] onion baddssl: https://gitlab.torproject.org/tpo/applications/team/-/wikis/Development-Information/BadSSL-But-Onion - - **TODO** all the identity block states - - **TODO** client auth -- [ ] **TODO**: .securedrop.tor.onion -- [ ] **TODO**: onion-service alt-svc -- [ ] HTML5 Video: https://tekeye.uk/html/html5-video-test-page - - [ ] MPEG4 - - [ ] WebM - - [ ] Ogg -- [ ] WebSocket Test: https://websocketking.com/ - -## External Components -- [ ] NoScript - - [ ] Latest Version: https://addons.mozilla.org/en-US/firefox/addon/noscript/ - - [ ] Not removable from about:addons - - [ ] Tests: https://test-data.tbb.torproject.org/test-data/noscript/ - - **TODO**: fix test pages -``` - -
diff --git a/.gitlab/issue_templates/QA - Desktop.md b/.gitlab/issue_templates/QA - Desktop.md deleted file mode 100644 index 78ad8c43ec61..000000000000 --- a/.gitlab/issue_templates/QA - Desktop.md +++ /dev/null @@ -1,164 +0,0 @@ -Manual QA test check-list for major desktop releases. Please copy/paste form into your own comment, fill out relevant info and run through the checklist! - -
- Tor Browser Desktop QA Checklist - -```markdown -# System Information - -- Version: Tor Browser XXX -- OS: Windows|macOS|Linux YYY -- CPU Architecture: -- Profile: New|Old - -# Features - -## Base functionality -- [ ] Tor Browser launches successfully -- [ ] Connects to the Tor network - - [ ] Homepage loads: - - [ ] about:tor - - [ ] about:blank - - [ ] custom -- [ ] Tor Browser loads URLs passed by command-line after bootstrapped -- [ ] Localisation (Browser chrome) - - [ ] Language notification/message bar - - [ ] Spoof English - - [ ] Check especially the recently added strings -- [ ] UI Customisations: - - [ ] New Identity - - [ ] Toolbar icon - - [ ] Hamburger menu - - [ ] File menu - - [ ] New circuit for this site - - [ ] Circuit display - - [ ] Hamburger menu - - [ ] File menu - - [ ] No Firefox extras (Sync, Pocket, Report broken site, Tracking protection, etc) - - [ ] No unified extensions button (puzzle piece) - - [ ] NoScript button hidden - - [ ] Context Menu Populated -- [ ] Fingerprinting resistance: https://arkenfox.github.io/TZP/tzp.html -- [ ] Security level (Standard, Safer, Safest) - - Displays in: - - toolbar icon - - toolbar panel - - about:preferences#privacy - - [ ] On switch, each UI element is updated - - [ ] On custom config (toggle `svg.disabled`) - - [ ] each UI element displays warning - - [ ] `Restore defaults` reverts custom prefs - - **TODO**: test pages verifying correct behaviour -- [ ] New identity -- [ ] Betterboxing - - [ ] Reuse last window size - - [ ] Content alignment - - [ ] No letterboxing: - - [ ]empty tabs or privileged pages (eg: about:blank, about:about) - - [ ] full-screen video - - [ ] pdf viewer - - [ ] reader-mode -- [ ] Downloads Warning - - [ ] Downloads toolbar panel - - [ ] about:downloads - - [ ] Library window (Ctrl+Shift+o) -- [ ] Drag and Drop protections: - - [ ] Dragging a link from a tab to another tab in the same window works - - [ ] Dragging a link from a tab to another tab in a separate window works - - [ ] Dragging a link into the library creates a bookmark - - [ ] Dragging a link from Tor Browser to Firefox doesn't work - - [ ] Dragging a link from Firefox to Tor Browser works - - [ ] Dragging a link from Tor Browser to another app (e.g., text editor) doesn't work - - [ ] Repeat with page favicon - -## Proxy safety -- [ ] Tor exit test: https://check.torproject.org -- [ ] Circuit isolation - - Following websites should all report different IP addresses - - https://ifconfig.io - - https://myip.wtf - - https://wtfismyip.com -- [ ] DNS leaks: https://dnsleaktest.com -- [ ] Circuit Display - - [ ] Website => circuit - - [ ] Remote PDF => circuit - - [ ] Remote image => circuit - - [ ] .onion Website => circuit with onion-service relays - - [ ] .tor.onion Website => circuit with onion-service relays, link to true onion address - - http://ft.securedrop.tor.onion - - [ ] Website in reader mode => circuit (same as w/o reader mode) - - [ ] Local image => no circuit - - [ ] Local SVG with remote content => catch-all circuit, but not shown - - [ ] Local PDF => no circuit - - [ ] Local HTML `file://` with local resources => no circuit - - [ ] Local HTML `file://` with remote resources => catch-all circuit, but not shown - -## Connectivity + Anti-Censorship -- [ ] Tor daemon config by environment variables - - https://gitlab.torproject.org/tpo/applications/team/-/wikis/Environment-variables-and-related-preferences -- [ ] Internet Test ( about:preferences#connection ) - - [ ] Fails when offline - - [ ] Succeeds when online -- [ ] Bridges: - - Bootstrap - - Browse: https://check.torproject.org - - Bridge node in circuit-display - - Bridge cards - - Disable - - Remove - - [ ] Default bridges: - - [ ] Removable as a group, not editable - - [ ] obfs4 - - [ ] meek - - [ ] snowflake - - [ ] User provided bridges: - - [ ] Removable and editable individually - - [ ] obfs4 from https://bridges.torproject.org - - [ ] webtunnel from https://bridges.torproject.org - - [ ] conjure from [gitlab](https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/conjure/-/blob/main/client/torrc?ref_type=heads#L6) - - [ ] Request bridges... - - [ ] Removable as a group, but not editable - - [ ] Succeeds when bootstrapped - - [ ] Succeeds when not bootstrapped - - **TODO**: Lox -- [ ] Connect Assist - - Useful pref: `torbrowser.debug.censorship_level` - - [ ] Auto-bootstrap updates Tor connection settings on success - - [ ] Auto-bootstrap restore previous Tor connection settings on failure - -## Web Browsing -- [ ] HTTPS-Only: http://http.badssl.com -- [ ] Crypto-currency warning on http website - - **TODO**: we should provide an example page -- [ ] .onion: - - [ ] torproject.org onion: http://2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion/ - - [ ] Onion-Location pill - - [ ] Client authentication - - You can create an ephemeral client-auth onion-service using [onion share](https://onionshare.org) - - [ ] Remember key option saves the key between sessions. - - [ ] Saved keys are viewable in preferences (privacy). - - [ ] Can remove individual keys. - - [ ] Can remove all keys at once. - - [ ] Onion service errors - - [ ] invalid onion: http://invalid.onion - - [ ] onion offline: http://wfdn32ds656ycma5gvrh7duvdvxbg2ygzr3no3ijsya25qm6nnko4iqd.onion/ - - [ ] onion baddssl: https://gitlab.torproject.org/tpo/applications/team/-/wikis/Development-Information/BadSSL-But-Onion - - **TODO** all the identity block states - - **TODO** client auth -- [ ] **TODO**: .securedrop.tor.onion -- [ ] **TODO**: onion-service alt-svc -- [ ] HTML5 Video: https://tekeye.uk/html/html5-video-test-page - - [ ] MPEG4 - - [ ] WebM - - [ ] Ogg -- [ ] WebSocket Test: https://websocketking.com/ - -## External Components -- [ ] NoScript - - [ ] Latest Version: https://addons.mozilla.org/en-US/firefox/addon/noscript/ - - [ ] Not removable from about:addons - - [ ] Tests: https://test-data.tbb.torproject.org/test-data/noscript/ - - **TODO**: fix test pages -``` - -
diff --git a/.gitlab/issue_templates/Uplift.md b/.gitlab/issue_templates/Uplift.md deleted file mode 100644 index c810a2049889..000000000000 --- a/.gitlab/issue_templates/Uplift.md +++ /dev/null @@ -1,26 +0,0 @@ - - -## Uplift Patchset - -### Book-keeping - -#### Gitlab Issue(s) -- tor-browser#12345 -- mullvad-browser#123 - -#### Merge Request(s) -- tor-browser!123 - -#### Upstream Mozilla Issue(s): -- https://bugzilla.mozilla.org/show_bug.cgi?id=12345 - -### Notes - - - -/label ~"Apps::Type::Uplift" diff --git a/.gitlab/issue_templates/bug.md b/.gitlab/issue_templates/bug.md deleted file mode 100644 index 257bb00aba3c..000000000000 --- a/.gitlab/issue_templates/bug.md +++ /dev/null @@ -1,32 +0,0 @@ - - -### Summary -**Summarize the bug encountered concisely.** - - -### Steps to reproduce: -**How one can reproduce the issue - this is very important.** - -1. Step 1 -2. Step 2 -3. ... - -### What is the current bug behavior? -**What actually happens.** - - -### What is the expected behavior? -**What you want to see instead** - - - -### Environment -**Which operating system are you using? For example: Debian GNU/Linux 10.1, Windows 10, Ubuntu Xenial, FreeBSD 12.2, etc.** -**Which installation method did you use? Distribution package (apt, pkg, homebrew), from source tarball, from Git, etc.** - -### Relevant logs and/or screenshots - - -/label ~"Apps::Type::Bug" diff --git a/.gitlab/merge_request_templates/Rebase.md b/.gitlab/merge_request_templates/Rebase.md deleted file mode 100644 index c8269618e782..000000000000 --- a/.gitlab/merge_request_templates/Rebase.md +++ /dev/null @@ -1,23 +0,0 @@ -## Merge Info - - - -### Rebase Issue -- tor-browser#xxxxx -- mullvad-browser#xxxxx - -### Release Prep Issue -- tor-browser-build#xxxxx - -### Issue Tracking -- [ ] Link rebase issue with appropriate [Release Prep issue](https://gitlab.torproject.org/groups/tpo/applications/-/issues/?sort=updated_desc&state=opened&label_name%5B%5D=Apps%3A%3AType%3A%3AReleasePreparation&first_page_size=20) for changelog generation - -### Review - -#### Request Reviewer - -- [ ] Request review from a release engineer: boklm, dan, ma1, morgan, pierov - -#### Change Description - - diff --git a/.gitlab/merge_request_templates/default.md b/.gitlab/merge_request_templates/default.md deleted file mode 100644 index 59c283fb3730..000000000000 --- a/.gitlab/merge_request_templates/default.md +++ /dev/null @@ -1,91 +0,0 @@ -## Merge Info - - - -### Issues - -#### Resolves -- tor-browser#xxxxx -- mullvad-browser#xxxxx -- tor-browser-build#xxxxx - -#### Related - -- tor-browser#xxxxx -- mullvad-browser#xxxxx -- tor-browser-build#xxxxx - -### Merging - - - -#### Target Branches - -- [ ] **`tor-browser`** - `!fixups` to `tor-browser`-specific commits, new features, security backports -- [ ] **`base-browser`** *and* **`mullvad-browser`** - `!fixups` to `base-browser`-specific commits, new features to be shared with `mullvad-browser`, and security backports - - ⚠️ **IMPORTANT**: Please list the `base-browser`-specific commits which need to be cherry-picked to the `base-browser` and `mullvad-browser` branches here - -#### Target Channels - -- [ ] **Alpha**: esr128-14.5 -- [ ] **Stable**: esr128-14.0 -- [ ] **Legacy**: esr115-13.5 - -### Backporting - -#### Timeline -- [ ] **No Backport (preferred)**: patchset for the next major stable -- [ ] **Immediate**: patchset needed as soon as possible (fixes CVEs, 0-days, etc) -- [ ] **Next Minor Stable Release**: patchset that needs to be verified in nightly before backport -- [ ] **Eventually**: patchset that needs to be verified in alpha before backport - -#### (Optional) Justification -- [ ] **Security update**: patchset contains a security fix (be sure to select the correct item in _Timeline_) -- [ ] **Censorship event**: patchset enables censorship circumvention -- [ ] **Critical bug-fix**: patchset fixes a bug in core-functionality -- [ ] **Consistency**: patchset which would make development easier if it were in both the alpha and release branches; developer tools, build system changes, etc -- [ ] **Sponsor required**: patchset required for sponsor -- [ ] **Localization**: typos and other localization changes that should be also in the release branch -- [ ] **Other**: please explain - -### Upstream -- [ ] Patchset is a candidate for uplift to Firefox -- [ ] Patchset is a backport from Firefox - - Bugzilla link: - - Upstream commit: - -### Issue Tracking -- [ ] Link resolved issues with appropriate [Release Prep issue](https://gitlab.torproject.org/groups/tpo/applications/-/issues/?sort=updated_desc&state=opened&label_name%5B%5D=Apps%3A%3AType%3A%3AReleasePreparation&first_page_size=100) for changelog generation - -### Review - -#### Request Reviewer - -- [ ] Request review from an applications developer depending on modified system: - - **NOTE**: if the MR modifies multiple areas, please `/cc` all the relevant reviewers (since Gitlab only allows 1 reviewer) - - **accessibility** : henry - - **android** : clairehurst, dan - - **build system** : boklm - - **extensions** : ma1 - - **firefox internals (XUL/JS/XPCOM)** : jwilde, ma1 - - **fonts** : pierov - - **frontend (implementation)** : henry - - **frontend (review)** : donuts, morgan - - **localization** : henry, pierov - - **macOS** : clairehurst, dan - - **nightly builds** : boklm - - **rebases/release-prep** : dan, ma1, pierov, morgan - - **security** : jwilde, ma1 - - **signing** : boklm, morgan - - **updater** : pierov - - **windows** : jwilde, morgan - - **misc/other** : pierov, morgan - -#### Change Description - - - - -#### How Tested - - -- GitLab From 8f8e1c59a8346b732b6ab2bdfba7ec9e83bf6fdc Mon Sep 17 00:00:00 2001 From: Morgan Date: Wed, 2 Apr 2025 18:45:22 +0000 Subject: [PATCH 023/250] BB 43615: Add Gitlab Issue and Merge Request templates --- .gitlab/issue_templates/000 Bug Report.md | 0 .gitlab/issue_templates/010 Proposal.md | 0 .../issue_templates/020 Web Compatibility.md | 0 .gitlab/issue_templates/030 Test.md | 0 .gitlab/issue_templates/040 Feature.md | 0 .gitlab/issue_templates/050 Backport.md | 31 ++ .gitlab/issue_templates/060 Rebase - Alpha.md | 155 ++++++++++ .../issue_templates/061 Rebase - Stable.md | 117 +++++++ .gitlab/issue_templates/063 Rebase - Rapid.md | 292 ++++++++++++++++++ .../090 Emergency Security Issue.md | 90 ++++++ .gitlab/issue_templates/Default.md | 19 ++ .gitlab/merge_request_templates/Default.md | 92 ++++++ 12 files changed, 796 insertions(+) create mode 100644 .gitlab/issue_templates/000 Bug Report.md create mode 100644 .gitlab/issue_templates/010 Proposal.md create mode 100644 .gitlab/issue_templates/020 Web Compatibility.md create mode 100644 .gitlab/issue_templates/030 Test.md create mode 100644 .gitlab/issue_templates/040 Feature.md create mode 100644 .gitlab/issue_templates/050 Backport.md create mode 100644 .gitlab/issue_templates/060 Rebase - Alpha.md create mode 100644 .gitlab/issue_templates/061 Rebase - Stable.md create mode 100644 .gitlab/issue_templates/063 Rebase - Rapid.md create mode 100644 .gitlab/issue_templates/090 Emergency Security Issue.md create mode 100644 .gitlab/issue_templates/Default.md create mode 100644 .gitlab/merge_request_templates/Default.md diff --git a/.gitlab/issue_templates/000 Bug Report.md b/.gitlab/issue_templates/000 Bug Report.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/.gitlab/issue_templates/010 Proposal.md b/.gitlab/issue_templates/010 Proposal.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/.gitlab/issue_templates/020 Web Compatibility.md b/.gitlab/issue_templates/020 Web Compatibility.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/.gitlab/issue_templates/030 Test.md b/.gitlab/issue_templates/030 Test.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/.gitlab/issue_templates/040 Feature.md b/.gitlab/issue_templates/040 Feature.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/.gitlab/issue_templates/050 Backport.md b/.gitlab/issue_templates/050 Backport.md new file mode 100644 index 000000000000..f6d6ab34a7cd --- /dev/null +++ b/.gitlab/issue_templates/050 Backport.md @@ -0,0 +1,31 @@ + + +## Backport Patchset + +### Book-keeping + +#### Issue(s) +- tor-browser#12345 +- mullvad-browser#123 +- https://bugzilla.mozilla.org/show_bug.cgi?id=1234567 + +#### Merge Request(s) +- tor-browser!123 + +#### Target Channels + +- [ ] Alpha +- [ ] Stable +- [ ] Legacy + +### Notes + + + +/label ~"Apps::Type::Backport" diff --git a/.gitlab/issue_templates/060 Rebase - Alpha.md b/.gitlab/issue_templates/060 Rebase - Alpha.md new file mode 100644 index 000000000000..2e6381bf827c --- /dev/null +++ b/.gitlab/issue_templates/060 Rebase - Alpha.md @@ -0,0 +1,155 @@ +**NOTE:** All examples in this template reference the rebase from 102.7.0esr to 102.8.0esr + +
+ Explanation of Variables + +- `$(ESR_VERSION)`: the Mozilla defined ESR version, used in various places for building tor-browser tags, labels, etc + - **Example**: `102.8.0` +- `$(ESR_TAG)`: the Mozilla defined hg (Mercurial) tag associated with `$(ESR_VERSION)` + - **Example**: `FIREFOX_102_8_0esr_RELEASE` +- `$(ESR_TAG_PREV)`: the Mozilla defined hg (Mercurial) tag associated with the previous ESR version when rebasing (ie, the ESR version we are rebasing from) + - **Example**: `FIREFOX_102_7_0esr_BUILD1` +- `$(BROWSER_MAJOR)`: the browser major version + - **Example**: `12` +- `$(BROWSER_MINOR)`: the browser minor version + - **Example**: either `0` or `5`; Alpha's is always `(Stable + 5) % 10` +- `$(BASE_BROWSER_BRANCH)`: the full name of the current `base-browser` branch + - **Example**: `base-browser-102.8.0esr-12.5-1` +- `$(BASE_BROWSER_BRANCH_PREV)`: the full name of the previous `base-browser` branch + - **Example**: `base-browser-102.7.0esr-12.5-1` +- `$(TOR_BROWSER_BRANCH)`: the full name of the current `tor-browser` branch + - **Example**: `tor-browser-102.8.0esr-12.5-1` +- `$(TOR_BROWSER_BRANCH_PREV)`: the full name of the previous `tor-browser` branch + - **Example**: `tor-browser-102.7.0esr-12.5-1` +
+ +**NOTE:** It is assumed that we've already identified the new ESR branch during the tor-browser stable rebase + +### **Bookkeeping** + +- [ ] Link this issue to the appropriate [Release Prep](https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/issues/?sort=updated_desc&state=opened&label_name%5B%5D=Apps%3A%3AType%3A%3AReleasePreparation) issue. + +### Update Branch Protection Rules + +- [ ] In [Repository Settings](https://gitlab.torproject.org/tpo/applications/tor-browser/-/settings/repository): + - [ ] Remove previous alpha `base-browser` and `tor-browser` branch protection rules (this will prevent pushing new changes to the branches being rebased) + - [ ] Create new `base-browser` and `tor-browser` branch protection rule: + - **Branch**: `*-$(ESR_VERSION)esr-$(BROWSER_MAJOR).$(BROWSER_MINOR)-1*` + - **Example**: `*-102.8.0esr-12.5-1*` + - **Allowed to merge**: `Maintainers` + - **Allowed to push and merge**: `Maintainers` + - **Allowed to force push**: `false` + - If you copied and pasted from old rules, double check you didn't add spaces at the end, as GitLab will not trim them! + +### **Create New Branches** + +- [ ] Find the Firefox mercurial tag `$(ESR_TAG)` + - If `$(BROWSER_MINOR)` is 5, the tag should already exist from the stable release + - Otherwise: + - [ ] Go to `https://hg.mozilla.org/releases/mozilla-esr$(ESR_MAJOR)/tags` + - [ ] Find and inspect the commit tagged with `$(ESR_TAG)` + - Tags are in yellow in the Mercurial web UI + - [ ] Find the equivalent commit in `https://github.com/mozilla/gecko-dev/commits/esr$(ESR_MAJOR)` + - The tag should be very close to `HEAD` (usually the second, before a `No bug - Tagging $(HG_HASH) with $(ESR_TAG)`) + - **Notice**: GitHub sorts commits by time, you might want to use `git log gecko-dev/esr$(ESR_MAJOR)` locally, instead + - [ ] Sign/Tag the `gecko-dev` commit: `git tag -as $(ESR_TAG) $(GIT_HASH) -m "Hg tag $(ESR_TAG)"` +- [ ] Create new alpha `base-browser` branch from Firefox mercurial tag + - Branch name in the form: `base-browser-$(ESR_VERSION)esr-$(BROWSER_MAJOR).$(BROWSER_MINOR)-1` + - **Example**: `base-browser-102.8.0esr-12.5-1` +- [ ] Create new alpha `tor-browser` branch from Firefox mercurial tag + - Branch name in the form: `tor-browser-$(ESR_VERSION)esr-$(BROWSER_MAJOR).$(BROWSER_MINOR)-1` + - **Example**: `tor-browser-102.8.0esr-12.5-1` +- [ ] Push new `base-browser` branch to `upstream` +- [ ] Push new `tor-browser` branch to `upstream` + +### **Rebase tor-browser** + +- [ ] Checkout a new local branch for the `tor-browser` rebase + - **Example**: `git branch tor-browser-rebase FIREFOX_102_8_0esr_BUILD1` +- [ ] **(Optional)** `base-browser` rebase and autosquash + - **NOTE** This step may be skipped if the `HEAD` of the previous `base-browser` branch is a `-buildN` tag + - [ ] Cherry-pick the previous `base-browser` commits up to `base-browser`'s `buildN` tag onto new `base-browser` rebase branch + - **Example**: `git cherry-pick FIREFOX_102_7_0esr_BUILD1..base-browser-102.7.0esr-12.5-1-build1` + - [ ] Rebase and autosquash these cherry-picked commits + - **Example**: `git rebase --autosquash --interactive FIREFOX_102_8_0esr_BUILD1 HEAD` + - [ ] Cherry-pick remainder of patches after the `buildN` tag + - **Example**: `git cherry-pick base-browser-102.7.0esr-12.5-1-build1..upstream/base-browser-102.7.0esr-12.5-1` + +- [ ] `tor-browser` rebase and autosquash + - [ ] Note the current git hash of `HEAD` for `tor-browser` rebase+autosquash step: `git rev-parse HEAD` + - [ ] Cherry-pick the appropriate previous `tor-browser` branch's commit range up to the last `tor-browser` `buildN` tag + - **Example**: `git cherry-pick base-browser-102.7.0esr-12.5-1-build1..tor-browser-102.7.0esr-12.5-1-build1` + - **Example (if separate base-browser rebase was skipped)**: `git cherry-pick FIREFOX_102_7_0esr_BUILD1..tor-browser-102.7.0esr-12.5-1-build1` + - [ ] Rebase and autosquash **ONLY** these newly cherry-picked commits using the commit noted previously: `git rebase --autosquash --interactive $(PREV_HEAD)` + - **Example**: `git rebase --autosquash --interactive FIREFOX_102_8_0esr_RELEASE` + - [ ] **(Optional)** Patch reordering + - **NOTE**: We typically want to do this after new features or bug fix commits which are not !fixups to an existing commit have been merged and are just sitting at the end of the commit history + - Relocate new `base-browser` patches in the patch-set to enforce this rough thematic ordering: + - **MOZILLA BACKPORTS** - official Firefox patches we have backported to our ESR branch: Android-specific security updates, critical bug fixes, worthwhile features, etc + - **MOZILLA REVERTS** - revert commits of official Firefox patches + - **UPLIFT CANDIDATES** - patches which stand on their own and should be uplifted to `mozilla-central` + - **BUILD CONFIGURATION** - tools/scripts, gitlab templates, etc + - **BROWSER CONFIGURATION** - branding, mozconfigs, preference overrides, etc + - **SECURITY PATCHES** - security improvements, hardening, etc + - **PRIVACY PATCHES** - fingerprinting, linkability, proxy bypass, etc + - **FEATURES** - new functionality: updater, UX, letterboxing, security level, add-on + - Relocate new `tor-browser` patches in the patch-set to enforce this rough thematic ordering: + - **BUILD CONFIGURATION** - tools/scripts, gitlab templates, etc + - **BROWSER CONFIGURATION** - branding, mozconfigs, preference overrides, etc + - **UPDATER PATCHES** - updater tweaks, signing keys, etc + - **SECURITY PATCHES** - non tor-dependent security improvements, hardening, etc + - **PRIVACY PATCHES** - non tor-dependent fingerprinting, linkability, proxy bypass, etc + - **FEAURES** - non tor-dependent features + - **TOR INTEGRATION** - legacy tor-launcher/torbutton, tor modules, bootstrapping, etc + - **TOR SECURITY PATCHES** - tor-specific security improvements + - **TOR PRIVACY PATCHES** - tor-specific privacy improvements + - **TOR FEATURES** - new tor-specific functionality: manual, onion-location, onion service client auth, etc + - [ ] Cherry-pick remainder of patches after the last `tor-browser` `buildN` tag + - **Example**: `git cherry-pick tor-browser-102.7.0esr-12.5-1-build1..upstream/tor-browser-102.7.0esr-12.5-1` + - [ ] Rebase and autosquash again, this time replacing all `fixup` and `squash` commands with `pick`. The goal here is to have all of the `fixup` and `squash` commits beside the commit which they modify, but kept un-squashed for easy debugging/bisecting. + - **Example**: `git rebase --autosquash --interactive FIREFOX_102_8_0esr_RELEASE` +- [ ] Compare patch sets to ensure nothing *weird* happened during conflict resolution: + - [ ] diff of diffs: + - Do the diff between `current_patchset.diff` and `rebased_patchset.diff` with your preferred difftool and look at differences on lines that starts with + or - + - `git diff $(ESR_TAG_PREV)..$(BROWSER_BRANCH_PREV) > current_patchset.diff` + - `git diff $(ESR_TAG)..$(BROWSER_BRANCH) > rebased_patchset.diff` + - diff `current_patchset.diff` and `rebased_patchset.diff` + - If everything went correctly, the only lines which should differ should be the lines starting with `index abc123...def456` (unless the previous `base-browser` branch includes changes not included in the previous `tor-browser` branch) + - [ ] rangediff: `git range-diff $(ESR_TAG_PREV)..$(TOR_BROWSER_BRANCH_PREV) $(ESR_TAG)..HEAD` + - **Example**: `git range-dif FIREFOX_102_7_0esr_BUILD1..upstream/tor-browser-102.7.0esr-12.5-1 FIREFOX_102_8_0esr_BUILD1..HEAD` +- [ ] Open MR for the `tor-browser` rebase +- [ ] Merge +- Update and push `base-browser` branch + - [ ] Reset the new `base-browser` branch to the appropriate commit in this new `tor-browser` branch + - [ ] Push these commits to `upstream` +- [ ] Set `$(TOR_BROWSER_BRANCH)` as the default GitLab branch + - [ ] Go to [Repository Settings](https://gitlab.torproject.org/tpo/applications/tor-browser/-/settings/repository) + - [ ] Expand `Branch defaults` + - [ ] Set the branch and leave the `Auto-close` checkbox unchecked + - [ ] Save changes + +### **Sign and Tag** + +- [ ] Sign/Tag `HEAD` of the merged `tor-browser` branch: + - In **tor-browser.git**, checkout the new alpha `tor-browser` branch + - In **tor-browser-build.git**, run signing script: + ```bash + ./tools/browser/sign-tag.torbrowser alpha build1 + ``` + - [ ] Push tag to `upstream` +- [ ] Sign/Tag HEAD of the merged `base-browser` branch: + - In **tor-browser.git**, checkout the new alpha `base-browser` branch + - In **tor-browser-build.git**, run signing script: + ```bash + ./tools/browser/sign-tag.basebrowser alpha build1 + ``` + - [ ] Push tag to `upstream` +- [ ] Update tor-browser-build's `main` branch (no MR required, you can just push it if you have the permissions) + - [ ] Update `projects/firefox/config` + - [ ] Update `firefox_platform_version` + - [ ] Set `browser_build` to 1 (to prevent failures in alpha testbuilds) + - [ ] Update `projects/geckoview/config` + - [ ] Update `firefox_platform_version` + - [ ] Set `browser_build` to 1 (to prevent failures in alpha testbuilds) + +/label ~"Apps::Type::Rebase" diff --git a/.gitlab/issue_templates/061 Rebase - Stable.md b/.gitlab/issue_templates/061 Rebase - Stable.md new file mode 100644 index 000000000000..9176729f2301 --- /dev/null +++ b/.gitlab/issue_templates/061 Rebase - Stable.md @@ -0,0 +1,117 @@ +**NOTE:** All examples in this template reference the rebase from 102.7.0esr to 102.8.0esr + +
+ Explanation of Variables + +- `$(ESR_VERSION)`: the Mozilla defined ESR version, used in various places for building tor-browser tags, labels, etc + - **Example**: `102.8.0` +- `$(ESR_TAG)`: the Mozilla defined hg (Mercurial) tag associated with `$(ESR_VERSION)` + - **Example**: `FIREFOX_102_8_0esr_RELEASE` +- `$(ESR_TAG_PREV)`: the Mozilla defined hg (Mercurial) tag associated with the previous ESR version when rebasing (ie, the ESR version we are rebasing from) + - **Example**: `FIREFOX_102_7_0esr_BUILD1` +- `$(BROWSER_MAJOR)`: the browser major version + - **Example**: `12` +- `$(BROWSER_MINOR)`: the browser minor version + - **Example**: either `0` or `5`; Alpha's is always `(Stable + 5) % 10` +- `$(BASE_BROWSER_BRANCH)`: the full name of the current `base-browser` branch + - **Example**: `base-browser-102.8.0esr-12.0-1` +- `$(BASE_BROWSER_BRANCH_PREV)`: the full name of the previous `base-browser` branch + - **Example**: `base-browser-102.7.0esr-12.0-1` +- `$(TOR_BROWSER_BRANCH)`: the full name of the current `tor-browser` branch + - **Example**: `tor-browser-102.8.0esr-12.0-1` +- `$(TOR_BROWSER_BRANCH_PREV)`: the full name of the previous `tor-browser` branch + - **Example**: `tor-browser-102.7.0esr-12.0-1` +
+ +### **Bookkeeping** + +- [ ] Link this issue to the appropriate [Release Prep](https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/issues/?sort=updated_desc&state=opened&label_name%5B%5D=Apps%3A%3AType%3A%3AReleasePreparation) issue. + +### Update Branch Protection Rules + +- [ ] In [Repository Settings](https://gitlab.torproject.org/tpo/applications/tor-browser/-/settings/repository): + - [ ] Remove previous stable `base-browser` and `tor-browser` branch protection rules (this will prevent pushing new changes to the branches being rebased) + - [ ] Create new `base-browser` and `tor-browser` branch protection rule: + - **Branch**: `*-$(ESR_VERSION)esr-$(BROWSER_MAJOR).$(BROWSER_MINOR)-1*` + - **Example**: `*-102.8.0esr-12.0-1*` + - **Allowed to merge**: `Maintainers` + - **Allowed to push and merge**: `Maintainers` + - **Allowed to force push**: `false` + +### **Identify the Firefox Tagged Commit and Create New Branches** + +- [ ] Find the Firefox mercurial tag here: https://hg.mozilla.org/releases/mozilla-esr102/tags + - **Example**: `FIREFOX_102_8_0esr_BUILD1` +- [ ] Find the analogous `gecko-dev` commit: https://github.com/mozilla/gecko-dev + - **Tip**: Search for unique string (like the Differential Revision ID) found in the mercurial commit in the `gecko-dev/esr102` branch to find the equivalent commit + - **Example**: `3a3a96c9eedd02296d6652dd50314fccbc5c4845` +- [ ] Sign and Tag `gecko-dev` commit + - Sign/Tag `gecko-dev` commit : + - **Tag**: `$(ESR_TAG)` + - **Message**: `Hg tag $(ESR_TAG)` +- [ ] Create new stable `base-browser` branch from tag + - Branch name in the form: `base-browser-$(ESR_VERSION)esr-$(BROWSER_MAJOR).$(BROWSER_MINOR)-1` + - **Example**: `base-browser-102.8.0esr-12.0-1` +- [ ] Create new stable `tor-browser` branch from + - Branch name in the form: `tor-browser-$(ESR_VERSION)esr-$(BROWSER_MAJOR).$(BROWSER_MINOR)-1` + - **Example**: `tor-browser-102.8.0esr-12.0-1` +- [ ] Push new `base-browser` branch to `upstream` +- [ ] Push new `tor-browser` branch to `upstream` +- [ ] Push new `$(ESR_TAG)` to `upstream` + +### **Rebase tor-browser** + +- [ ] Checkout a new local branch for the `tor-browser` rebase + - **Example**: `git branch tor-browser-rebase FIREFOX_102_8_0esr_BUILD1` +- [ ] **(Optional)** `base-browser` rebase + - **NOTE** This step may be skipped if the `HEAD` of the previous `base-browser` branch is a `-buildN` tag + - [ ] Cherry-pick the previous `base-browser` commits up to `base-browser`'s `buildN` tag onto new `base-browser` rebase branch + - **Example**: `git cherry-pick FIREFOX_102_7_0esr_BUILD1..base-browser-102.7.0esr-12.0-1-build1` + - [ ] Rebase and autosquash these cherry-picked commits + - **Example**: `git rebase --autosquash --interactive FIREFOX_102_8_0esr_BUILD1 HEAD` + - [ ] Cherry-pick remainder of patches after the `buildN` tag + - **Example**: `git cherry-pick base-browser-102.7.0esr-12.0-1-build1..upstream/base-browser-102.7.0esr-12.0-1` +- [ ] `tor-browser` rebase + - [ ] Note the current git hash of `HEAD` for `tor-browser` rebase+autosquash step: `git rev-parse HEAD` + - [ ] Cherry-pick the appropriate previous `tor-browser` branch's commit range up to the last `tor-browser` `buildN` tag + - **Example**: `git cherry-pick base-browser-102.7.0esr-12.0-1-build1..tor-browser-102.7.0esr-12.0-1-build1` + - **Example (if separate base-browser rebase was skipped)**: `git cherry-pick FIREFOX_102_7_0esr_BUILD1..tor-browser-102.7.0esr-12.0-1-build1` + - [ ] Rebase and autosquash these newly cherry-picked commits: `git rebase --autosquash --interactive $(PREV_HEAD)` + - **Example**: `git rebase --autosquash --interactive FIREFOX_102_8_0esr_RELEASE` + - [ ] Cherry-pick remainder of patches after the last `tor-browser` `buildN` tag + - **Example**: `git cherry-pick tor-browser-102.7.0esr-12.0-1-build1..upstream/tor-browser-102.7.0esr-12.0-1` + - [ ] Rebase and autosquash again, this time replacing all `fixup` and `squash` commands with `pick`. The goal here is to have all of the `fixup` and `squash` commits beside the commit which they modify, but kept un-squashed for easy debugging/bisecting. + - **Example**: `git rebase --autosquash --interactive FIREFOX_102_8_0esr_RELEASE` +- [ ] Compare patch sets to ensure nothing *weird* happened during conflict resolution: + - [ ] diff of diffs: + - Do the diff between `current_patchset.diff` and `rebased_patchset.diff` with your preferred difftool and look at differences on lines that starts with + or - + - `git diff $(ESR_TAG_PREV)..$(BROWSER_BRANCH_PREV) > current_patchset.diff` + - `git diff $(ESR_TAG)..$(BROWSER_BRANCH) > rebased_patchset.diff` + - diff `current_patchset.diff` and `rebased_patchset.diff` + - If everything went correctly, the only lines which should differ should be the lines starting with `index abc123...def456` (unless the previous `base-browser` branch includes changes not included in the previous `tor-browser` branch) + - [ ] rangediff: `git range-diff $(ESR_TAG_PREV)..$(TOR_BROWSER_BRANCH_PREV) $(ESR_TAG)..HEAD` + - **Example**: `git range-dif FIREFOX_102_7_0esr_BUILD1..upstream/tor-browser-102.7.0esr-12.0-1 FIREFOX_102_8_0esr_BUILD1..HEAD` +- [ ] Open MR for the `tor-browser` rebase +- [ ] Merge +- Update and push `base-browser` branch + - [ ] Reset the new `base-browser` branch to the appropriate commit in this new `tor-browser` branch + - [ ] Push these commits to `upstream` + +### **Sign and Tag** + +- [ ] Sign/Tag `HEAD` of the merged `tor-browser` branch: + - In **tor-browser.git**, checkout the new stable `tor-browser` branch + - In **tor-browser-build.git**, run signing script: + ```bash + ./tools/browser/sign-tag.torbrowser stable build1 + ``` + - [ ] Push tag to `upstream` +- [ ] Sign/Tag HEAD of the merged `base-browser` branch: + - In **tor-browser.git**, checkout the new stable `base-browser` branch + - In **tor-browser-build.git**, run signing script: + ```bash + ./tools/browser/sign-tag.basebrowser stable build1 + ``` + - [ ] Push tag to `upstream` + +/label ~"Apps::Type::Rebase" diff --git a/.gitlab/issue_templates/063 Rebase - Rapid.md b/.gitlab/issue_templates/063 Rebase - Rapid.md new file mode 100644 index 000000000000..e5e913aff1a1 --- /dev/null +++ b/.gitlab/issue_templates/063 Rebase - Rapid.md @@ -0,0 +1,292 @@ +- **NOTE**: All examples in this template reference the rebase from Firefox 129.0a1 to 130.0a1 +- **TODO**: + - Documentation step for any difficulties or noteworthy things for each rapid rebase + +
+ Explanation of Channels + + There are unfortunately some collisions between how we and Mozilla name our release channels which can make things confusing: + - **Firefox**: + - **Nightly**: \_START and \_END tags, version in the format `$(MAJOR).$(MINOR)a1` + - **Example**: Firefox Nightly 130 was `130.0a1` + - **Note**: Nightly is 2 major versions ahead of the current Release + - **Beta**: tagged each Monday, Wednesday, and Friday until release, version in the format `$(MAJOR).$(MINOR)b$(PATCH)` + - **Example**: the first Firefox Beta 130 was `130.0b1` + - **Note**: Beta is 1 major version ahead of the current Release, should be irrelevant to us + - **Release**: tagged monthly, version in the format `$(MAJOR).$(MINOR)` or `$(MAJOR).$(MINOR).$(PATCH)` + - **Example** Firefox Release 130 was `130.0` + - **ESR**: tagged monthly, version in the format `$(ESR_MAJOR).$(ESR_MINOR).$(ESR_PATCH)esr` + - **Example**: Firefox ESR 128.1 is `128.1.0esr` + - **Tor+Mullvad Browser**: + - **Rapid**: tagged monthly, based on the latest Firefox Nightly + - **Nightly**: not tagged, built nightly from our current Alpha branch's `HEAD` + - **Alpha**: tagged monthly, based on the latest Firefox ESR + - **Stable**: tagged monthly, based on oldest supported Firefox ESR + +
+ +
+ Branching Overview + + Rebasing Tor Browser Rapid onto the current Firefox Nightly is a bit more confusing/involved than rebasing Tor Browser Alpha or Stable from one minor ESR to the next minor ESR. + + The general process basically involves rebasing the previous Firefox Nightly-based Tor Browser Rapid onto the latest Firefox Nightly, and then cherry-picking all of the commits from the previous Firefox ESR-based Tor Browser Alpha after that channel's `build1` tag. This process presumes that the previous Tor Browser Alpha branch is locked and receiving no more changes. + + This diagram provides a high-level view of the overall code-flow for rebasing/cherry-picking commits from Tor Browser Alpha based on Firefox 128.1.0esr and Tor Browser Rapid based on Firefox 129.0a1 onto Firefox 130.0a1: + + ```mermaid +%%{init: { 'themeVariables': {'git0': '#0072b2', 'gitBranchLabel0': '#fff', 'git1': "#e69f00", 'gitBranchLabel1': '#fff', 'git2': '#009e73', 'gitBranchLabel2': '#fff', 'git3': '#cc79a7', 'gitBranchLabel3': '#fff'}, 'gitGraph': {'mainBranchName': 'tor-browser-128.1.0esr-14.5-1'}} }%% +gitGraph: + branch tor-browser-129.0a1-15.0-2 + branch tor-browser-130.0a1-15.0-1 + branch tor-browser-130.0a1-15.0-2 + + checkout tor-browser-128.1.0esr-14.5-1 + commit id: "FIREFOX_128_1_0esr_BUILD1" + commit id: "base-browser-128.1.0esr-14.5-1-build1" + commit id: "tor-browser-128.1.0esr-14.5-1-build1" + commit id: "tor-browser-128.1.0esr-14.5-1-build2" + + checkout tor-browser-129.0a1-15.0-2 + commit id: "FIREFOX_NIGHTLY_129_END" + %% commit id: "tor-browser-129.0a1-15.0-2-build1" + + checkout tor-browser-130.0a1-15.0-1 + commit id: "FIREFOX_NIGHTLY_130_END" + + checkout tor-browser-130.0a1-15.0-2 + commit id: "FIREFOX_NIGHTLY_130_END " + + checkout tor-browser-130.0a1-15.0-1 + merge tor-browser-129.0a1-15.0-2 + + checkout tor-browser-130.0a1-15.0-2 + merge tor-browser-130.0a1-15.0-1 + + + checkout tor-browser-129.0a1-15.0-2 + commit id: "tor-browser-129.0a1-15.0-2-build1" + + checkout tor-browser-130.0a1-15.0-1 + merge tor-browser-129.0a1-15.0-2 id: "tor-browser-130.0a1-15.0-1-build1" + + checkout tor-browser-130.0a1-15.0-2 + merge tor-browser-130.0a1-15.0-1 + + checkout tor-browser-130.0a1-15.0-1 + merge tor-browser-128.1.0esr-14.5-1 + + checkout tor-browser-130.0a1-15.0-2 + merge tor-browser-130.0a1-15.0-1 + + checkout tor-browser-128.1.0esr-14.5-1 + commit id: "tor-browser-128.1.0esr-14.5-1" + + checkout tor-browser-130.0a1-15.0-1 + merge tor-browser-128.1.0esr-14.5-1 id:"tor-browser-130.0a1-15.0-1-build2" + + checkout tor-browser-130.0a1-15.0-2 + + merge tor-browser-130.0a1-15.0-1 + commit id: "tor-browser-130.0a1-15.0-2-build1" + + ``` + + In this concrete example, the rebaser performs the following steps: + - create new `tor-browser-130.0a1-15.0-1`, and `tor-browser-130.0a1-15.0-2` branches from the `FIREFOX_NIGHTLY_130_END` tag. + - these will be the rebase review branches + - onto `tor-browser-130.0a1-15.0-1`, cherry-pick the range `FIREFOX_NIGHTLY_129_END..tor-browser-129.0a1-15.0-2-build1` (i.e. the Firefox Nightly 129-based Tor Browser Rapid commits) + - this updates the previous Tor Browser Rapid onto Firefox Nightly 130 + - cherry-pick the new alpha patches onto `tor-browser-130.0a1-15.0-1` (i.e. cherry-pick `tor-browser-128.1.0esr-14.5-1-build2..origin/tor-browser-128.1.0esr-14.5-1`) + - onto `tor-browser-130.0a1-15.0-2`, rebase and autosquash the `FIREFOX_NIGHTLY_130_END..tor-browser-130.0a1-15.0-2-build1` commit range + - onto `tor-browser-130.0a1-15.0-2`, cherry-pick the remaining commit range `tor-browser-130.0a1-15.0-2-build1..origin/tor-browser-130.0a1-15.0-2` + - re-order any remaining fixup! commits to be adjacent to their parents (i.e. the same rebase command queue as one would get from `git rebase --autosquash`, but with the `fixup!` commands replaced with `pick!` commands). + - this re-organises the branch in a nicely-bisectable way, and will ensure the rebase+autosquash step for the next release *should* succeed without any additional effort + +
+ +
+ Explanation of Variables + +- `$(NIGHTLY_VERSION)`: the Mozilla defined nightly version, used in various places for building tor-browser tags, labels, etc + - **Example**: `130.0a1` +- `$(NIGHTLY_TAG)`: the Mozilla defined hg (Mercurial) tag associated with `$(NIGHTLY_VERSION)` + - **Example**: `FIREFOX_NIGHTLY_130_END` +- `$(NIGHTLY_TAG_PREV)`: the Mozilla defined hg (Mercurial) tag associated with the previous nightly version when rebasing (ie, the nightly version we are rebasing from) + - **Example**: `FIREFOX_NIGHTLY_129_END` +- `$(BROWSER_VERSION)`: the browser version which will first be based on the next major ESR version this *Firefox* Nightly series is leading up to + - **Example**: `15` +- `$(TOR_BROWSER_BRANCH)`: the full name of the current `tor-browser` branch based off of the Firefox Nightly channel + - **Example**: `tor-browser-130.0a1-15.0-1` +- `$(TOR_BROWSER_BRANCH_PREV)`: the full name of the previous `tor-browser` branch based off of the Firefox Nightly channel + - **Example**: `tor-browser-129.0a1-15.0-1` +
+ +### Update Branch Protection Rules + +- [ ] In [Repository Settings](https://gitlab.torproject.org/tpo/applications/tor-browser/-/settings/repository): + - [ ] Remove previous nightly `tor-browser` branch protection rules (this will prevent pushing new changes to the branches being rebased) + - [ ] Create new `tor-browser` branch protection rule: + - **Branch**: `tor-browser-$(NIGHTLY_VERSION)-$(BROWSER_VERSION)-*` + - **Example**: `tor-browser-130.0a1-15.0-*` + - **Allowed to merge**: `Maintainers` + - **Allowed to push and merge**: `Maintainers` + - **Allowed to force push**: `false` + - ⚠️ **IMPORTANT**: If you copied and pasted from old rules, double check you didn't add spaces at the end, as GitLab will not trim them! + +### **Create New Branches** + +- [ ] Find the Firefox mercurial tag `$(NIGHTLY_TAG)` + - Go to https://hg.mozilla.org/mozilla-central/tags + - Find and inspect the commit tagged with `$(NIGHTLY_TAG)` + - Tags are in yellow in the Mercurial web UI + - Find the equivalent commit in https://github.com/mozilla/gecko-dev/commits/master + - **Notice**: GitHub sorts commits by time, you might want to use `git log gecko-dev/master` locally, instead + - Using the differential revision link is useful to quickly find the git commit + - Sign/Tag the `gecko-dev` commit: `git tag -as $(NIGHTLY_TAG) $(GIT_HASH) -m "Hg tag $(NIGHTLY_TAG)"` +- [ ] Create two new rapid `tor-browser` branches from Firefox mercurial tag + - Branch name in the form: `tor-browser-$(NIGHTLY_VERSION)-$(BROWSER_VERSION)-${BRANCH_NUM}` + - **Example**: `tor-browser-130.0a1-15.0-1` and `tor-browser-130.0a1-15.0-2` +- [ ] Push new `tor-browser` branches and the `firefox` tag to `upstream` + +### **Rebase previous `-2` rapid branch's HEAD onto current `-1` rapid branch** + +- **Desired outcome**: + - An easy to review branch with the previous rapid branch rebased onto the latest Firefox Nighty tag + - It must be possible to run `git range-diff` between the previous `-2` and the new branch + - We want to see only the effects of the rebase + - No autosquash should happen at this point + - **Expected difficulties**: + - Conflicts with upstream developments + - Sometimes it will be hard to keep a feature working. It's fine to drop it, and create an issue to restore it after a deeper investigation. +- [ ] Checkout a new local branch for the first part of the `-1` rebase + - **Example**: `git checkout -b rapid-rebase-part1 origin/tor-browser-130.0a1-15.0-1` +- [ ] Firefox Nightly-based `tor-browser` rebase: + - [ ] cherry-pick previous Tor Browser Rapid `-2` branch to new `-1` rebase branch + - **Example**: `git cherry-pick FIREFOX_NIGHTLY_129_END..origin/tor-browser-129.0a1-15.0-2` +- [ ] Rebase Verification: + - [ ] Clean range-diff between the previous rapid branch and current rebase branch + - **Example**: + ```bash + git range-diff FIREFOX_NIGHTLY_129_END..origin/tor-browser-129.0a1-15.0-2 FIREFOX_NIGHTLY_130_END..rapid-rebase-part1 + ``` + - [ ] Optional: clean diff of diffs between previous rapid branch and current rebase branch + - **Example**: + ```bash + git diff FIREFOX_NIGHTLY_129_END origin/tor-browser-129.0a1-15.0-2 > 129.diff + git diff FIREFOX_NIGHTLY_130_END HEAD > 130.diff + # A two-column diff tool is suggested rather than plain-diff, e.g., meld on Linux. + meld 129.diff 130.diff + ``` + - **Note**: Only differences should be due to resolving merge conflicts with upstream changes from Firefox Nightly +- [ ] Open MR +- [ ] Merge +- [ ] Sign/Tag `HEAD` of the merged `tor-browser` branch: + - In **tor-browser.git**, checkout the `-1` rapid `tor-browser` branch + - In **tor-browser-build.git**, run signing script: + ```bash + ./tools/browser/sign-tag.torbrowser rapid build1 + ``` + - [ ] Push tag to `upstream` + +### **Port new alpha patches to `-1`** + +- **Desired outcome**: + - The previous release-cycle's new alpha patches cherry-picked to the end of the current nightly + - It must be possible to run `git range-diff ESR-build1..ESR NIGHTLY-build1..` + - **Expected difficulties**: + - Conflicts with upstream developments (similar to the previous part) + - The range might contain cherry-picked upstream commits, which will result in empty commits: it's fine to skip them + - **Note**: The Tor Browser Alpha branch should be closed at this point and not receiving any more MRs +- [ ] Checkout a new local branch for the second part of the `-1` rebase + - **Example**: `git checkout -b rapid-rebase-part2 origin/tor-browser-130.0a1-15.0-1` +- [ ] Cherry-pick the new `tor-browser` alpha commits (i.e. the new dangling commits which did not appear in the previous Tor Browser Alpha release): + - **Example** `git cherry-pick tor-browser-128.1.0esr-14.5-1-build1..origin/tor-browser-128.1.0esr-14.5-1` +- [ ] Rebase Verification + - [ ] Clean range-diff between the alpha patch set ranges + - **Example**: + ```bash + git range-diff tor-browser-128.1.0esr-14.5-1-build1..origin/tor-browser-128.1.0esr-14.5-1 origin/tor-browser-130.0a1-15.0-1..HEAD + ``` + - [ ] Clean diff of diffs between the alpha patch set ranges + - **Example**: + ```bash + git diff tor-browser-128.1.0esr-14.5-1-build1 origin/tor-browser-128.1.0esr-14.5-1 > 128.1.0esr.diff + git diff origin/tor-browser-130.0a1-15.0-1 HEAD > 130.diff + # A two-column diff tool is suggested rather than plain-diff, e.g., meld on Linux. + meld 128.1.0esr.diff 130.diff + ``` + - **Note**: Only differences should be due to resolving merge conflicts with upstream changes from Firefox Nightly +- [ ] Open MR +- [ ] Merge +- [ ] Sign/Tag `HEAD` of the merged `tor-browser` branch: + - In **tor-browser.git**, checkout the `-1` rapid `tor-browser` branch + - In **tor-browser-build.git**, run signing script: + ```bash + ./tools/browser/sign-tag.torbrowser rapid build2 + ``` + - [ ] Push tag to `upstream` + +### **Squash and Reorder tor-browser `-1` branch to new `-2` branch** +- **Desired outcome**: + - The rapid branch from the previous step prepared for the next nightly + - **Rationale**: + - We squash a lot of commits. We want to keep them a little bit longer rather than squashing them immediately for troubleshooting and documentation purposes. + - Doing this as a separate pass helps to separate errors due to upstream changes from errors due to processes created by our workflow. + - **Expected difficulties**: + - our patches aren't disjoint, therefore we might have conflicts when shuffling them around. +- [ ] Checkout a new local branch for the `-2` rebase, aligned to -1-build1 + - **Example**: `git checkout -b rapid-rebase-part3 tor-browser-130.0a1-15.0-1-build1` +- [ ] Rebase with autosquash. This step should be trivial and not involve any conflicts. + - **Example**: `git rebase -i --autosquash FIREFOX_NIGHTLY_130_END` +- [ ] Cherry-pick the remaining commits + - **Example**: `git cherry-pick tor-browser-130.0a1-15.0-1-build1..upstream/tor-browser-130.0a1-15.0-1` +- [ ] Create a branch for self-reviewing purposes, or take note of the current commit hash somewhere + - **Example**: `git branch rapid-rebase-part3-review` + - You do not need to publish this, and you can delete it at the end of the process (`git branch -D rapid-rebase-part3-review`) + - When you are a reviewer, it might be useful to repeat these steps locally. They should not involve mental overhead (and PieroV has a script to automate this) +- [ ] Rebase and reorder commits (i.e. replace `fixup `, `fixup -C ` and `squash ` with `pick ` commands) + - Notice the space at the end, to avoid replacing `fixup!` with `pick!` in the commit subject, even though git will probably not care of such changes +- [ ] Rebase Verification + - [ ] Clean range-diff between the temporary review branch and the final branch + - **Example**: + ```bash + git range-diff FIREFOX_NIGHTLY_130_END..rapid-rebase-part3-review FIREFOX_NIGHTLY_130_END..rapid-rebase-part3 + ``` + - If you are the reviewer, it should be trivial to create such a branch on your own, as no shuffling is involved + - [ ] Clean diff of diffs between rapid branches + - **Example**: + ```bash + git diff FIREFOX_NIGHTLY_130_END tor-browser-130.0a1-15.0-1-build2 > 130-1.diff + git diff FIREFOX_NIGHTLY_130_END HEAD > 130-2.diff + ``` + - [ ] Understandable range-diff (i.e. `fixup!` patches are distributed from end of branch next to their parent) + - **Example**: + ```bash + git range-diff FIREFOX_NIGHTLY_130_END..tor-browser-130.0a1-15.0-1-build2 FIREFOX_NIGHTLY_130_END..HEAD + ``` +- [ ] Open MR +- [ ] Merge +- [ ] Sign/Tag `HEAD` of the merged `tor-browser` branch: + - In **tor-browser.git**, checkout the `-2` rapid `tor-browser` branch + - In **tor-browser-build.git**, run signing script: + ```bash + ./tools/browser/sign-tag.torbrowser rapid build1 + ``` + - [ ] Push tag to `upstream` + +### **Create and Tag base-browser `-2` branch** +- [ ] Find the last commit in the merged `-2` `tor-browser` branch with a `BB XXXXX...` subject +- [ ] Create new branch from this commit + - Branch name in the form: `base-browser-$(NIGHTLY_VERSION)-$(BROWSER_VERSION)-2` + - **Example**: `base-browser-130.0a1-15.0-2` +- [ ] Push branch to `upstream` +- [ ] Sign/Tag latest `HEAD` of the merged `base-browser` branch: + - In **tor-browser.git**, checkout the `-2` rapid `tor-browser` branch + - In **tor-browser-build.git**, run signing script: + ```bash + ./tools/browser/sign-tag.basebrowser rapid build1 ${COMMIT} + ``` + - [ ] Push tag to `upstream` + +/label ~"Apps::Type::Rebase" diff --git a/.gitlab/issue_templates/090 Emergency Security Issue.md b/.gitlab/issue_templates/090 Emergency Security Issue.md new file mode 100644 index 000000000000..33e6a1d7452a --- /dev/null +++ b/.gitlab/issue_templates/090 Emergency Security Issue.md @@ -0,0 +1,90 @@ +**NOTE** This is an issue template to standardise our process for responding to and fixing critical security and privacy vulnerabilities, exploits, etc. + +## Information + +### Related Issue +- tor-browser#AAAAA +- mullvad-browser#BBBBB +- tor-browser-build#CCCCC + +#### Affected Platforms + +- [ ] Android +- [ ] Desktop + - [ ] Windows + - [ ] macOS + - [ ] Linux + +### Type of Issue: What are we dealing with? + +- [ ] Security (sandbox escape, remote code execution, etc) +- [ ] Proxy Bypass (traffic contents becoming MITM'able) +- [ ] De-Anonymization (otherwise identifying which website a user is visiting) +- [ ] Cross-Site Linkability (correlating sessions across circuits and websites) +- [ ] Disk Leak (persisting session information to disk) +- [ ] Other (please explain) + +### Involvement: Who needs to be consulted and or involved to fix this? + +- [ ] Applications Developers + - [ ] **boklm** : build, packaging, signing, release + - [ ] **clairehurst** : Android, macOS + - [ ] **dan** : Android, macOS + - [ ] **henry** : accessibility, frontend, localisation + - [ ] **ma1** : firefox internals + - [ ] **pierov** : updater, fonts, localisation, general + - [ ] **richard** : signing, release + - [ ] **thorin** : fingerprinting +- [ ] Other Engineering Teams + - [ ] Networking (**ahf**, **dgoulet**) + - [ ] Anti-Censorship (**meskio**, **cohosh**) + - [ ] UX (**donuts**) + - [ ] TPA (**anarcat**, **lavamind**) +- [ ] External Tor Partners + - [ ] Mozilla + - [ ] Mullvad + - [ ] Brave + - [ ] Guardian Project (Orbot, Onion Browser) + - [ ] Tails + - [ ] Other (please list) + +### Urgency: When do we need to act? + +- [ ] **ASAP** :rotating_light: Emergency release :rotating_light: +- [ ] Next scheduled stable +- [ ] Next scheduled alpha, then backport to stable +- [ ] Next major release +- [ ] Other (please explain) + +#### Justification + + + +### Side-Effects: Who will be affected by a fix for this? +Sometimes fixes have side-effects: users lose their data, roadmaps need to be adjusted, services have to be upgraded, etc. Please enumerate the known downstream consequences a fix to this issue will likely incur. +- [ ] End-Users (please list) +- [ ] Internal Partners (please list) +- [ ] External Partners (please list) + +## Todo: + +### Communications + +- [ ] Start an initial email thread with the following people: + - [ ] **bella** + - [ ] Relevant Applications Developers + - [ ] **(Optional)** **micah** + - if there are considerations or asks outside the Applications Team + - [ ] **(Optional)** Other Team Leads + - if there are considerations or asks outside the Applications Team + - [ ] **(Optional)** **gazebook** + - if there are consequences to the organisation or partners beyond a browser update, then a communication plan may be needed + +/cc @bella +/cc @ma1 +/cc @micah +/cc @richard + +/confidential + +Godspeed! :pray: diff --git a/.gitlab/issue_templates/Default.md b/.gitlab/issue_templates/Default.md new file mode 100644 index 000000000000..13be5ed00565 --- /dev/null +++ b/.gitlab/issue_templates/Default.md @@ -0,0 +1,19 @@ +# Open a new Issue + +Please select the appropriate issue template from the **Description** drop-down. + +--- + +- 🐞 **Bug Report** - report a problem with the browser +- 💡 **Proposal** - suggest a new feature +- 🌐 **Web Compatibility** - report a broken website + +*NOTE*: the following issue types are intended for internal use + +- 💣 **Test** - develop a test or update testing infrastructure +- ✨ **Feature** - implement new features +- ⬅️ **Backport** - cherry-pick change to other release channels +- ⤵️ **Rebase - Alpha** - rebase alpha to latest Firefox ESR version +- ⤵️ **Rebase - Stable** - rebase stable to latest Firefox ESR version +- ⤵️ **Rebase - Rapid** - rebase rapid to latest Firefox Nightly version +- 🚨 **Emergency Security Issue** - manage fixing and publishing a critical security fix diff --git a/.gitlab/merge_request_templates/Default.md b/.gitlab/merge_request_templates/Default.md new file mode 100644 index 000000000000..fb083a62c9b5 --- /dev/null +++ b/.gitlab/merge_request_templates/Default.md @@ -0,0 +1,92 @@ +## Merge Info + + + +### Issues + +#### Resolves +- tor-browser#xxxxx +- mullvad-browser#xxxxx +- tor-browser-build#xxxxx + +#### Related + +- tor-browser#xxxxx +- mullvad-browser#xxxxx +- tor-browser-build#xxxxx + +### Merging + + + +#### Target Branches + +- [ ] **`tor-browser`** - `!fixups` to `tor-browser`-specific commits, new features, security backports +- [ ] **`base-browser`** *and* **`mullvad-browser`** - `!fixups` to `base-browser`-specific commits, new features to be shared with `mullvad-browser`, and security backports + - ⚠️ **IMPORTANT**: Please list the `base-browser`-specific commits which need to be cherry-picked to the `base-browser` and `mullvad-browser` branches here + +#### Target Channels + +- [ ] **Alpha**: esr128-14.5 +- [ ] **Stable**: esr128-14.0 +- [ ] **Legacy**: esr115-13.5 + +### Backporting + +#### Timeline +- [ ] **No Backport (preferred)**: patchset for the next major stable +- [ ] **Immediate**: patchset needed as soon as possible (fixes CVEs, 0-days, etc) +- [ ] **Next Minor Stable Release**: patchset that needs to be verified in nightly before backport +- [ ] **Eventually**: patchset that needs to be verified in alpha before backport + +#### (Optional) Justification +- [ ] **Security update**: patchset contains a security fix (be sure to select the correct item in _Timeline_) +- [ ] **Censorship event**: patchset enables censorship circumvention +- [ ] **Critical bug-fix**: patchset fixes a bug in core-functionality +- [ ] **Consistency**: patchset which would make development easier if it were in both the alpha and release branches; developer tools, build system changes, etc +- [ ] **Sponsor required**: patchset required for sponsor +- [ ] **Localization**: typos and other localization changes that should be also in the release branch +- [ ] **Other**: please explain + +### Upstream +- [ ] Patchset is a candidate for uplift to Firefox +- [ ] Patchset is a backport from Firefox + - Bugzilla link: + - Upstream commit: + +### Issue Tracking +- [ ] Link resolved issues with appropriate [Release Prep issue](https://gitlab.torproject.org/groups/tpo/applications/-/issues/?sort=updated_desc&state=opened&label_name%5B%5D=Apps%3A%3AType%3A%3AReleasePreparation&first_page_size=100) for changelog generation + +### Review + +#### Request Reviewer + +- [ ] Request review from an applications developer depending on modified system: + - **NOTE**: if the MR modifies multiple areas, please `/cc` all the relevant reviewers (since Gitlab only allows 1 reviewer) + - **accessibility** : henry + - **android** : clairehurst, dan + - **build system** : boklm + - **ci/cd**: brizental, henry + - **extensions** : ma1 + - **firefox internals (XUL/JS/XPCOM)** : jwilde, ma1 + - **fonts** : pierov + - **frontend (implementation)** : henry + - **frontend (review)** : donuts, morgan + - **localization** : henry, pierov + - **macOS** : clairehurst, dan + - **nightly builds** : boklm + - **rebases/release-prep** : brizental, clairehurst, dan, ma1, pierov, morgan + - **security** : jwilde, ma1 + - **signing** : boklm, morgan + - **updater** : pierov + - **windows** : jwilde, morgan + - **misc/other** : pierov, morgan + +#### Change Description + + + + +#### How Tested + + -- GitLab From 3599f1d2cbe0b47896c462431cf20715dc188317 Mon Sep 17 00:00:00 2001 From: Morgan Date: Thu, 3 Apr 2025 12:31:16 +0000 Subject: [PATCH 024/250] fixup! BB 43615: Add Gitlab Issue and Merge Request templates add new and modify existing shared Tor/Mullvad browser templates --- .gitlab/issue_templates/000 Bug Report.md | 121 ++++++++++++++++++ .gitlab/issue_templates/010 Proposal.md | 70 ++++++++++ .../issue_templates/020 Web Compatibility.md | 112 ++++++++++++++++ .gitlab/issue_templates/030 Test.md | 29 +++++ .gitlab/issue_templates/040 Feature.md | 32 +++++ .gitlab/issue_templates/050 Backport.md | 30 +++-- .gitlab/issue_templates/060 Rebase - Alpha.md | 8 ++ .../issue_templates/061 Rebase - Stable.md | 8 ++ .gitlab/issue_templates/063 Rebase - Rapid.md | 8 ++ .../090 Emergency Security Issue.md | 18 ++- 10 files changed, 422 insertions(+), 14 deletions(-) diff --git a/.gitlab/issue_templates/000 Bug Report.md b/.gitlab/issue_templates/000 Bug Report.md index e69de29bb2d1..3b42b63e5e23 100644 --- a/.gitlab/issue_templates/000 Bug Report.md +++ b/.gitlab/issue_templates/000 Bug Report.md @@ -0,0 +1,121 @@ +# 🐞 Bug Report + + +## Reproduction steps + + +## Expected behaviour + + +## Actual behaviour + + +## Bookkeeping + + +- Browser version: +- Browser channel: + - [ ] Release + - [ ] Alpha + - [ ] Nightly +- Distribution method: + - [ ] Installer/archive from torproject.org + - [ ] tor-browser-launcher + - [ ] homebrew + - [ ] other (please specify): +- Operating System: + - [ ] Windows + - [ ] macOS + - [ ] Linux + - [ ] Android + - [ ] Tails + - [ ] Other (please specify): +- Operating System Version: + +### Browser UI language + + +### Have you modified any of the settings in `about:preferences` or `about:config`? If yes, which ones? + + +### Do you have any extra extensions installed? + + +## Troubleshooting + + +### Does this bug occur in a fresh installation? + +### Is this bug new? If it is a regression, in which version of the browser did this bug first appear? + + +### Does this bug occur in the Alpha release channel? + + +### Does this bug occur in Firefox ESR (Desktop only)? + + +### Does this bug occur in Firefox Rapid Release? + + + + +--- + +/label ~"Apps::Product::TorBrowser" +/label ~"Apps::Type::Bug" diff --git a/.gitlab/issue_templates/010 Proposal.md b/.gitlab/issue_templates/010 Proposal.md index e69de29bb2d1..ad6e80d64f19 100644 --- a/.gitlab/issue_templates/010 Proposal.md +++ b/.gitlab/issue_templates/010 Proposal.md @@ -0,0 +1,70 @@ +# 💡 Proposal + + +## User Story + + +## Security and Privacy Implications + + +### Security + + +### Privacy + + +## Accessibility Implications + + +## Other Trade-Offs + + +## Prior Art + +### Does this feature exist in other browsers? +- [ ] Yes + - [ ] Firefox + - [ ] Firefox ESR + - [ ] Other (please specify) +- [ ] No + +### Does this feature exist as an extension? If yes, which one provides this functionality? + + + +--- + +/label ~"Apps::Product::TorBrowser" +/label ~"Apps::Type::Proposal" diff --git a/.gitlab/issue_templates/020 Web Compatibility.md b/.gitlab/issue_templates/020 Web Compatibility.md index e69de29bb2d1..b42b0aa419eb 100644 --- a/.gitlab/issue_templates/020 Web Compatibility.md +++ b/.gitlab/issue_templates/020 Web Compatibility.md @@ -0,0 +1,112 @@ +# 🌍 Web Compatibility + + +## URL + + +## Expected behaviour + + +## Actual behaviour + + +## Reproduction steps + + +## Bookkeeping + + +- Browser version: +- Browser channel: + - [ ] Release + - [ ] Alpha + - [ ] Nightly +- Distribution method: + - [ ] Installer/archive from torproject.org + - [ ] tor-browser-launcher + - [ ] homebrew + - [ ] other (please specify): +- Operating System: + - [ ] Windows + - [ ] macOS + - [ ] Linux + - [ ] Android + - [ ] Tails + - [ ] Other (please specify): +- Operating System Version: + +### Have you modified any of the settings in `about:preferences` or `about:config`? If yes, which ones? + + +### Do you have any extra extensions installed? + + +## Troubleshooting + + +### Does this bug occur in a fresh installation? + +### Is this bug new? If it is a regression, in which version of the browser did this bug first appear? + + +### Does this bug occur in the Alpha release channel? + + +### Does this bug occur in Firefox ESR (Desktop only)? + + +### Does this bug occur in Firefox Rapid Release? + + + + +--- + +/label ~"Apps::Product::TorBrowser" +/label ~"Apps::Type::WebCompatibility" diff --git a/.gitlab/issue_templates/030 Test.md b/.gitlab/issue_templates/030 Test.md index e69de29bb2d1..54f566524715 100644 --- a/.gitlab/issue_templates/030 Test.md +++ b/.gitlab/issue_templates/030 Test.md @@ -0,0 +1,29 @@ +# 💣 Test + + +## Description + + +## Scenarios + + + + +--- + +/label ~"Apps::Product::TorBrowser" +/label ~"Apps::Type::Test" diff --git a/.gitlab/issue_templates/040 Feature.md b/.gitlab/issue_templates/040 Feature.md index e69de29bb2d1..da64b445a1da 100644 --- a/.gitlab/issue_templates/040 Feature.md +++ b/.gitlab/issue_templates/040 Feature.md @@ -0,0 +1,32 @@ +# ✨ Feature + + +## Description + + +## Bookkeeping + +### Proposal + +- tor-browser#12345 + +### Design + +- tpo/UX/Design#123 + + + +--- + +/label ~"Apps::Product::TorBrowser" +/label ~"Apps::Type::Feature" diff --git a/.gitlab/issue_templates/050 Backport.md b/.gitlab/issue_templates/050 Backport.md index f6d6ab34a7cd..e9380a5cee7c 100644 --- a/.gitlab/issue_templates/050 Backport.md +++ b/.gitlab/issue_templates/050 Backport.md @@ -1,31 +1,39 @@ +# ⬅️ Backport Patchset +please ensure the title has the following format: + +- Backport tor-browser#12345: Title of original issue +- Backport Bugzilla 1234567: Title of original issue -## Backport Patchset +--> -### Book-keeping +## Bookkeeping -#### Issue(s) +### Issue(s) - tor-browser#12345 - mullvad-browser#123 - https://bugzilla.mozilla.org/show_bug.cgi?id=1234567 -#### Merge Request(s) +### Merge Request(s) - tor-browser!123 -#### Target Channels +### Target Channels - [ ] Alpha - [ ] Stable - [ ] Legacy -### Notes +## Notes + + + +--- + +/label ~"Apps::Product::TorBrowser" /label ~"Apps::Type::Backport" diff --git a/.gitlab/issue_templates/060 Rebase - Alpha.md b/.gitlab/issue_templates/060 Rebase - Alpha.md index 2e6381bf827c..fe8dc649222f 100644 --- a/.gitlab/issue_templates/060 Rebase - Alpha.md +++ b/.gitlab/issue_templates/060 Rebase - Alpha.md @@ -1,3 +1,5 @@ +# ⤵️ Rebase Alpha + **NOTE:** All examples in this template reference the rebase from 102.7.0esr to 102.8.0esr
@@ -152,4 +154,10 @@ - [ ] Update `firefox_platform_version` - [ ] Set `browser_build` to 1 (to prevent failures in alpha testbuilds) + + +--- + +/label ~"Apps::Product::TorBrowser" /label ~"Apps::Type::Rebase" +/label ~"Apps::Priority::Blocker" diff --git a/.gitlab/issue_templates/061 Rebase - Stable.md b/.gitlab/issue_templates/061 Rebase - Stable.md index 9176729f2301..a324c2059fac 100644 --- a/.gitlab/issue_templates/061 Rebase - Stable.md +++ b/.gitlab/issue_templates/061 Rebase - Stable.md @@ -1,3 +1,5 @@ +# ⤵️ Rebase Stable + **NOTE:** All examples in this template reference the rebase from 102.7.0esr to 102.8.0esr
@@ -114,4 +116,10 @@ ``` - [ ] Push tag to `upstream` + + +--- + +/label ~"Apps::Product::TorBrowser" /label ~"Apps::Type::Rebase" +/label ~"Apps::Priority::Blocker" diff --git a/.gitlab/issue_templates/063 Rebase - Rapid.md b/.gitlab/issue_templates/063 Rebase - Rapid.md index e5e913aff1a1..96a182524866 100644 --- a/.gitlab/issue_templates/063 Rebase - Rapid.md +++ b/.gitlab/issue_templates/063 Rebase - Rapid.md @@ -1,3 +1,5 @@ +# ⤵️ Rebase Rapid + - **NOTE**: All examples in this template reference the rebase from Firefox 129.0a1 to 130.0a1 - **TODO**: - Documentation step for any difficulties or noteworthy things for each rapid rebase @@ -289,4 +291,10 @@ gitGraph: ``` - [ ] Push tag to `upstream` + + +--- + +/label ~"Apps::Product::TorBrowser" /label ~"Apps::Type::Rebase" +/label ~"Apps::Priority::High" diff --git a/.gitlab/issue_templates/090 Emergency Security Issue.md b/.gitlab/issue_templates/090 Emergency Security Issue.md index 33e6a1d7452a..b60fbc5a9af4 100644 --- a/.gitlab/issue_templates/090 Emergency Security Issue.md +++ b/.gitlab/issue_templates/090 Emergency Security Issue.md @@ -1,3 +1,5 @@ +# 🚨 Emergency Security Issue + **NOTE** This is an issue template to standardise our process for responding to and fixing critical security and privacy vulnerabilities, exploits, etc. ## Information @@ -31,9 +33,10 @@ - [ ] **clairehurst** : Android, macOS - [ ] **dan** : Android, macOS - [ ] **henry** : accessibility, frontend, localisation + - [ ] **jwilde** : windows, firefox internals - [ ] **ma1** : firefox internals - [ ] **pierov** : updater, fonts, localisation, general - - [ ] **richard** : signing, release + - [ ] **morgan** : signing, release - [ ] **thorin** : fingerprinting - [ ] Other Engineering Teams - [ ] Networking (**ahf**, **dgoulet**) @@ -80,11 +83,20 @@ Sometimes fixes have side-effects: users lose their data, roadmaps need to be ad - [ ] **(Optional)** **gazebook** - if there are consequences to the organisation or partners beyond a browser update, then a communication plan may be needed +Godspeed! :pray: + + + +--- + /cc @bella /cc @ma1 /cc @micah -/cc @richard +/cc @morgan /confidential -Godspeed! :pray: +/label ~"Apps::Product::TorBrowser" +/label ~"Apps::Product::MullvadBrowser" +/label ~"Apps::Type::Bug" +/label ~"Apps::Priority::Blocker" -- GitLab From 88dd35f168622ad2c5516aa407cd159f27f57a6c Mon Sep 17 00:00:00 2001 From: Richard Pospesel Date: Sat, 29 Jun 2024 02:39:03 +0000 Subject: [PATCH 025/250] BB 42683: Create script to generate issue triage csv file from bugzilla query and git logs --- .../generate-bugzilla-triage-csv.sh | 239 ++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100755 tools/torbrowser/generate-bugzilla-triage-csv.sh diff --git a/tools/torbrowser/generate-bugzilla-triage-csv.sh b/tools/torbrowser/generate-bugzilla-triage-csv.sh new file mode 100755 index 000000000000..0dc791dd7743 --- /dev/null +++ b/tools/torbrowser/generate-bugzilla-triage-csv.sh @@ -0,0 +1,239 @@ +#!/usr/bin/env bash + +# prints to stderr +function echoerr() { echo "$@" 1>&2; } + +# help dialog +if [ "$#" -lt 5 ]; then + echoerr "Usage: $0 ff-version begin-commit end-commit gitlab-audit-issue reviewers..." + echoerr "" + echoerr "Writes a CSV to stdout of Bugzilla issues to triage for a particular Firefox version. This" + echoerr "script performs a union of the labeled Bugzilla issues in Mozilla's issue tracker and the" + echoerr "labeled commits in the provided commit range" + echoerr + echoerr " ff-version rapid-release Firefox version to audit" + echoerr " begin-commit starting gecko-dev commit of this Firefox version" + echoerr " end-commit ending gecko-dev commit of this Firefox version" + echoerr " gitlab-audit-issue tor-browser-spec Gitlab issue number for this audit" + echoerr " reviewers... space-separated list of reviewers responsible for this audit" + echoerr "" + echoerr "Example:" + echoerr "" + echoerr "$0 116 FIREFOX_ESR_115_BASE FIREFOX_116_0_3_RELEASE 40064 richard pierov henry" + exit 1 +fi + +# set -x +set -e + + +# Ensure various required tools are available +function check_exists() { + local cmd=$1 + if ! which ${cmd} > /dev/null ; then + echoerr "missing ${cmd} dependency" + exit 1 + fi +} + +check_exists git +check_exists jq +check_exists mktemp +check_exists perl +check_exists printf +check_exists sed +check_exists sort +check_exists touch +check_exists uniq +check_exists wget + +# Assign arguments to named variables +firefox_version=$1 +git_begin=$2 +git_end=$3 +audit_issue=$4 +reviewers="${@:5}" + +# Check valid Firefox version +if ! [[ "${firefox_version}" =~ ^[1-9][0-9]{2}$ ]]; then + echoerr "invalid Firefox version (probably)" + exit 1 +fi + +# Check valid Gitlab issue number +if ! [[ "${audit_issue}" =~ ^[1-9][0-9]{4}$ ]]; then + echoerr "invalid gitlab audit issue number (probably)" + exit 1 +fi + +# +# Encoding/Decoding Functions +# + +# escape " and \ +function json_escape() { + local input="$1" + echo "${input}" | sed 's/["\]/\\"/g' +} + + +# un-escape \" +function jq_unescape() { + local input="$1" + echo "${input}" | sed 's/\\"/"/g' +} + +# change quotes to double-quotes +function csv_escape() { + local input="$1" + echo "${input}" | sed 's/"/""/g' +} + +# we need to urlencode the strings used in the new issue link +function url_encode() { + local input="$1" + echo "${input}" | perl -MURI::Escape -wlne 'print uri_escape $_' +} + + +# +# Create temp json files +# +git_json=$(mktemp -t git-audit-${firefox_version}-XXXXXXXXXXX.json) +bugzilla_json=$(mktemp -t bugzilla-audit-${firefox_version}-XXXXXXXXXXX.json) +union_json=$(mktemp -t union-audit-${firefox_version}-XXXXXXXXXXX.json) +touch "${git_json}" +touch "${bugzilla_json}" +touch "${union_json}" + +function json_cleanup { + rm -f "${git_json}" + rm -f "${bugzilla_json}" + rm -f "${union_json}" +} +trap json_cleanup EXIT + +# +# Generate Git Commit Triage List +# + +# Try and extract bug id and summary from git log +# Mozilla's commits are not always 100% consistently named, so this +# regex is a bit flexible to handle various inputs such as: +# "Bug 1234 -", "Bug 1234:", "Bug Bug 1234 -", "[Bug 1234] -", " bug 1234 -". +sed_extract_id_summary="s/^[[ ]*[bug –-]+ ([1-9][0-9]*)[]:\., –-]*(.*)\$/\\1 \\2/pI" + +# Generate a json array of objects in the same format as bugzilla: {id: number, summary: string} +printf "[\n" >> "${git_json}" + +first_object=true +git log --format='%s' $git_begin..$git_end \ +| sed -En "${sed_extract_id_summary}" \ +| sort -h \ +| uniq \ +| while IFS= read -r line; do + read -r id summary <<< "${line}" + summary=$(json_escape "${summary}") + + # json does not allow trailing commas + if [[ "${first_object}" = true ]]; then + first_object=false + else + printf ",\n" >> "${git_json}" + fi + + printf " { \"id\": %s, \"summary\": \"%s\" }" ${id} "${summary}" >> "${git_json}" +done +printf "\n]\n" >> "${git_json}" + +# +# Download Bugzilla Triage List +# + +# search for: +# + Product is NOT "Thunderbird,Calander,Chat Core,MailNews Core" (&f1=product&n1=1&o1=anyexact&v1=Thunderbird%2CCalendar%2CChat%20Core%2CMailNews%20Core). AND +# + Target Milestone contains "${firefox_version}" (115 Branch or Firefox 115) (&f2=target_milestone&o2=substring&v2=${firefox_version}). +# "&limit=0" shows all matching bugs. + +query_tail="&f1=product&n1=1&o1=anyexact&v1=Thunderbird%2CCalendar%2CChat%20Core%2CMailNews%20Core&f2=target_milestone&o2=substring&v2=${firefox_version}&limit=0" + +bugzilla_query="https://bugzilla.mozilla.org/buglist.cgi?${query_tail}" +bugzilla_json_query="https://bugzilla.mozilla.org/rest/bug?include_fields=id,component,summary${query_tail}" + +wget "${bugzilla_json_query}" -O ${bugzilla_json} + + +# +# Create Union of these two sets of issues +# + +# bugzilla array is actually on a root object: { bugs: [...] } +jq -s '[ (.[0].bugs)[], (.[1])[] ] | group_by(.id) | map(.[0])' "${bugzilla_json}" "${git_json}" > "${union_json}" + +# +# Generate Triage CSV +# + +echo "\"Review\",,\"Bugzilla Component\",\"Bugzilla Bug\"" + +jq '. | sort_by([.component, .id])[] | "\(.id)|\(.component)|\(.summary)"' ${union_json} \ +| while IFS='|' read -r id component summary; do + + # bugzilla info + id="${id:1}" + component="${component:0}" + summary="${summary:0:-1}" + summary=$(jq_unescape "${summary}") + # short summary for gitlab issue title + [[ ${#summary} -gt 80 ]] && summary_short="${summary:0:77}..." || summary_short="${summary}" + + # filter out some issue types that we never care about + skip_issue=false + + # skip `[wpt-sync] Sync PR` + if [[ "${summary}" =~ ^\[wpt-sync\]\ Sync\ PR.*$ ]]; then + skip_issue=true + # skip `Crash in [@` and variants + elif [[ "${summary}" =~ ^Crash[esin\ ]*\ \[\@.*$ ]]; then + skip_issue=true + # skip `Assertion failuire: ` + elif [[ "${summary}" =~ ^Assertion\ failure:\ .*$ ]]; then + skip_issue=true + # skip `Hit MOZ_CRASH` + elif [[ "${summary}" =~ ^Hit\ MOZ_CRASH.*$ ]]; then + skip_issue=true + fi + + if [[ "${skip_issue}" = true ]]; then + echoerr "Skipped Bugzilla ${id}: ${summary_short}" + else + csv_summary=$(csv_escape "${summary}") + csv_component=$(csv_escape "${component}") + + # parent issue + bugzilla_url="https://bugzilla.mozilla.org/show_bug.cgi?id=${id}" + # review issue title + new_issue_title=$(url_encode "Review Mozilla ${id}: ${summary_short}") + # review issue description + labeling (14.0 stable, FF128-esr, Next) + new_issue_description=$(url_encode "### Bugzilla: ${bugzilla_url}")%0A$(url_encode "/label ~\"14.0 stable\" ~FF128-esr ~Next")%0A$(url_encode "/relate tpo/applications/tor-browser-spec#${audit_issue}")%0A%0A$(url_encode "")%0A + # url which create's new issue with title and description pre-populated + new_issue_url="https://gitlab.torproject.org/tpo/applications/tor-browser/-/issues/new?issue[title]=${new_issue_title}&issue[description]=${new_issue_description}" + + # this link will start the creation of a new gitlab issue to review + create_issue=$(csv_escape "=HYPERLINK(\"${new_issue_url}\", \"New Issue\")") + bugzilla_link=$(csv_escape "=HYPERLINK(\"${bugzilla_url}\", \"Bugzilla ${id}: ${csv_summary}\")") + + echo "FALSE,\"${create_issue}\",\"${csv_component}\",\"${bugzilla_link}\"," + fi +done + +echo +echo "\"Triaged by:\"" +for reviewer in $reviewers; do + reviewer=$(csv_escape "${reviewer}") + echo "\"FALSE\",\"${reviewer}\"" +done +echo + +bugzilla_query="=HYPERLINK(\"${bugzilla_query}\", \"Bugzilla query\")" +echo \"$(csv_escape "${bugzilla_query}")\" -- GitLab From 318af331aa47119f51db5f5cedf15b9329313678 Mon Sep 17 00:00:00 2001 From: Henry Wilkes Date: Tue, 21 Jan 2025 10:46:15 +0000 Subject: [PATCH 026/250] BB 42305: Add script to combine translation files across versions. --- .../l10n/combine-translation-versions.py | 397 +++++++++++++++ tools/base-browser/l10n/combine/__init__.py | 3 + tools/base-browser/l10n/combine/combine.py | 206 ++++++++ tools/base-browser/l10n/combine/tests/README | 2 + .../l10n/combine/tests/__init__.py | 0 .../l10n/combine/tests/test_android.py | 415 +++++++++++++++ .../l10n/combine/tests/test_dtd.py | 413 +++++++++++++++ .../l10n/combine/tests/test_fluent.py | 477 ++++++++++++++++++ .../l10n/combine/tests/test_properties.py | 410 +++++++++++++++ 9 files changed, 2323 insertions(+) create mode 100644 tools/base-browser/l10n/combine-translation-versions.py create mode 100644 tools/base-browser/l10n/combine/__init__.py create mode 100644 tools/base-browser/l10n/combine/combine.py create mode 100644 tools/base-browser/l10n/combine/tests/README create mode 100644 tools/base-browser/l10n/combine/tests/__init__.py create mode 100644 tools/base-browser/l10n/combine/tests/test_android.py create mode 100644 tools/base-browser/l10n/combine/tests/test_dtd.py create mode 100644 tools/base-browser/l10n/combine/tests/test_fluent.py create mode 100644 tools/base-browser/l10n/combine/tests/test_properties.py diff --git a/tools/base-browser/l10n/combine-translation-versions.py b/tools/base-browser/l10n/combine-translation-versions.py new file mode 100644 index 000000000000..5684d1726017 --- /dev/null +++ b/tools/base-browser/l10n/combine-translation-versions.py @@ -0,0 +1,397 @@ +import argparse +import json +import logging +import os +import re +import subprocess + +from combine import combine_files + +arg_parser = argparse.ArgumentParser( + description="Combine a translation file across two different versions" +) + +arg_parser.add_argument( + "current_branch", metavar="", help="branch for the newest version" +) +arg_parser.add_argument( + "files", metavar="", help="JSON specifying the translation files" +) +arg_parser.add_argument("outname", metavar="", help="name of the json output") + +args = arg_parser.parse_args() + +logging.basicConfig() +logger = logging.getLogger("combine-translation-versions") +logger.setLevel(logging.INFO) + + +def in_pink(msg: str) -> str: + """Present a message as pink in the terminal output. + + :param msg: The message to wrap in pink. + :returns: The message to print to terminal. + """ + # Pink and bold. + return f"\x1b[1;38;5;212m{msg}\x1b[0m" + + +def git_run(git_args: list[str]) -> None: + """Run a git command. + + :param git_args: The arguments that should follow "git". + """ + # Add some text to give context to git's stderr appearing in log. + logger.info("Running: " + in_pink("git " + " ".join(git_args))) + subprocess.run(["git", *git_args], check=True) + + +def git_text(git_args: list[str]) -> str: + """Get the text output for a git command. + + :param git_args: The arguments that should follow "git". + :returns: The stdout of the command. + """ + logger.info("Running: " + in_pink("git " + " ".join(git_args))) + return subprocess.run( + ["git", *git_args], text=True, check=True, stdout=subprocess.PIPE + ).stdout + + +def git_lines(git_args: list[str]) -> list[str]: + """Get the lines from a git command. + + :param git_args: The arguments that should follow "git". + :returns: The non-empty lines from stdout of the command. + """ + return [line for line in git_text(git_args).split("\n") if line] + + +class TranslationFile: + """Represents a translation file.""" + + def __init__(self, path: str, content: str) -> None: + self.path = path + self.content = content + + +class BrowserBranch: + """Represents a browser git branch.""" + + def __init__(self, branch_name: str, is_head: bool = False) -> None: + """Create a new instance. + + :param branch_name: The branch's git name. + :param is_head: Whether the branch matches "HEAD". + """ + version_match = re.match( + r"(?P[a-z]+\-browser)\-" + r"(?P[0-9]+(?:\.[0-9]+){1,2})esr\-" + r"(?P[0-9]+\.[05])\-" + r"(?P[0-9]+)$", + branch_name, + ) + + if not version_match: + raise ValueError(f"Unable to parse the version from the ref {branch_name}") + + self.name = branch_name + self.prefix = version_match.group("prefix") + self.browser_version = version_match.group("browser") + # Convert tor-browser to "Tor Browser", and similar. + browser_name = self.prefix.replace("-", " ").title() + self.browser_version_name = f"{browser_name} {self.browser_version}" + + self._is_head = is_head + self._ref = "HEAD" if is_head else f"origin/{branch_name}" + + firefox_nums = [int(n) for n in version_match.group("firefox").split(".")] + if len(firefox_nums) == 2: + firefox_nums.append(0) + browser_nums = [int(n) for n in self.browser_version.split(".")] + branch_number = int(version_match.group("number")) + # Prioritise the firefox ESR version, then the browser version then the + # branch number. + self._ordered = ( + firefox_nums[0], + firefox_nums[1], + firefox_nums[2], + browser_nums[0], + browser_nums[1], + branch_number, + ) + + # Minor version for browser is only ever "0" or "5", so we can convert + # the version to an integer. + self._browser_int_version = int(2 * float(self.browser_version)) + + self._file_paths: list[str] | None = None + + def release_below(self, other: "BrowserBranch", num: int) -> bool: + """Determine whether another branch is within range of a previous + browser release. + + The browser versions are expected to increment by "0.5", and a previous + release branch's version is expected to be `num * 0.5` behind the + current one. + + :param other: The branch to compare. + :param num: The number of "0.5" releases behind to test with. + """ + return other._browser_int_version == self._browser_int_version - num + + def __lt__(self, other: "BrowserBranch") -> bool: + return self._ordered < other._ordered + + def __gt__(self, other: "BrowserBranch") -> bool: + return self._ordered > other._ordered + + def _matching_dirs(self, path: str, dir_list: list[str]) -> bool: + """Test that a path is contained in the list of dirs. + + :param path: The path to check. + :param dir_list: The list of directories to check against. + :returns: Whether the path matches. + """ + for dir_path in dir_list: + if os.path.commonpath([dir_path, path]) == dir_path: + return True + return False + + def get_file( + self, filename: str, search_dirs: list[str] | None + ) -> TranslationFile | None: + """Fetch the file content for the named file in this branch. + + :param filename: The name of the file to fetch the content for. + :param search_dirs: The directories to restrict the search to, or None + to search for the file anywhere. + :returns: The file, or `None` if no file could be found. + """ + if self._file_paths is None: + if not self._is_head: + # Minimal fetch of non-HEAD branch to get the file paths. + # Individual file blobs will be downloaded as needed. + git_run( + ["fetch", "--depth=1", "--filter=blob:none", "origin", self.name] + ) + self._file_paths = git_lines( + ["ls-tree", "-r", "--format=%(path)", self._ref] + ) + + matching = [ + path + for path in self._file_paths + if os.path.basename(path) == filename + and (search_dirs is None or self._matching_dirs(path, search_dirs)) + ] + if not matching: + return None + if len(matching) > 1: + raise Exception(f"Multiple occurrences of {filename}") + + path = matching[0] + + return TranslationFile( + path=path, content=git_text(["cat-file", "blob", f"{self._ref}:{path}"]) + ) + + +def get_stable_branch( + compare_version: BrowserBranch, +) -> tuple[BrowserBranch, BrowserBranch | None]: + """Find the most recent stable branch in the origin repository. + + :param compare_version: The development branch to compare against. + :returns: The stable and legacy branches. If no legacy branch is found, + `None` will be returned instead. + """ + # We search for build1 tags. These are added *after* the rebase of browser + # commits, so the corresponding branch should contain our strings. + # Moreover, we *assume* that the branch with the most recent ESR version + # with such a tag will be used in the *next* stable build in + # tor-browser-build. + tag_glob = f"{compare_version.prefix}-*-build1" + + # To speed up, only fetch the tags without blobs. + git_run( + ["fetch", "--depth=1", "--filter=object:type=tag", "origin", "tag", tag_glob] + ) + stable_branches = [] + legacy_branches = [] + stable_annotation_regex = re.compile(r"\bstable\b") + legacy_annotation_regex = re.compile(r"\blegacy\b") + tag_pattern = re.compile( + rf"^{re.escape(compare_version.prefix)}-[^-]+esr-[^-]+-[^-]+-build1$" + ) + + for build_tag, annotation in ( + line.split(" ", 1) for line in git_lines(["tag", "-n1", "--list", tag_glob]) + ): + if not tag_pattern.match(build_tag): + continue + is_stable = bool(stable_annotation_regex.search(annotation)) + is_legacy = bool(legacy_annotation_regex.search(annotation)) + if not is_stable and not is_legacy: + continue + try: + # Branch name is the same as the tag, minus "-build1". + branch = BrowserBranch(re.sub(r"-build1$", "", build_tag)) + except ValueError: + logger.warning(f"Could not read the version for {build_tag}") + continue + if branch.prefix != compare_version.prefix: + continue + if is_stable: + # Stable can be one release version behind. + # NOTE: In principle, when switching between versions there may be a + # window of time where the development branch has not yet progressed + # to the next "0.5" release, so has the same browser version as the + # stable branch. So we also allow for matching browser versions. + # NOTE: + # 1. The "Will be unused in" message will not make sense, but we do + # not expect string differences in this scenario. + # 2. We do not expect this scenario to last for long. + if not ( + compare_version.release_below(branch, 1) + or compare_version.release_below(branch, 0) + ): + continue + stable_branches.append(branch) + elif is_legacy: + # Legacy can be two release versions behind. + # We also allow for being just one version behind. + if not ( + compare_version.release_below(branch, 2) + or compare_version.release_below(branch, 1) + ): + continue + legacy_branches.append(branch) + + if not stable_branches: + raise Exception("No stable build1 branch found") + + return ( + # Return the stable branch with the highest version. + max(stable_branches), + max(legacy_branches) if legacy_branches else None, + ) + + +current_branch = BrowserBranch(args.current_branch, is_head=True) + +stable_branch, legacy_branch = get_stable_branch(current_branch) + +if os.environ.get("TRANSLATION_INCLUDE_LEGACY", "") != "true": + legacy_branch = None + +files_list = [] + +for file_dict in json.loads(args.files): + name = file_dict["name"] + where_dirs = file_dict.get("where", None) + current_file = current_branch.get_file(name, where_dirs) + stable_file = stable_branch.get_file(name, where_dirs) + + if current_file is None and stable_file is None: + # No file in either branch. + logger.warning(f"{name} does not exist in either the current or stable branch") + elif current_file is None: + logger.warning(f"{name} deleted in the current branch") + elif stable_file is None: + logger.warning(f"{name} does not exist in the stable branch") + elif current_file.path != stable_file.path: + logger.warning( + f"{name} has different paths in the current and stable branch. " + f"{current_file.path} : {stable_file.path}" + ) + + content = None if current_file is None else current_file.content + + # If we have a branding file, we want to also include strings from the other + # branding directories that differ from the stable release. + # The strings that *differ* per release should be specified in + # file_dict["branding"]["ids"]. These strings will be copied from the other + # release's branding directory, with an addition suffix added to their ID, + # as specified in the version_dict["suffix"]. + branding = file_dict.get("branding", None) + if branding: + include_ids = branding["ids"] + for version_dict in branding["versions"]: + branding_dirs = version_dict.get("where", None) + branding_file = current_branch.get_file(name, branding_dirs) + if branding_file is None: + raise Exception(f"{name} does not exist in {branding_dirs}") + content = combine_files( + name, + content, + branding_file.content, + f'{version_dict["name"]} Release.', + include_ids, + version_dict["suffix"], + ) + + content = combine_files( + name, + content, + None if stable_file is None else stable_file.content, + f"Will be unused in {current_branch.browser_version_name}!", + ) + + if legacy_branch and not file_dict.get("exclude-legacy", False): + legacy_file = legacy_branch.get_file(name, where_dirs) + if legacy_file is not None and current_file is None and stable_file is None: + logger.warning(f"{name} still exists in the legacy branch") + elif legacy_file is None: + logger.warning(f"{name} does not exist in the legacy branch") + elif stable_file is not None and legacy_file.path != stable_file.path: + logger.warning( + f"{name} has different paths in the stable and legacy branch. " + f"{stable_file.path} : {legacy_file.path}" + ) + elif current_file is not None and legacy_file.path != current_file.path: + logger.warning( + f"{name} has different paths in the current and legacy branch. " + f"{current_file.path} : {legacy_file.path}" + ) + + content = combine_files( + name, + content, + legacy_file.content, + f"Unused in {stable_branch.browser_version_name}!", + ) + elif legacy_branch: + logger.info(f"Excluding legacy branch for {name}") + + files_list.append( + { + "name": name, + # If "directory" is unspecified, we place the file directly beneath + # en-US/ in the translation repository. i.e. "". + "directory": file_dict.get("directory", ""), + "branch": file_dict["branch"], + "content": content, + } + ) + + +ci_commit = os.environ.get("CI_COMMIT_SHA", "") +ci_url_base = os.environ.get("CI_PROJECT_URL", "") + +json_data = { + "commit": ci_commit, + "commit-url": ( + f"{ci_url_base}/-/commit/{ci_commit}" if (ci_commit and ci_url_base) else "" + ), + "project-path": os.environ.get("CI_PROJECT_PATH", ""), + "current-branch": current_branch.name, + "stable-branch": stable_branch.name, + "files": files_list, +} + +if legacy_branch: + json_data["legacy-branch"] = legacy_branch.name + +with open(args.outname, "w") as file: + json.dump(json_data, file) diff --git a/tools/base-browser/l10n/combine/__init__.py b/tools/base-browser/l10n/combine/__init__.py new file mode 100644 index 000000000000..67dc30efbea0 --- /dev/null +++ b/tools/base-browser/l10n/combine/__init__.py @@ -0,0 +1,3 @@ +# flake8: noqa + +from .combine import combine_files diff --git a/tools/base-browser/l10n/combine/combine.py b/tools/base-browser/l10n/combine/combine.py new file mode 100644 index 000000000000..964b7d3b4303 --- /dev/null +++ b/tools/base-browser/l10n/combine/combine.py @@ -0,0 +1,206 @@ +import re +from typing import TYPE_CHECKING, Any + +from compare_locales.parser import getParser +from compare_locales.parser.android import AndroidEntity, DocumentWrapper +from compare_locales.parser.base import Comment, Entity, Junk, Whitespace +from compare_locales.parser.dtd import DTDEntity +from compare_locales.parser.fluent import FluentComment, FluentEntity +from compare_locales.parser.properties import PropertiesEntity + +if TYPE_CHECKING: + from collections.abc import Iterable + + +def combine_files( + filename: str, + primary_content: str | None, + alternative_content: str | None, + comment_prefix: str, + include_ids: list[str] | None = None, + alternative_suffix: str = "", +) -> str | None: + """Combine two translation files into one to include all strings from both. + The primary content is presented first, followed by the alternative content + at the end with an additional comment. + + :param filename: The filename for the file, determines the format. + :param primary_content: The primary content for the file, or None if it does + not exist. + :param alternative_content: The alternative content for the file, or None if + it does not exist. + :param comment_prefix: A comment to include for any strings that are + appended to the content. This will be placed before any other comments for + the string. + :param include_ids: String IDs from `alternative_content` we want to + include. If this is `None` then we include all strings that do not already + have a matching ID in `primary_content`. + :param duplicate_suffix: The suffix to apply to the alternative IDs. + + :returns: The combined content, or None if both given contents are None. + """ + if primary_content is None and alternative_content is None: + return None + + # getParser from compare_locale returns the same instance for the same file + # extension. + parser = getParser(filename) + + is_android = filename.endswith(".xml") + if primary_content is None: + if is_android: + # File was deleted, add some document parts. + content_start = ( + '\n\n' + ) + content_end = "\n" + else: + # Treat as an empty file. + content_start = "" + content_end = "" + existing_keys = [] + else: + parser.readUnicode(primary_content) + + # Start with the same content as the current file. + # For android strings, we want to keep the final "" until after. + if is_android: + closing_match = re.match( + r"^(.*)(\s*)$", parser.ctx.contents, re.DOTALL + ) + if not closing_match: + raise ValueError("Missing a final ") + content_start = closing_match.group(1) + content_end = closing_match.group(2) + else: + content_start = parser.ctx.contents + content_end = "" + existing_keys = [entry.key for entry in parser.walk(only_localizable=True)] + + # For Fluent, we want to prefix the strings using GroupComments. + # On weblate this will cause all the strings that fall under the GroupComment's + # scope to have the prefix added to their "notes". + # We set up an initial GroupComment for the first string we find. This will also + # end the scope of the last GroupComment in the new translation file. + # This will be replaced with a the next GroupComment when it is found. + fluent_group_comment_prefix = f"\n## {comment_prefix}\n" + fluent_group_comment: str | None = fluent_group_comment_prefix + + # For other formats, we want to keep all the comment lines that come directly + # before the string. + # In compare_locales.parser, only the comment line directly before an Entity + # counts as the pre_comment for that Entity. I.e. only this line will be + # included in Entity.all + # However, in weblate every comment line that comes before the Entity is + # included as a comment. So we also want to keep these additional comments to + # preserve them for weblate. + # We gather these extra comments in stacked_comments, and clear them whenever we + # reach an Entity or a blank line (Whitespace is more than "\n"). + stacked_comments: list[str] = [] + + additions: list[str] = [] + + entry_iter: Iterable[Any] = () + # If the file does not exist in the old branch, don't make any additions. + if alternative_content is not None: + parser.readUnicode(alternative_content) + entry_iter = parser.walk(only_localizable=False) + for entry in entry_iter: + if isinstance(entry, Junk): + raise ValueError(f"Unexpected Junk: {entry.all}") + if isinstance(entry, Whitespace): + # Clear stacked comments if more than one empty line. + if entry.all != "\n": + stacked_comments.clear() + continue + if isinstance(entry, Comment): + if isinstance(entry, FluentComment): + # Don't stack Fluent comments. + # Only the comments included in Entity.pre_comment count towards + # that Entity's comment. + if entry.all.startswith("##"): + # A Fluent GroupComment + if entry.all == "##": + # Empty GroupComment. Used to end the scope of a previous + # GroupComment. + # Replace this with our prefix comment. + fluent_group_comment = fluent_group_comment_prefix + else: + # Prefix the group comment. + fluent_group_comment = ( + f"{fluent_group_comment_prefix}{entry.all}\n" + ) + else: + stacked_comments.append(entry.all) + continue + if isinstance(entry, DocumentWrapper): + # Not needed. + continue + + if not isinstance(entry, Entity): + raise ValueError(f"Unexpected type: {entry.__class__.__name__}") + + if include_ids is None: + # We include the entry if it is not already included. + include_entry = entry.key not in existing_keys + else: + # We include the entry if it is in our list. + include_entry = entry.key in include_ids + if not include_entry: + # Drop the gathered comments for this Entity. + stacked_comments.clear() + continue + + if isinstance(entry, FluentEntity): + id_regex = rf"^({re.escape(entry.key)})( *=)" + if fluent_group_comment is not None: + # We have a found GroupComment which has not been included yet. + # All following Entity's will be under its scope, until the next + # GroupComment. + additions.append(fluent_group_comment) + # Added GroupComment, so don't need to add again. + fluent_group_comment = None + elif isinstance(entry, DTDEntity): + id_regex = rf"^(\s*") + elif isinstance(entry, PropertiesEntity): + id_regex = rf"^({re.escape(entry.key)})( *=)" + additions.append(f"# {comment_prefix}") + elif isinstance(entry, AndroidEntity): + id_regex = rf'^(\s*]*name="{re.escape(entry.key)})(")' + additions.append(f"") + else: + raise ValueError(f"Unexpected Entity type: {entry.__class__.__name__}") + + # Add any other comment lines that came directly before this Entity. + additions.extend(stacked_comments) + stacked_comments.clear() + entry_content = entry.all + if alternative_suffix: + # NOTE: compare_locales does not allow us to set the entry.key + # value. Instead we use a regular expression to append the suffix to + # the expected key. + entry_content, count = re.subn( + id_regex, rf"\1{alternative_suffix}\2", entry_content, flags=re.M + ) + if count != 1: + raise ValueError(f"Failed to substitute the ID for {entry.key}") + additions.append(entry_content) + + content_middle = "" + + if additions: + # New line before and after the additions + additions.insert(0, "") + additions.append("") + if is_android: + content_middle = "\n ".join(additions) + else: + content_middle = "\n".join(additions) + + # Remove " " in otherwise blank lines. + content_middle = re.sub("^ +$", "", content_middle, flags=re.MULTILINE) + + return content_start + content_middle + content_end diff --git a/tools/base-browser/l10n/combine/tests/README b/tools/base-browser/l10n/combine/tests/README new file mode 100644 index 000000000000..c7403e87a4a5 --- /dev/null +++ b/tools/base-browser/l10n/combine/tests/README @@ -0,0 +1,2 @@ +python tests to be run with pytest. +Requires the compare-locales package. diff --git a/tools/base-browser/l10n/combine/tests/__init__.py b/tools/base-browser/l10n/combine/tests/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tools/base-browser/l10n/combine/tests/test_android.py b/tools/base-browser/l10n/combine/tests/test_android.py new file mode 100644 index 000000000000..e221f626b8d4 --- /dev/null +++ b/tools/base-browser/l10n/combine/tests/test_android.py @@ -0,0 +1,415 @@ +import textwrap + +from combine import combine_files + + +def wrap_in_xml(content): + if content is None: + return None + # Allow for indents to make the tests more readable. + content = textwrap.dedent(content) + return f"""\ + + +{textwrap.indent(content, " ")} +""" + + +def assert_result(new_content, old_content, expect): + new_content = wrap_in_xml(new_content) + old_content = wrap_in_xml(old_content) + expect = wrap_in_xml(expect) + assert expect == combine_files( + "test_strings.xml", new_content, old_content, "REMOVED STRING" + ) + + +def assert_alternative(content, alternative_content, alternative_ids, expect): + content = wrap_in_xml(content) + alternative_content = wrap_in_xml(alternative_content) + expect = wrap_in_xml(expect) + assert expect == combine_files( + "test_strings.xml", + content, + alternative_content, + "ALTERNATIVE STRING", + alternative_ids, + "_alt", + ) + + +def test_combine_empty(): + assert_result(None, None, None) + + +def test_combine_new_file(): + # New file with no old content. + assert_result( + """\ + First + Second + """, + None, + """\ + First + Second + """, + ) + + +def test_combine_removed_file(): + # Entire file was removed. + assert_result( + None, + """\ + First + Second + """, + """\ + + + First + + Second + """, + ) + + +def test_no_change(): + content = """\ + First + Second + """ + assert_result(content, content, content) + + +def test_added_string(): + assert_result( + """\ + First + NEW + Second + """, + """\ + First + Second + """, + """\ + First + NEW + Second + """, + ) + + +def test_removed_string(): + assert_result( + """\ + First + Second + """, + """\ + First + REMOVED + Second + """, + """\ + First + Second + + + REMOVED + """, + ) + + +def test_removed_and_added(): + assert_result( + """\ + New string + First + Second + New string 2 + """, + """\ + First + First removed + Second removed + Second + Third removed + """, + """\ + New string + First + Second + New string 2 + + + First removed + + Second removed + + Third removed + """, + ) + + +def test_updated(): + # String content was updated. + assert_result( + """\ + NEW + """, + """\ + OLD + """, + """\ + NEW + """, + ) + + +def test_updated_comment(): + # String comment was updated. + assert_result( + """\ + + string + """, + """\ + + string + """, + """\ + + string + """, + ) + # Comment added. + assert_result( + """\ + + string + """, + """\ + string + """, + """\ + + string + """, + ) + # Comment removed. + assert_result( + """\ + string + """, + """\ + + string + """, + """\ + string + """, + ) + + # With file comments + assert_result( + """\ + + + + string + """, + """\ + + + + string + """, + """\ + + + + string + """, + ) + + +def test_reordered(): + # String was re_ordered. + assert_result( + """\ + value + move + """, + """\ + move + value + """, + """\ + value + move + """, + ) + + +def test_removed_string_with_comment(): + assert_result( + """\ + + First + Second + """, + """\ + + First + + REMOVED + Second + """, + """\ + + First + Second + + + + REMOVED + """, + ) + + # With file comments and multi-line. + # All comments prior to a removed string are moved with it, until another + # entity or blank line is reached. + assert_result( + """\ + + + + + First + + + + + Second + """, + """\ + + + + + First + First removed + + Second removed + + + + + + Third removed + + + + + Fourth removed + Second + """, + """\ + + + + + First + + + + + Second + + + First removed + + + Second removed + + + + Third removed + + Fourth removed + """, + ) + + +def test_alternatives(): + assert_alternative( + """\ + First string + """, + """\ + Alternative string + """, + ["string_1"], + """\ + First string + + + Alternative string + """, + ) + assert_alternative( + """\ + + First string + + Second string + Third string + """, + """\ + First string + + Alternative string + Third string different + Other string + """, + ["string_2"], + """\ + + First string + + Second string + Third string + + + + Alternative string + """, + ) + assert_alternative( + """\ + First string + Second string + Third string + """, + """\ + Alternative string + Third string + + Other string + """, + ["string_1", "string_4"], + """\ + First string + Second string + Third string + + + Alternative string + + + Other string + """, + ) diff --git a/tools/base-browser/l10n/combine/tests/test_dtd.py b/tools/base-browser/l10n/combine/tests/test_dtd.py new file mode 100644 index 000000000000..879c4b480eca --- /dev/null +++ b/tools/base-browser/l10n/combine/tests/test_dtd.py @@ -0,0 +1,413 @@ +import textwrap + +from combine import combine_files + + +def assert_result(new_content, old_content, expect): + # Allow for indents to make the tests more readable. + if new_content is not None: + new_content = textwrap.dedent(new_content) + if old_content is not None: + old_content = textwrap.dedent(old_content) + if expect is not None: + expect = textwrap.dedent(expect) + assert expect == combine_files( + "test.dtd", new_content, old_content, "REMOVED STRING" + ) + + +def assert_alternative(content, alternative_content, alternative_ids, expect): + if content is not None: + content = textwrap.dedent(content) + if alternative_content is not None: + alternative_content = textwrap.dedent(alternative_content) + if expect is not None: + expect = textwrap.dedent(expect) + assert expect == combine_files( + "test.dtd", + content, + alternative_content, + "ALTERNATIVE STRING", + alternative_ids, + ".alt", + ) + + +def test_combine_empty(): + assert_result(None, None, None) + + +def test_combine_new_file(): + # New file with no old content. + assert_result( + """\ + + + """, + None, + """\ + + + """, + ) + + +def test_combine_removed_file(): + # Entire file was removed. + assert_result( + None, + """\ + + + """, + """\ + + + + + + """, + ) + + +def test_no_change(): + content = """\ + + + """ + assert_result(content, content, content) + + +def test_added_string(): + assert_result( + """\ + + + + """, + """\ + + + """, + """\ + + + + """, + ) + + +def test_removed_string(): + assert_result( + """\ + + + """, + """\ + + + + """, + """\ + + + + + + """, + ) + + +def test_removed_and_added(): + assert_result( + """\ + + + + + """, + """\ + + + + + + """, + """\ + + + + + + + + + + + + """, + ) + + +def test_updated(): + # String content was updated. + assert_result( + """\ + + """, + """\ + + """, + """\ + + """, + ) + + +def test_updated_comment(): + # String comment was updated. + assert_result( + """\ + + + """, + """\ + + + """, + """\ + + + """, + ) + # Comment added. + assert_result( + """\ + + + """, + """\ + + """, + """\ + + + """, + ) + # Comment removed. + assert_result( + """\ + + """, + """\ + + + """, + """\ + + """, + ) + + # With multiple comments + assert_result( + """\ + + + + + """, + """\ + + + + + """, + """\ + + + + + """, + ) + + +def test_reordered(): + # String was re.ordered. + assert_result( + """\ + + + """, + """\ + + + """, + """\ + + + """, + ) + + +def test_removed_string_with_comment(): + assert_result( + """\ + + + + """, + """\ + + + + + + """, + """\ + + + + + + + + """, + ) + + # With multiple lines of comments. + + assert_result( + """\ + + + + + + + + + + """, + """\ + + + + + + + + + + + + + + + + + + + """, + """\ + + + + + + + + + + + + + + + + + + + + + + """, + ) + + +def test_alternatives(): + assert_alternative( + """\ + + """, + """\ + + """, + ["string.1"], + """\ + + + + + """, + ) + assert_alternative( + """\ + + + + + + """, + """\ + + + + + + """, + ["string.2"], + """\ + + + + + + + + + + """, + ) + assert_alternative( + """\ + + + + """, + """\ + + + + + """, + ["string.1", "string.4"], + """\ + + + + + + + + + + """, + ) diff --git a/tools/base-browser/l10n/combine/tests/test_fluent.py b/tools/base-browser/l10n/combine/tests/test_fluent.py new file mode 100644 index 000000000000..a5a4e9664672 --- /dev/null +++ b/tools/base-browser/l10n/combine/tests/test_fluent.py @@ -0,0 +1,477 @@ +import textwrap + +from combine import combine_files + + +def assert_result(new_content, old_content, expect): + # Allow for indents to make the tests more readable. + if new_content is not None: + new_content = textwrap.dedent(new_content) + if old_content is not None: + old_content = textwrap.dedent(old_content) + if expect is not None: + expect = textwrap.dedent(expect) + assert expect == combine_files( + "test.ftl", new_content, old_content, "REMOVED STRING" + ) + + +def assert_alternative(content, alternative_content, alternative_ids, expect): + if content is not None: + content = textwrap.dedent(content) + if alternative_content is not None: + alternative_content = textwrap.dedent(alternative_content) + if expect is not None: + expect = textwrap.dedent(expect) + assert expect == combine_files( + "test.ftl", + content, + alternative_content, + "ALTERNATIVE STRING", + alternative_ids, + "-alt", + ) + + +def test_combine_empty(): + assert_result(None, None, None) + + +def test_combine_new_file(): + # New file with no old content. + assert_result( + """\ + string-1 = First + string-2 = Second + """, + None, + """\ + string-1 = First + string-2 = Second + """, + ) + + +def test_combine_removed_file(): + # Entire file was removed. + assert_result( + None, + """\ + string-1 = First + string-2 = Second + """, + """\ + + + ## REMOVED STRING + + string-1 = First + string-2 = Second + """, + ) + + +def test_no_change(): + content = """\ + string-1 = First + string-2 = Second + """ + assert_result(content, content, content) + + +def test_added_string(): + assert_result( + """\ + string-1 = First + string-new = NEW + string-2 = Second + """, + """\ + string-1 = First + string-2 = Second + """, + """\ + string-1 = First + string-new = NEW + string-2 = Second + """, + ) + + +def test_removed_string(): + assert_result( + """\ + string-1 = First + string-2 = Second + """, + """\ + string-1 = First + removed = REMOVED + string-2 = Second + """, + """\ + string-1 = First + string-2 = Second + + + ## REMOVED STRING + + removed = REMOVED + """, + ) + + +def test_removed_and_added(): + assert_result( + """\ + new-1 = New string + string-1 = + .attr = First + string-2 = Second + new-2 = + .title = New string 2 + """, + """\ + string-1 = + .attr = First + removed-1 = First removed + removed-2 = + .attr = Second removed + string-2 = Second + removed-3 = Third removed + """, + """\ + new-1 = New string + string-1 = + .attr = First + string-2 = Second + new-2 = + .title = New string 2 + + + ## REMOVED STRING + + removed-1 = First removed + removed-2 = + .attr = Second removed + removed-3 = Third removed + """, + ) + + +def test_updated(): + # String content was updated. + assert_result( + """\ + changed-string = NEW + """, + """\ + changed-string = OLD + """, + """\ + changed-string = NEW + """, + ) + + +def test_updated_comment(): + # String comment was updated. + assert_result( + """\ + # NEW + changed-string = string + """, + """\ + # OLD + changed-string = string + """, + """\ + # NEW + changed-string = string + """, + ) + # Comment added. + assert_result( + """\ + # NEW + changed-string = string + """, + """\ + changed-string = string + """, + """\ + # NEW + changed-string = string + """, + ) + # Comment removed. + assert_result( + """\ + changed-string = string + """, + """\ + # OLD + changed-string = string + """, + """\ + changed-string = string + """, + ) + + # With group comments. + assert_result( + """\ + ## GROUP NEW + + # NEW + changed-string = string + """, + """\ + ## GROUP OLD + + # OLD + changed-string = string + """, + """\ + ## GROUP NEW + + # NEW + changed-string = string + """, + ) + + +def test_reordered(): + # String was re-ordered. + assert_result( + """\ + string-1 = value + moved-string = move + """, + """\ + moved-string = move + string-1 = value + """, + """\ + string-1 = value + moved-string = move + """, + ) + + +def test_removed_string_with_comment(): + assert_result( + """\ + # Comment for first. + string-1 = First + string-2 = Second + """, + """\ + # Comment for first. + string-1 = First + # Comment for removed. + removed = REMOVED + string-2 = Second + """, + """\ + # Comment for first. + string-1 = First + string-2 = Second + + + ## REMOVED STRING + + # Comment for removed. + removed = REMOVED + """, + ) + + # Group comments are combined with the "REMOVED STRING" comments. + # If strings have no group comment, then a single "REMOVED STRING" is + # included for them. + assert_result( + """\ + ## First Group comment + + # Comment for first. + string-1 = First + + ## + + no-group = No group comment + + ## Second + ## Group comment + + string-2 = Second + """, + """\ + ## First Group comment + + # Comment for first. + string-1 = First + removed-1 = First removed + # Comment for second removed. + removed-2 = Second removed + + ## + + no-group = No group comment + removed-3 = Third removed + + ## Second + ## Group comment + + removed-4 = Fourth removed + string-2 = Second + """, + """\ + ## First Group comment + + # Comment for first. + string-1 = First + + ## + + no-group = No group comment + + ## Second + ## Group comment + + string-2 = Second + + + ## REMOVED STRING + ## First Group comment + + removed-1 = First removed + # Comment for second removed. + removed-2 = Second removed + + ## REMOVED STRING + + removed-3 = Third removed + + ## REMOVED STRING + ## Second + ## Group comment + + removed-4 = Fourth removed + """, + ) + + +def test_alternatives(): + assert_alternative( + """\ + string-1 = First string + .title = hello + """, + """\ + string-1 = Alternative string + .title = different + """, + ["string-1"], + """\ + string-1 = First string + .title = hello + + + ## ALTERNATIVE STRING + + string-1-alt = Alternative string + .title = different + """, + ) + assert_alternative( + """\ + string-1 = First string + .title = hello + """, + """\ + string-1 = Alternative string + """, + ["string-1"], + """\ + string-1 = First string + .title = hello + + + ## ALTERNATIVE STRING + + string-1-alt = Alternative string + """, + ) + assert_alternative( + """\ + -term-1 = First string + """, + """\ + -term-1 = Alternative string + """, + ["-term-1"], + """\ + -term-1 = First string + + + ## ALTERNATIVE STRING + + -term-1-alt = Alternative string + """, + ) + assert_alternative( + """\ + # Comment 1 + string-1 = First string + # Comment 2 + string-2 = Second string + string-3 = Third string + """, + """\ + string-1 = First string + # Alt comment + string-2 = Alternative string + string-3 = Third string different + string-4 = Other string + """, + ["string-2"], + """\ + # Comment 1 + string-1 = First string + # Comment 2 + string-2 = Second string + string-3 = Third string + + + ## ALTERNATIVE STRING + + # Alt comment + string-2-alt = Alternative string + """, + ) + assert_alternative( + """\ + string-1 = First string + string-2 = Second string + string-3 = Third string + """, + """\ + string-1 = Alternative string + string-3 = Third string + # comment + -string-4 = Other string + """, + ["string-1", "-string-4"], + """\ + string-1 = First string + string-2 = Second string + string-3 = Third string + + + ## ALTERNATIVE STRING + + string-1-alt = Alternative string + # comment + -string-4-alt = Other string + """, + ) diff --git a/tools/base-browser/l10n/combine/tests/test_properties.py b/tools/base-browser/l10n/combine/tests/test_properties.py new file mode 100644 index 000000000000..a944e7a5e017 --- /dev/null +++ b/tools/base-browser/l10n/combine/tests/test_properties.py @@ -0,0 +1,410 @@ +import textwrap + +from combine import combine_files + + +def assert_result(new_content, old_content, expect): + # Allow for indents to make the tests more readable. + if new_content is not None: + new_content = textwrap.dedent(new_content) + if old_content is not None: + old_content = textwrap.dedent(old_content) + if expect is not None: + expect = textwrap.dedent(expect) + assert expect == combine_files( + "test.properties", new_content, old_content, "REMOVED STRING" + ) + + +def assert_alternative(content, alternative_content, alternative_ids, expect): + if content is not None: + content = textwrap.dedent(content) + if alternative_content is not None: + alternative_content = textwrap.dedent(alternative_content) + if expect is not None: + expect = textwrap.dedent(expect) + assert expect == combine_files( + "test.properties", + content, + alternative_content, + "ALTERNATIVE STRING", + alternative_ids, + ".alt", + ) + + +def test_combine_empty(): + assert_result(None, None, None) + + +def test_combine_new_file(): + # New file with no old content. + assert_result( + """\ + string.1 = First + string.2 = Second + """, + None, + """\ + string.1 = First + string.2 = Second + """, + ) + + +def test_combine_removed_file(): + # Entire file was removed. + assert_result( + None, + """\ + string.1 = First + string.2 = Second + """, + """\ + + # REMOVED STRING + string.1 = First + # REMOVED STRING + string.2 = Second + """, + ) + + +def test_no_change(): + content = """\ + string.1 = First + string.2 = Second + """ + assert_result(content, content, content) + + +def test_added_string(): + assert_result( + """\ + string.1 = First + string.new = NEW + string.2 = Second + """, + """\ + string.1 = First + string.2 = Second + """, + """\ + string.1 = First + string.new = NEW + string.2 = Second + """, + ) + + +def test_removed_string(): + assert_result( + """\ + string.1 = First + string.2 = Second + """, + """\ + string.1 = First + removed = REMOVED + string.2 = Second + """, + """\ + string.1 = First + string.2 = Second + + # REMOVED STRING + removed = REMOVED + """, + ) + + +def test_removed_and_added(): + assert_result( + """\ + new.1 = New string + string.1 = First + string.2 = Second + new.2 = New string 2 + """, + """\ + string.1 = First + removed.1 = First removed + removed.2 = Second removed + string.2 = Second + removed.3 = Third removed + """, + """\ + new.1 = New string + string.1 = First + string.2 = Second + new.2 = New string 2 + + # REMOVED STRING + removed.1 = First removed + # REMOVED STRING + removed.2 = Second removed + # REMOVED STRING + removed.3 = Third removed + """, + ) + + +def test_updated(): + # String content was updated. + assert_result( + """\ + changed.string = NEW + """, + """\ + changed.string = OLD + """, + """\ + changed.string = NEW + """, + ) + + +def test_updated_comment(): + # String comment was updated. + assert_result( + """\ + # NEW + changed.string = string + """, + """\ + # OLD + changed.string = string + """, + """\ + # NEW + changed.string = string + """, + ) + # Comment added. + assert_result( + """\ + # NEW + changed.string = string + """, + """\ + changed.string = string + """, + """\ + # NEW + changed.string = string + """, + ) + # Comment removed. + assert_result( + """\ + changed.string = string + """, + """\ + # OLD + changed.string = string + """, + """\ + changed.string = string + """, + ) + + # With file comments + assert_result( + """\ + # NEW file comment + + # NEW + changed.string = string + """, + """\ + # OLD file comment + + # OLD + changed.string = string + """, + """\ + # NEW file comment + + # NEW + changed.string = string + """, + ) + + +def test_reordered(): + # String was re.ordered. + assert_result( + """\ + string.1 = value + moved.string = move + """, + """\ + moved.string = move + string.1 = value + """, + """\ + string.1 = value + moved.string = move + """, + ) + + +def test_removed_string_with_comment(): + assert_result( + """\ + # Comment for first. + string.1 = First + string.2 = Second + """, + """\ + # Comment for first. + string.1 = First + # Comment for removed. + removed = REMOVED + string.2 = Second + """, + """\ + # Comment for first. + string.1 = First + string.2 = Second + + # REMOVED STRING + # Comment for removed. + removed = REMOVED + """, + ) + + # With file comments and multi-line. + # All comments prior to a removed string are moved with it, until another + # entity or blank line is reached. + assert_result( + """\ + # First File comment + + # Comment for first. + # Comment 2 for first. + string.1 = First + + # Second + # File comment + + string.2 = Second + """, + """\ + # First File comment + + # Comment for first. + # Comment 2 for first. + string.1 = First + removed.1 = First removed + # Comment for second removed. + removed.2 = Second removed + + # Removed file comment + + # Comment 1 for third removed + # Comment 2 for third removed + removed.3 = Third removed + + # Second + # File comment + + removed.4 = Fourth removed + string.2 = Second + """, + """\ + # First File comment + + # Comment for first. + # Comment 2 for first. + string.1 = First + + # Second + # File comment + + string.2 = Second + + # REMOVED STRING + removed.1 = First removed + # REMOVED STRING + # Comment for second removed. + removed.2 = Second removed + # REMOVED STRING + # Comment 1 for third removed + # Comment 2 for third removed + removed.3 = Third removed + # REMOVED STRING + removed.4 = Fourth removed + """, + ) + + +def test_alternatives(): + assert_alternative( + """\ + string.1 = First string + """, + """\ + string.1 = Alternative string + """, + ["string.1"], + """\ + string.1 = First string + + # ALTERNATIVE STRING + string.1.alt = Alternative string + """, + ) + assert_alternative( + """\ + # Comment 1 + string.1 = First string + # Comment 2 + string.2 = Second string + string.3 = Third string + """, + """\ + string.1 = First string + # Alt comment + string.2 = Alternative string + string.3 = Third string different + string.4 = Other string + """, + ["string.2"], + """\ + # Comment 1 + string.1 = First string + # Comment 2 + string.2 = Second string + string.3 = Third string + + # ALTERNATIVE STRING + # Alt comment + string.2.alt = Alternative string + """, + ) + assert_alternative( + """\ + string.1 = First string + string.2 = Second string + string.3 = Third string + """, + """\ + string.1 = Alternative string + string.3 = Third string + # comment + string.4 = Other string + """, + ["string.1", "string.4"], + """\ + string.1 = First string + string.2 = Second string + string.3 = Third string + + # ALTERNATIVE STRING + string.1.alt = Alternative string + # ALTERNATIVE STRING + # comment + string.4.alt = Other string + """, + ) -- GitLab From 5bf49d59ffdba4e883820bd17dd6aae926797e0d Mon Sep 17 00:00:00 2001 From: Beatriz Rizental Date: Wed, 5 Mar 2025 10:26:08 +0100 Subject: [PATCH 027/250] BB 43535: Enable tests --- testing/specialpowers/api.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/testing/specialpowers/api.js b/testing/specialpowers/api.js index a0ffe42b3208..d5ad622f0fb5 100644 --- a/testing/specialpowers/api.js +++ b/testing/specialpowers/api.js @@ -40,6 +40,18 @@ this.specialpowers = class extends ExtensionAPI { uri, resProto.ALLOW_CONTENT_ACCESS ); + } else { + // This is a hack! + // For some reason, this specific substituion has an extra `/` in the path. + // This is a workaround to fix it. + // + // TODO (#43545): Remove this once we have a proper fix. + let uri = resProto.getSubstitution("testing-common"); + resProto.setSubstitution( + "testing-common", + Services.io.newURI(uri.spec.replace("file:////", "file:///")), + resProto.ALLOW_CONTENT_ACCESS + ); } SpecialPowersParent.registerActor(); -- GitLab From 746c9243c3562a5cf7aa056e1de0d54f3e897199 Mon Sep 17 00:00:00 2001 From: Beatriz Rizental Date: Wed, 19 Jun 2024 09:46:19 +0200 Subject: [PATCH 028/250] Add CI for Base Browser --- .gitlab-ci.yml | 12 + .gitlab/ci/docker/base/Dockerfile | 69 ++++++ .gitlab/ci/jobs/lint/helpers.py | 123 ++++++++++ .gitlab/ci/jobs/lint/lint.yml | 296 ++++++++++++++++++++++++ .gitlab/ci/jobs/update-translations.yml | 53 +++++ .gitlab/ci/mixins.yml | 70 ++++++ 6 files changed, 623 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 .gitlab/ci/docker/base/Dockerfile create mode 100755 .gitlab/ci/jobs/lint/helpers.py create mode 100644 .gitlab/ci/jobs/lint/lint.yml create mode 100644 .gitlab/ci/jobs/update-translations.yml create mode 100644 .gitlab/ci/mixins.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000000..557c4c89b7fa --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,12 @@ +stages: + - lint + - update-translations + +variables: + IMAGE_PATH: containers.torproject.org/tpo/applications/tor-browser/base:latest + LOCAL_REPO_PATH: /srv/apps-repos/tor-browser.git + +include: + - local: '.gitlab/ci/mixins.yml' + - local: '.gitlab/ci/jobs/lint/lint.yml' + - local: '.gitlab/ci/jobs/update-translations.yml' diff --git a/.gitlab/ci/docker/base/Dockerfile b/.gitlab/ci/docker/base/Dockerfile new file mode 100644 index 000000000000..aa5cdaddd9a8 --- /dev/null +++ b/.gitlab/ci/docker/base/Dockerfile @@ -0,0 +1,69 @@ +FROM debian:latest + +# Base image which includes all* dependencies checked by ./mach configure. +# +# * Actually not all dependencies. WASM sandboxed depencies were left out for now. +# This installs all dependencies checked by `./mach configure --without-wasm-sandboxed-libraries`. +# +# # Building and publishing +# +# Whenever this file changes, the updated Docker image must be built and published _manually_ to +# the tor-browser container registry (https://gitlab.torproject.org/tpo/applications/tor-browser/container_registry/185). +# +# This image copies a script from the taskcluster/ folder, which requires it +# to be built from a folder which is a parent of the taskcluster/ folder. +# +# To build, run: +# +# ```bash +# docker build \ +# -f \ +# -t /: +# . +# ``` +# +# For example, when building from the root of this repository to the main tor-browser repository +# and assuming image name to be "base" and tag "latest" -- which is the current terminology: +# +# ```bash +# docker build \ +# -f .gitlab/ci/docker/Dockerfile \ +# -t containers.torproject.org/tpo/applications/tor-browser/base:latest +# . +# ``` + +RUN apt-get update && apt-get install -y \ + clang \ + curl \ + git \ + libasound2-dev \ + libdbus-glib-1-dev \ + libgtk-3-dev \ + libpango1.0-dev \ + libpulse-dev \ + libx11-xcb-dev \ + libxcomposite-dev \ + libxcursor-dev \ + libxdamage-dev \ + libxi-dev \ + libxrandr-dev \ + libxtst-dev \ + m4 \ + mercurial \ + nasm \ + pkg-config \ + python3 \ + python3-pip \ + unzip \ + wget + +COPY taskcluster/docker/recipes/install-node.sh /scripts/install-node.sh +RUN chmod +x /scripts/install-node.sh +RUN /scripts/install-node.sh + +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +RUN $HOME/.cargo/bin/cargo install cbindgen + +WORKDIR /app + +CMD ["/bin/bash"] diff --git a/.gitlab/ci/jobs/lint/helpers.py b/.gitlab/ci/jobs/lint/helpers.py new file mode 100755 index 000000000000..aa12aca59019 --- /dev/null +++ b/.gitlab/ci/jobs/lint/helpers.py @@ -0,0 +1,123 @@ +#!/usr/bin/env python3 + +import argparse +import os +import re +import shlex +import subprocess + + +def git(command): + result = subprocess.run( + ["git"] + shlex.split(command), check=True, capture_output=True, text=True + ) + return result.stdout.strip() + + +def get_firefox_tag(reference): + """Extracts the Firefox tag associated with a branch or tag name. + + The "firefox tag" is the tag that marks + the end of the Mozilla commits and the start of the Tor Project commits. + + Know issue: If ever there is more than one tag per Firefox ESR version, + this function may return the incorrect reference number. + + Args: + reference: The branch or tag name to extract the Firefox tag from. + Expected format is tor-browser-91.2.0esr-11.0-1, + where 91.2.0esr is the Firefox version. + + Returns: + The reference specifier of the matching Firefox tag. + An exception will be raised if anything goes wrong. + """ + + # Extracts the version number from a branch or tag name. + firefox_version = "" + match = re.search(r"(?<=browser-)([^-]+)", reference) + if match: + # TODO: Validate that what we got is actually a valid semver string? + firefox_version = match.group(1) + else: + raise ValueError(f"Failed to extract version from reference '{reference}'.") + + major_version = firefox_version.split(".")[0] + minor_patch_version = "_".join(firefox_version.split(".")[1:]) + + remote_tags = git("ls-remote --tags origin") + + # Each line looks like: + # 9edd658bfd03a6b4743ecb75fd4a9ad968603715 refs/tags/FIREFOX_91_9_0esr_BUILD1 + pattern = ( + rf"(.*)FIREFOX_{re.escape(major_version)}_{re.escape(minor_patch_version)}(.*)$" + ) + match = re.search(pattern, remote_tags, flags=re.MULTILINE) + if not match: + # Attempt to match with a nightly tag, in case the ESR tag is not found + pattern = rf"(.*)FIREFOX_NIGHTLY_{re.escape(major_version)}(.*)$" + match = re.search(pattern, remote_tags, flags=re.MULTILINE) + + if match: + return match.group(0).split()[0] + else: + raise ValueError( + f"Failed to find reference specifier for Firefox tag of version '{firefox_version}' from '{reference}'." + ) + + +def get_list_of_changed_files(): + """Gets a list of files changed in the working directory. + + This function is meant to be run inside the Gitlab CI environment. + + When running in a default branch, get the list of changed files since the last Firefox tag. + When running for a new MR commit, get a list of changed files in the current MR. + + Returns: + A list of filenames of changed files (excluding deleted files). + An exception wil be raised if anything goes wrong. + """ + + base_reference = "" + + if os.getenv("CI_PIPELINE_SOURCE") == "merge_request_event": + # For merge requests, the base_reference is the common ancestor between the MR and the target branch + base_reference = os.getenv("CI_MERGE_REQUEST_DIFF_BASE_SHA") + else: + # When not in merge requests, the base reference is the Firefox tag + base_reference = get_firefox_tag(os.getenv("CI_COMMIT_BRANCH")) + + if not base_reference: + raise RuntimeError("No base reference found. There might be more errors above.") + + # Fetch the tag reference + git(f"fetch origin {base_reference} --depth=1 --filter=blob:none") + # Return but filter the issue_templates files because those file names have spaces which can cause issues + return git("diff --diff-filter=d --name-only FETCH_HEAD HEAD").split("\n") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="") + + parser.add_argument( + "--get-firefox-tag", + help="Get the Firefox tag related to a given (tor-mullvad-base)-browser tag or branch name.", + type=str, + ) + parser.add_argument( + "--get-changed-files", + help="Get list of changed files." + "When running from a merge request get sthe list of changed files since the merge-base of the current branch." + "When running from a protected branch i.e. any branch that starts with -browser-, gets the list of files changed since the FIREFOX_ tag.", + action="store_true", + ) + + args = parser.parse_args() + + if args.get_firefox_tag: + print(get_firefox_tag(args.get_firefox_tag)) + elif args.get_changed_files: + print("\n".join(get_list_of_changed_files())) + else: + print("No valid option provided.") diff --git a/.gitlab/ci/jobs/lint/lint.yml b/.gitlab/ci/jobs/lint/lint.yml new file mode 100644 index 000000000000..ef810c2fdc29 --- /dev/null +++ b/.gitlab/ci/jobs/lint/lint.yml @@ -0,0 +1,296 @@ +.base: + extends: .with-local-repo-bash + stage: lint + image: $IMAGE_PATH + interruptible: true + variables: + MOZBUILD_STATE_PATH: "$CI_PROJECT_DIR/.cache/mozbuild" + cache: + paths: + - node_modules + - .cache/mozbuild + # Store the cache regardless on job outcome + when: 'always' + # Share the cache throughout all pipelines running for a given branch + key: $CI_COMMIT_REF_SLUG + tags: + # Run these jobs in the browser dedicated runners. + - firefox + +eslint: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l eslint + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + # Files that are likely audited. + - '**/*.js' + - '**/*.jsm' + - '**/*.json' + - '**/*.jsx' + - '**/*.mjs' + - '**/*.sjs' + - '**/*.html' + - '**/*.xhtml' + - '**/*.xml' + - 'tools/lint/eslint.yml' + # Run when eslint policies change. + - '**/.eslintignore' + - '**/*eslintrc*' + # The plugin implementing custom checks. + - 'tools/lint/eslint/eslint-plugin-mozilla/**' + - 'tools/lint/eslint/eslint-plugin-spidermonkey-js/**' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +stylelint: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l stylelint + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + # Files that are likely audited. + - '**/*.css' + - 'tools/lint/styleint.yml' + # Run when stylelint policies change. + - '**/.stylelintignore' + - '**/*stylelintrc*' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +py-black: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l black + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + # The list of extensions should match tools/lint/black.yml + - '**/*.py' + - '**/moz.build' + - '**/*.configure' + - '**/*.mozbuild' + - 'pyproject.toml' + - 'tools/lint/black.yml' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +py-ruff: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l ruff + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + - '**/*.py' + - '**/*.configure' + - '**/.ruff.toml' + - 'pyproject.toml' + - 'tools/lint/ruff.yml' + - 'tools/lint/python/ruff.py' + - 'tools/lint/python/ruff_requirements.txt' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +yaml: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l yaml + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + - '**/*.yml' + - '**/*.yaml' + - '**/.ymllint' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +shellcheck: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l shellcheck + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + - '**/*.sh' + - 'tools/lint/shellcheck.yml' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +clang-format: + extends: .base + script: + - ./mach configure --without-wasm-sandboxed-libraries --with-base-browser-version=0.0.0 + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l clang-format + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + - '**/*.cpp' + - '**/*.c' + - '**/*.cc' + - '**/*.h' + - '**/*.m' + - '**/*.mm' + - 'tools/lint/clang-format.yml' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +rustfmt: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l rustfmt + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + - '**/*.rs' + - 'tools/lint/rustfmt.yml' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +fluent-lint: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l fluent-lint + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + - '**/*.ftl' + - 'tools/lint/fluent-lint.yml' + - 'tools/lint/fluent-lint/exclusions.yml' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +localization: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l l10n + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + - '**/locales/en-US/**' + - '**/l10n.toml' + - 'third_party/python/compare-locales/**' + - 'third_party/python/fluent/**' + - 'tools/lint/l10n.yml' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +mingw-capitalization: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l mingw-capitalization + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + - '**/*.cpp' + - '**/*.cc' + - '**/*.c' + - '**/*.h' + - 'tools/lint/mingw-capitalization.yml' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +mscom-init: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l mscom-init + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + - '**/*.cpp' + - '**/*.cc' + - '**/*.c' + - '**/*.h' + - 'tools/lint/mscom-init.yml' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +file-whitespace: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l file-whitespace + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + - '**/*.c' + - '**/*.cc' + - '**/*.cpp' + - '**/*.css' + - '**/*.dtd' + - '**/*.idl' + - '**/*.ftl' + - '**/*.h' + - '**/*.html' + - '**/*.md' + - '**/*.properties' + - '**/*.py' + - '**/*.rs' + - '**/*.rst' + - '**/*.webidl' + - '**/*.xhtml' + - '**/*.java' + - 'tools/lint/file-whitespace.yml' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +test-manifest: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l test-manifest-alpha -l test-manifest-disable -l test-manifest-skip-if + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + - '**/*.ini' + - 'python/mozlint/**' + - 'tools/lint/**' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') + +trojan-source: + extends: .base + script: + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l trojan-source + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + # List copied from: taskcluster/ci/source-test/mozlint.yml + # + - '**/*.c' + - '**/*.cc' + - '**/*.cpp' + - '**/*.h' + - '**/*.py' + - '**/*.rs' + - 'tools/lint/trojan-source.yml' + # Run job whenever a commit is merged to a protected branch + - if: ($CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == 'true' && $CI_PIPELINE_SOURCE == 'push') diff --git a/.gitlab/ci/jobs/update-translations.yml b/.gitlab/ci/jobs/update-translations.yml new file mode 100644 index 000000000000..9074c8742533 --- /dev/null +++ b/.gitlab/ci/jobs/update-translations.yml @@ -0,0 +1,53 @@ +.update-translation-base: + stage: update-translations + rules: + - if: ($TRANSLATION_FILES != "" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push") + changes: + - "**/*.ftl" + - "**/*.properties" + - "**/*.dtd" + - "**/*strings.xml" + - "**/update-translations.yml" + - "**/l10n/combine/combine.py" + - "**/l10n/combine-translation-versions.py" + - if: ($TRANSLATION_FILES != "" && $FORCE_UPDATE_TRANSLATIONS == "true") + variables: + COMBINED_FILES_JSON: "combined-translation-files.json" + TRANSLATION_FILES: '' + + +combine-en-US-translations: + extends: .update-translation-base + needs: [] + image: python + variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + cache: + paths: + - .cache/pip + # Artifact is for translation project job + artifacts: + paths: + - "$COMBINED_FILES_JSON" + expire_in: "60 min" + reports: + dotenv: job_id.env + # Don't load artifacts for this job. + dependencies: [] + script: + # Save this CI_JOB_ID to the dotenv file to be used in the variables for the + # push-en-US-translations job. + - echo 'COMBINE_TRANSLATIONS_JOB_ID='"$CI_JOB_ID" >job_id.env + - pip install compare_locales + - python ./tools/base-browser/l10n/combine-translation-versions.py "$CI_COMMIT_BRANCH" "$TRANSLATION_FILES" "$COMBINED_FILES_JSON" + +push-en-US-translations: + extends: .update-translation-base + needs: + - job: combine-en-US-translations + variables: + COMBINED_FILES_JSON_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/jobs/${COMBINE_TRANSLATIONS_JOB_ID}/artifacts/${COMBINED_FILES_JSON}" + trigger: + strategy: depend + project: tor-browser-translation-bot/translation + branch: tor-browser-ci diff --git a/.gitlab/ci/mixins.yml b/.gitlab/ci/mixins.yml new file mode 100644 index 000000000000..7a35eac53885 --- /dev/null +++ b/.gitlab/ci/mixins.yml @@ -0,0 +1,70 @@ +.with-local-repo-bash: + variables: + GIT_STRATEGY: "none" + before_script: + - git init + - git remote add local "$LOCAL_REPO_PATH" + - | + # Determine the reference of the target branch in the local repository copy. + # + # 1. List all references in the local repository + # 2. Filter the references to the target branch + # 3. Remove tags + # 4. Keep a single line, in case there are too many matches + # 5. Clean up the output + # 6. Remove everything before the last two slashes, because the output is like `refs/heads/...` or `refs/remotes/...` + TARGET_BRANCH=$(git ls-remote local | grep ${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME} | grep -v 'refs/tags/' | awk '{print $2}' | tail -1 | sed 's|[^/]*/[^/]*/||') + if [ -z "$TARGET_BRANCH" ]; then + echo "Target branch $TARGET_BRANCH is not yet in local repository. Stopping the pipeline." + exit 1 + fi + - git fetch --depth 500 local $TARGET_BRANCH + - git remote add origin "$CI_REPOSITORY_URL" + - | + if [ -z "${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}" ]; then + echo "No branch specified. Stopping the pipeline." + exit 1 + fi + - echo "Fetching from remote branch ${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}" + - | + if ! git fetch origin "${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"; then + echo -e "\e[31mFetching failed for branch ${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} from $CI_REPOSITORY_URL.\e[0m" + echo "Attempting to fetch the merge request branch, assuming this pipeline is not running in a fork." + git fetch origin "merge-requests/${CI_MERGE_REQUEST_IID}/head" + fi + - git checkout FETCH_HEAD + +.with-local-repo-pwsh: + variables: + GIT_STRATEGY: "none" + before_script: + - git init + - git remote add local $env:LOCAL_REPO_PATH + - | + $branchName = $env:CI_COMMIT_BRANCH + if ([string]::IsNullOrEmpty($branchName)) { + $branchName = $env:CI_MERGE_REQUEST_TARGET_BRANCH_NAME + } + $TARGET_BRANCH = git ls-remote local | Select-String -Pattern $branchName | Select-String -Pattern -NotMatch 'refs/tags/' | Select-Object -Last 1 | ForEach-Object { $_.ToString().Split()[1] -replace '^[^/]*/[^/]*/', '' } + if ([string]::IsNullOrEmpty($TARGET_BRANCH)) { + Write-Output "Target branch $TARGET_BRANCH is not yet in local repository. Stopping the pipeline." + exit 1 + } + - git remote add origin $env:CI_REPOSITORY_URL + - | + $branchName = $env:CI_COMMIT_BRANCH + if ([string]::IsNullOrEmpty($branchName)) { + $branchName = $env:CI_MERGE_REQUEST_SOURCE_BRANCH_NAME + } + if ([string]::IsNullOrEmpty($branchName)) { + Write-Output "No branch specified. Stopping the pipeline." + exit 1 + } + - Write-Output "Fetching from remote branch $branchName" + - | + if (! git fetch origin $branchName) { + Write-Output "Fetching failed for branch $branchName from $env:CI_REPOSITORY_URL." + Write-Output "Attempting to fetch the merge request branch, assuming this pipeline is not running in a fork." + git fetch origin "merge-requests/$env:CI_MERGE_REQUEST_IID/head" + } + - git checkout FETCH_HEAD -- GitLab From e4067259ccb56d5beb4428f07f1e0adcae7deb22 Mon Sep 17 00:00:00 2001 From: Beatriz Rizental Date: Tue, 15 Apr 2025 22:45:53 +0200 Subject: [PATCH 029/250] fixup! Add CI for Base Browser --- .gitlab/ci/jobs/lint/lint.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.gitlab/ci/jobs/lint/lint.yml b/.gitlab/ci/jobs/lint/lint.yml index ef810c2fdc29..767e6ce90bcc 100644 --- a/.gitlab/ci/jobs/lint/lint.yml +++ b/.gitlab/ci/jobs/lint/lint.yml @@ -20,7 +20,7 @@ eslint: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l eslint + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l eslint rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -49,7 +49,7 @@ eslint: stylelint: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l stylelint + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l stylelint rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -67,7 +67,7 @@ stylelint: py-black: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l black + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l black rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -86,7 +86,7 @@ py-black: py-ruff: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l ruff + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l ruff rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -105,7 +105,7 @@ py-ruff: yaml: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l yaml + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l yaml rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -120,7 +120,7 @@ yaml: shellcheck: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l shellcheck + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l shellcheck rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -135,7 +135,7 @@ clang-format: extends: .base script: - ./mach configure --without-wasm-sandboxed-libraries --with-base-browser-version=0.0.0 - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l clang-format + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l clang-format rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -154,7 +154,7 @@ clang-format: rustfmt: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l rustfmt + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l rustfmt rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -168,7 +168,7 @@ rustfmt: fluent-lint: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l fluent-lint + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l fluent-lint rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -183,7 +183,7 @@ fluent-lint: localization: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l l10n + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l l10n rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -200,7 +200,7 @@ localization: mingw-capitalization: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l mingw-capitalization + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l mingw-capitalization rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -217,7 +217,7 @@ mingw-capitalization: mscom-init: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l mscom-init + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l mscom-init rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -234,7 +234,7 @@ mscom-init: file-whitespace: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l file-whitespace + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l file-whitespace rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -264,7 +264,7 @@ file-whitespace: test-manifest: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l test-manifest-alpha -l test-manifest-disable -l test-manifest-skip-if + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l test-manifest-alpha -l test-manifest-disable -l test-manifest-skip-if rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: @@ -279,7 +279,7 @@ test-manifest: trojan-source: extends: .base script: - - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -l trojan-source + - .gitlab/ci/jobs/lint/helpers.py --get-changed-files | xargs -d '\n' ./mach lint -v -l trojan-source rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' changes: -- GitLab From 0d44a81ca9792c91e282b462615d6261846eb960 Mon Sep 17 00:00:00 2001 From: Beatriz Rizental Date: Wed, 23 Apr 2025 01:14:00 +0200 Subject: [PATCH 030/250] fixup! Add CI for Base Browser Timeout `git fetch` if takes longer than 3min. Long fetched are very expensive and due to the amount of parallel jobs our CI can execute at a time too many long fetches can cause significant slowness on our Gitlab instance. --- .gitlab/ci/mixins.yml | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/.gitlab/ci/mixins.yml b/.gitlab/ci/mixins.yml index 7a35eac53885..d9e71fb1698a 100644 --- a/.gitlab/ci/mixins.yml +++ b/.gitlab/ci/mixins.yml @@ -1,6 +1,7 @@ .with-local-repo-bash: variables: GIT_STRATEGY: "none" + FETCH_TIMEOUT: 180 # 3 minutes before_script: - git init - git remote add local "$LOCAL_REPO_PATH" @@ -19,18 +20,38 @@ exit 1 fi - git fetch --depth 500 local $TARGET_BRANCH + - git --no-pager log FETCH_HEAD --oneline -n 5 - git remote add origin "$CI_REPOSITORY_URL" - | if [ -z "${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}" ]; then echo "No branch specified. Stopping the pipeline." exit 1 fi - - echo "Fetching from remote branch ${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}" + - echo "Fetching from remote branch ${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} with a ${FETCH_TIMEOUT}s timeout." - | - if ! git fetch origin "${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"; then - echo -e "\e[31mFetching failed for branch ${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} from $CI_REPOSITORY_URL.\e[0m" - echo "Attempting to fetch the merge request branch, assuming this pipeline is not running in a fork." - git fetch origin "merge-requests/${CI_MERGE_REQUEST_IID}/head" + fetch_with_timeout() { + local remote=$1 + local branch=$2 + + set +e + timeout ${FETCH_TIMEOUT} git fetch "$remote" "$branch" + local fetch_exit=$? + set -e + + if [ "$fetch_exit" -eq 124 ]; then + echo "Fetching failed for branch ${remote}/${branch} due to a timeout. Try again later." + echo "Gitlab may be experiencing slowness or the local copy of the repository on the CI server may be oudated." + return 1 + fi + + return $fetch_exit + } + + if ! fetch_with_timeout origin "${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"; then + echo "Fetching failed for branch ${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}." + echo "Attempting to fetch the merge request branch, assuming this pipeline is not running in a fork." + + fetch_with_timeout origin "merge-requests/${CI_MERGE_REQUEST_IID}/head" || exit 1 fi - git checkout FETCH_HEAD -- GitLab From afb2532009c774b5cc9c0831ae5543a560367da4 Mon Sep 17 00:00:00 2001 From: Pier Angelo Vendrame Date: Mon, 23 May 2022 17:01:24 +0200 Subject: [PATCH 031/250] Base Browser's .mozconfigs. Bug 17858: Cannot create incremental MARs for hardened builds. Define HOST_CFLAGS, etc. to avoid compiling programs such as mbsdiff (which is part of mar-tools and is not distributed to end-users) with ASan. Bug 21849: Don't allow SSL key logging. Bug 25741 - TBA: Disable features at compile-time Define MOZ_ANDROID_NETWORK_STATE and MOZ_ANDROID_LOCATION Bug 27623 - Export MOZILLA_OFFICIAL during desktop builds This fixes a problem where some preferences had the wrong default value. Also see bug 27472 where we made a similar fix for Android. Bug 29859: Disable HLS support for now Bug 30463: Explicitly disable MOZ_TELEMETRY_REPORTING Bug 32493: Disable MOZ_SERVICES_HEALTHREPORT Bug 33734: Set MOZ_NORMANDY to False Bug 33851: Omit Parental Controls. Bug 40252: Add --enable-rust-simd to our tor-browser mozconfig files Bug 41584: Move some configuration options to base-browser level --- browser/config/mozconfigs/base-browser | 51 +++++++++++++++++++ .../config/mozconfigs/base-browser-android | 50 ++++++++++++++++++ browser/moz.configure | 10 ++-- mobile/android/basebrowser.configure | 33 ++++++++++++ mobile/android/moz.configure | 10 +++- moz.configure | 31 +++++++++++ mozconfig-android-aarch64 | 4 ++ mozconfig-android-all | 41 +++++++++++++++ mozconfig-android-armv7 | 4 ++ mozconfig-android-x86 | 4 ++ mozconfig-android-x86_64 | 4 ++ mozconfig-linux-aarch64 | 12 +++++ mozconfig-linux-aarch64-dev | 20 ++++++++ mozconfig-linux-arm | 18 +++++++ mozconfig-linux-i686 | 16 ++++++ mozconfig-linux-x86_64 | 13 +++++ mozconfig-linux-x86_64-asan | 26 ++++++++++ mozconfig-linux-x86_64-dev | 22 ++++++++ mozconfig-macos | 12 +++++ mozconfig-macos-dev | 23 +++++++++ mozconfig-windows-i686 | 25 +++++++++ mozconfig-windows-x86_64 | 25 +++++++++ security/moz.build | 3 +- security/nss/lib/ssl/Makefile | 3 +- toolkit/modules/AppConstants.sys.mjs | 2 + 25 files changed, 454 insertions(+), 8 deletions(-) create mode 100644 browser/config/mozconfigs/base-browser create mode 100644 browser/config/mozconfigs/base-browser-android create mode 100644 mobile/android/basebrowser.configure create mode 100644 mozconfig-android-aarch64 create mode 100644 mozconfig-android-all create mode 100644 mozconfig-android-armv7 create mode 100644 mozconfig-android-x86 create mode 100644 mozconfig-android-x86_64 create mode 100644 mozconfig-linux-aarch64 create mode 100644 mozconfig-linux-aarch64-dev create mode 100644 mozconfig-linux-arm create mode 100644 mozconfig-linux-i686 create mode 100644 mozconfig-linux-x86_64 create mode 100644 mozconfig-linux-x86_64-asan create mode 100644 mozconfig-linux-x86_64-dev create mode 100644 mozconfig-macos create mode 100644 mozconfig-macos-dev create mode 100644 mozconfig-windows-i686 create mode 100644 mozconfig-windows-x86_64 diff --git a/browser/config/mozconfigs/base-browser b/browser/config/mozconfigs/base-browser new file mode 100644 index 000000000000..2e19eb652537 --- /dev/null +++ b/browser/config/mozconfigs/base-browser @@ -0,0 +1,51 @@ +# Shared build settings and settings to enhance security and privacy. + +. $topsrcdir/browser/config/mozconfig + +if test -f "$topsrcdir/mozconfig-toolchain"; then + . $topsrcdir/mozconfig-toolchain +fi + +mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@ + +ac_add_options --enable-official-branding +export MOZILLA_OFFICIAL=1 + +ac_add_options --enable-optimize +ac_add_options --enable-rust-simd + +ac_add_options --disable-unverified-updates + +ac_add_options --enable-bundled-fonts + +# See bug #41587 +ac_add_options --disable-updater + +ac_add_options --disable-tests +ac_add_options --disable-debug + +ac_add_options --disable-crashreporter +# Before removing, please notice that WebRTC does not work on mingw (Bug 1393901) +ac_add_options --disable-webrtc +ac_add_options --disable-parental-controls +ac_add_options --enable-proxy-bypass-protection +# See bugs #30575 and #32418: system policies are harmful either because they +# could allow proxy bypass, and override a number of other preferences we set +ac_add_options --disable-system-policies + +# See bug #41131 +ac_add_options --disable-backgroundtasks + +# Disable telemetry +ac_add_options MOZ_TELEMETRY_REPORTING= + +# Disable the creation of a .default that Firefox by default creates +# for old version that could not use dedicated profiles. See tor-browser#41542. +ac_add_options --disable-legacy-profile-creation + +if test -z "$WASI_SYSROOT"; then + ac_add_options --without-wasm-sandboxed-libraries +fi + +# tor-browser#42337 +ac_add_options --enable-geckodriver diff --git a/browser/config/mozconfigs/base-browser-android b/browser/config/mozconfigs/base-browser-android new file mode 100644 index 000000000000..9a39b00ebfe7 --- /dev/null +++ b/browser/config/mozconfigs/base-browser-android @@ -0,0 +1,50 @@ +# Changes on this file might need to be synchronized with mozconfig-android-all! +# See also tor-browser#43151. + +export MOZILLA_OFFICIAL=1 + +ac_add_options --enable-optimize +ac_add_options --enable-rust-simd +ac_add_options --enable-official-branding + +ac_add_options --enable-application=mobile/android + +CC="clang" +CXX="clang++" +ac_add_options --enable-linker=lld +ac_add_options --with-java-bin-path=$JAVA_HOME/bin +ac_add_options --with-android-sdk=$ANDROID_HOME +ac_add_options --with-android-ndk=$ANDROID_NDK_HOME +ac_add_options --with-android-min-sdk=21 +ac_add_options --with-gradle=$GRADLE_HOME/bin/gradle + +ac_add_options --enable-strip +ac_add_options --enable-install-strip +ac_add_options --disable-tests +ac_add_options --disable-debug +ac_add_options --disable-rust-debug + +ac_add_options --disable-updater +ac_add_options --disable-crashreporter +ac_add_options --disable-webrtc +ac_add_options --disable-parental-controls + +ac_add_options --enable-proxy-bypass-protection +ac_add_options --disable-system-policies + +# See tor-browser#41131 +ac_add_options --disable-backgroundtasks + +# Disable telemetry +ac_add_options MOZ_TELEMETRY_REPORTING= + +if test -n "$LOCAL_DEV_BUILD"; then + # You must use the "default" bogus channel for dev builds + ac_add_options --enable-update-channel=default + ac_add_options --with-base-browser-version=dev-build + ac_add_options --disable-minify +fi + +if test -z "$WASI_SYSROOT"; then + ac_add_options --without-wasm-sandboxed-libraries +fi diff --git a/browser/moz.configure b/browser/moz.configure index 6710ca8f4ba8..df7f216b1ad7 100644 --- a/browser/moz.configure +++ b/browser/moz.configure @@ -5,12 +5,14 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. imply_option("MOZ_PLACES", True) -imply_option("MOZ_SERVICES_HEALTHREPORT", True) +# tor-browser#32493 +imply_option("MOZ_SERVICES_HEALTHREPORT", False) imply_option("MOZ_SERVICES_SYNC", True) imply_option("MOZ_DEDICATED_PROFILES", True) imply_option("MOZ_BLOCK_PROFILE_DOWNGRADE", True) -imply_option("MOZ_NORMANDY", True) -imply_option("MOZ_PROFILE_MIGRATOR", True) +# tor-browser#33734 +imply_option("MOZ_NORMANDY", False) +imply_option("MOZ_PROFILE_MIGRATOR", False) imply_option("MOZ_APP_VENDOR", "Mozilla") @@ -64,7 +66,7 @@ def requires_stub_installer( "USE_STUB_INSTALLER is not specified in the environment" ) - return True + return False imply_option("MOZ_STUB_INSTALLER", True, when=requires_stub_installer) diff --git a/mobile/android/basebrowser.configure b/mobile/android/basebrowser.configure new file mode 100644 index 000000000000..2d546d39f5d5 --- /dev/null +++ b/mobile/android/basebrowser.configure @@ -0,0 +1,33 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Set Base Browser default config +# See tor-browser#25741 and tor-browser#41584. + +imply_option("MOZ_ANDROID_EXCLUDE_FONTS", False) + +# Disable uploading crash reports and dump files to an external server +# This is still configured in old-configure. Uncomment when this moves +# to the python config +# imply_option("MOZ_CRASHREPORTER", False) + +# Disable uploading information about the browser configuration and +# performance to an external server. See tor-browser#32493. +imply_option("MOZ_SERVICES_HEALTHREPORT", False) + +# Disable creating telemetry and data reports that are uploaded to an +# external server +# These aren't actually configure options. These are disabled in +# confvars.sh, but they look like configure options so we'll document +# them here, as well. +# XXX: no confvars.sh here +# imply_option("MOZ_TELEMETRY_REPORTING", False) +# imply_option("MOZ_DATA_REPORTING", False) + +# tor-browser#24796: This controls some permissions in GeckoView's +# AndroidManifest.xml +imply_option("MOZ_ANDROID_NETWORK_STATE", False) +imply_option("MOZ_ANDROID_LOCATION", False) diff --git a/mobile/android/moz.configure b/mobile/android/moz.configure index c900501ee65a..8aec08c90088 100644 --- a/mobile/android/moz.configure +++ b/mobile/android/moz.configure @@ -10,10 +10,11 @@ project_flag( default=True, ) +# tor-browser#29859 project_flag( "MOZ_ANDROID_HLS_SUPPORT", help="Enable HLS (HTTP Live Streaming) support (currently using the ExoPlayer library)", - default=True, + default=False, ) option( @@ -104,7 +105,10 @@ set_config("MOZ_ANDROID_DEBUGGABLE", android_debuggable) imply_option("MOZ_NORMANDY", False) -imply_option("MOZ_SERVICES_HEALTHREPORT", True) +# Comment this so we can imply |False| in basebrowser.configure +# The Build system doesn't allow multiple imply_option() +# calls with the same key. +# imply_option("MOZ_SERVICES_HEALTHREPORT", True) imply_option("MOZ_GECKOVIEW_HISTORY", True) imply_option("MOZ_APP_UA_NAME", "Firefox") @@ -127,6 +131,8 @@ def check_target(target): ) +include("basebrowser.configure") + include("../shared/moz.configure") include("../../toolkit/moz.configure") include("../../build/moz.configure/android-sdk.configure") diff --git a/moz.configure b/moz.configure index 5e9cc42a9715..169d15d60e52 100755 --- a/moz.configure +++ b/moz.configure @@ -945,6 +945,37 @@ with only_when(cross_compiling): ) set_config("JS_BINARY", depends_if("JS_BINARY")(lambda value: value[0])) +option( + "--with-base-browser-version", + nargs=1, + help="Set the Base Browser version, e.g., 7.0a1", +) + + +@depends("--with-base-browser-version") +def base_browser_version(value): + if not value: + die( + "--with-base-browser-version is required for Base Browser and derived browsers." + ) + return value[0] + + +@depends("--with-base-browser-version") +def base_browser_version_quoted(value): + if not value: + die( + "--with-base-browser-version is required for Base Browser and derived browsers." + ) + if '"' in value or "\\" in value: + die('--with-base-browser-version cannot contain " or \\.') + return '"{}"'.format(value[0]) + + +set_define("BASE_BROWSER_VERSION", base_browser_version) +set_define("BASE_BROWSER_VERSION_QUOTED", base_browser_version_quoted) + + # Please do not add configure checks from here on. # Fallthrough to autoconf-based configure diff --git a/mozconfig-android-aarch64 b/mozconfig-android-aarch64 new file mode 100644 index 000000000000..5e166ec9ea8c --- /dev/null +++ b/mozconfig-android-aarch64 @@ -0,0 +1,4 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser-android + +mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-aarch64-linux-android +ac_add_options --target=aarch64-linux-android diff --git a/mozconfig-android-all b/mozconfig-android-all new file mode 100644 index 000000000000..5935c2d090c7 --- /dev/null +++ b/mozconfig-android-all @@ -0,0 +1,41 @@ +# Changes on this file might need to be synchronized with +# browser/config/mozconfigs/base-browser-android! +# See also tor-browser#43151. + +export MOZILLA_OFFICIAL=1 + +ac_add_options --enable-application=mobile/android + +ac_add_options --disable-compile-environment + +ac_add_options --with-java-bin-path=$JAVA_HOME/bin +ac_add_options --with-android-sdk=$ANDROID_HOME +ac_add_options --with-gradle=$GRADLE_HOME/bin/gradle + +ac_add_options --disable-tests +ac_add_options --disable-debug + +ac_add_options --disable-updater +ac_add_options --disable-crashreporter +ac_add_options --disable-webrtc +ac_add_options --disable-parental-controls + +ac_add_options --enable-proxy-bypass-protection +ac_add_options --disable-system-policies + +# See tor-browser#41131 +ac_add_options --disable-backgroundtasks + +# Disable telemetry +ac_add_options MOZ_TELEMETRY_REPORTING= + +if test -n "$LOCAL_DEV_BUILD"; then + # You must use the "default" bogus channel for dev builds + ac_add_options --enable-update-channel=default + ac_add_options --with-base-browser-version=dev-build + ac_add_options --disable-minify +fi + +if test -z "$WASI_SYSROOT"; then + ac_add_options --without-wasm-sandboxed-libraries +fi diff --git a/mozconfig-android-armv7 b/mozconfig-android-armv7 new file mode 100644 index 000000000000..05468e50be53 --- /dev/null +++ b/mozconfig-android-armv7 @@ -0,0 +1,4 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser-android + +mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-arm-linux-androideabi +ac_add_options --target=arm-linux-androideabi diff --git a/mozconfig-android-x86 b/mozconfig-android-x86 new file mode 100644 index 000000000000..ed1c88cf396e --- /dev/null +++ b/mozconfig-android-x86 @@ -0,0 +1,4 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser-android + +mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-i386-linux-android +ac_add_options --target=i686-linux-android diff --git a/mozconfig-android-x86_64 b/mozconfig-android-x86_64 new file mode 100644 index 000000000000..f8f6a301d4fb --- /dev/null +++ b/mozconfig-android-x86_64 @@ -0,0 +1,4 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser-android + +mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-x86_64-linux-android +ac_add_options --target=x86_64-linux-android diff --git a/mozconfig-linux-aarch64 b/mozconfig-linux-aarch64 new file mode 100644 index 000000000000..45fb29cb3375 --- /dev/null +++ b/mozconfig-linux-aarch64 @@ -0,0 +1,12 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser + +ac_add_options --target=aarch64-unknown-linux-gnu + +# Moz switched to lld for all Linux targets in Bug 1839739. +ac_add_options --enable-linker=lld + +ac_add_options --disable-strip +ac_add_options --disable-install-strip + +ac_add_options --enable-default-toolkit=cairo-gtk3 + diff --git a/mozconfig-linux-aarch64-dev b/mozconfig-linux-aarch64-dev new file mode 100644 index 000000000000..1d5eeea5a734 --- /dev/null +++ b/mozconfig-linux-aarch64-dev @@ -0,0 +1,20 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser + +# This mozconfig file is not used in official builds. +# It is only intended to be used when doing incremental Linux builds +# during development. + +# Moz switched to lld for all Linux targets in Bug 1839739. +ac_add_options --enable-linker=lld + +export MOZILLA_OFFICIAL= + +ac_add_options --enable-default-toolkit=cairo-gtk3 + +ac_add_options --disable-strip +ac_add_options --disable-install-strip + +ac_add_options --with-base-browser-version=dev-build +ac_add_options --disable-base-browser-update + +ac_add_options --enable-tests diff --git a/mozconfig-linux-arm b/mozconfig-linux-arm new file mode 100644 index 000000000000..0a476ed03bb4 --- /dev/null +++ b/mozconfig-linux-arm @@ -0,0 +1,18 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser + +ac_add_options --target=arm-linux-gnueabihf + +ac_add_options --enable-default-toolkit=cairo-gtk3 + +# Bug 31448: ld.gold fails if we don't disable debug-symbols. +# Also, we keep strip enabled. +ac_add_options --disable-debug-symbols + +# From Arch Linux ARM for Firefox 102.0.1 +# https://github.com/archlinuxarm/PKGBUILDs/blob/6da804f4020487c112f59ea067e6644a309c4338/extra/firefox/PKGBUILD +ac_add_options --disable-elf-hack +ac_add_options --disable-av1 +ac_add_options --enable-optimize="-g0 -O2" +# One of the following two lines (not sure which) prevents "read-only segment has dynamic relocations" linker error. +export MOZ_DEBUG_FLAGS=" " +export RUSTFLAGS="-Cdebuginfo=0" diff --git a/mozconfig-linux-i686 b/mozconfig-linux-i686 new file mode 100644 index 000000000000..ad2991379066 --- /dev/null +++ b/mozconfig-linux-i686 @@ -0,0 +1,16 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser + +ac_add_options --target=i686-linux-gnu + +# Moz switched to lld for all Linux targets in Bug 1839739. +# Also, gold used not to work with debug symbols (tor-browser#42146). +ac_add_options --enable-linker=lld + +ac_add_options --disable-strip +ac_add_options --disable-install-strip + +ac_add_options --enable-default-toolkit=cairo-gtk3 + +# Let's make sure no preference is enabling either Adobe's or Google's CDM. +ac_add_options --disable-eme + diff --git a/mozconfig-linux-x86_64 b/mozconfig-linux-x86_64 new file mode 100644 index 000000000000..91159366e67f --- /dev/null +++ b/mozconfig-linux-x86_64 @@ -0,0 +1,13 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser + +# Moz switched to lld for all Linux targets in Bug 1839739. +ac_add_options --enable-linker=lld + +ac_add_options --disable-strip +ac_add_options --disable-install-strip + +ac_add_options --enable-default-toolkit=cairo-gtk3 + +# Let's make sure no preference is enabling either Adobe's or Google's CDM. +ac_add_options --disable-eme + diff --git a/mozconfig-linux-x86_64-asan b/mozconfig-linux-x86_64-asan new file mode 100644 index 000000000000..0d47d8e0bd99 --- /dev/null +++ b/mozconfig-linux-x86_64-asan @@ -0,0 +1,26 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser + +export CFLAGS="-fsanitize=address -Dxmalloc=myxmalloc" +export CXXFLAGS="-fsanitize=address -Dxmalloc=myxmalloc" +# We need to add -ldl explicitely due to bug 1213698 +export LDFLAGS="-fsanitize=address -ldl" + +# Define HOST_CFLAGS, etc. to avoid compiling programs such as mbsdiff +# (which is part of mar-tools and is not distributed to end-users) with +# ASan. See bug 17858. +export HOST_CFLAGS="" +export HOST_CXXFLAGS="" +export HOST_LDFLAGS="-ldl" + +ac_add_options --enable-address-sanitizer +ac_add_options --disable-jemalloc +ac_add_options --disable-elf-hack + +ac_add_options --enable-default-toolkit=cairo-gtk3 + +ac_add_options --disable-strip +ac_add_options --disable-install-strip + +# Let's make sure no preference is enabling either Adobe's or Google's CDM. +ac_add_options --disable-eme + diff --git a/mozconfig-linux-x86_64-dev b/mozconfig-linux-x86_64-dev new file mode 100644 index 000000000000..d4e1c221c440 --- /dev/null +++ b/mozconfig-linux-x86_64-dev @@ -0,0 +1,22 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser + +# This mozconfig file is not used in official builds. +# It is only intended to be used when doing incremental Linux builds +# during development. + +# Moz switched to lld for all Linux targets in Bug 1839739. +ac_add_options --enable-linker=lld + +export MOZILLA_OFFICIAL= + +ac_add_options --enable-default-toolkit=cairo-gtk3 + +ac_add_options --disable-strip +ac_add_options --disable-install-strip + +ac_add_options --with-base-browser-version=dev-build + +# Let's make sure no preference is enabling either Adobe's or Google's CDM. +ac_add_options --disable-eme + +ac_add_options --enable-tests diff --git a/mozconfig-macos b/mozconfig-macos new file mode 100644 index 000000000000..7cac6c523d50 --- /dev/null +++ b/mozconfig-macos @@ -0,0 +1,12 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser + +ac_add_options --enable-strip + +# See bug #13379 +ac_add_options --enable-nss-mar + +# See bug #41131 +ac_add_options --disable-update-agent + +# Let's make sure no preference is enabling either Adobe's or Google's CDM. +ac_add_options --disable-eme diff --git a/mozconfig-macos-dev b/mozconfig-macos-dev new file mode 100644 index 000000000000..0935e698c673 --- /dev/null +++ b/mozconfig-macos-dev @@ -0,0 +1,23 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser + +# This mozconfig file is not used in official builds. +# It is only intended to be used when doing incremental macOS builds +# during development. + +export MOZILLA_OFFICIAL= + +ac_add_options --disable-strip +ac_add_options --disable-install-strip + +ac_add_options --with-base-browser-version=dev-build + +ac_add_options --disable-base-browser-update +# See bug #13379 +ac_add_options --enable-nss-mar +# See bug #41131 +ac_add_options --disable-update-agent + +# Let's make sure no preference is enabling either Adobe's or Google's CDM. +ac_add_options --disable-eme + +ac_add_options --enable-tests diff --git a/mozconfig-windows-i686 b/mozconfig-windows-i686 new file mode 100644 index 000000000000..49363b8c99d1 --- /dev/null +++ b/mozconfig-windows-i686 @@ -0,0 +1,25 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser + +ac_add_options --target=i686-w64-mingw32 +ac_add_options --with-toolchain-prefix=i686-w64-mingw32- + +ac_add_options --enable-strip + +# Bits is Background Intelligent Transfer Service +ac_add_options --disable-bits-download +ac_add_options --disable-maintenance-service +ac_add_options --disable-default-browser-agent + +# See bug #13379 +ac_add_options --enable-nss-mar + +# See bug #41131 +ac_add_options --disable-update-agent + +# Bug 1782837: Not supported because Mozilla (and therefore also us) build +# libc++ with LIBCXX_ENABLE_FILESYSTEM disabled. +ac_add_options --disable-notification-server + +# Let's make sure no preference is enabling either Adobe's or Google's CDM. +ac_add_options --disable-eme + diff --git a/mozconfig-windows-x86_64 b/mozconfig-windows-x86_64 new file mode 100644 index 000000000000..be07911e21b2 --- /dev/null +++ b/mozconfig-windows-x86_64 @@ -0,0 +1,25 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser + +ac_add_options --target=x86_64-w64-mingw32 +ac_add_options --with-toolchain-prefix=x86_64-w64-mingw32- + +ac_add_options --enable-strip + +# Bits is Background Intelligent Transfer Service +ac_add_options --disable-bits-download +ac_add_options --disable-maintenance-service +ac_add_options --disable-default-browser-agent + +# See bug #13379 +ac_add_options --enable-nss-mar + +# See bug #41131 +ac_add_options --disable-update-agent + +# Bug 1782837: Not supported because Mozilla (and therefore also us) build +# libc++ with LIBCXX_ENABLE_FILESYSTEM disabled. +ac_add_options --disable-notification-server + +# Let's make sure no preference is enabling either Adobe's or Google's CDM. +ac_add_options --disable-eme + diff --git a/security/moz.build b/security/moz.build index 4f11c45f9d33..4d3ae7be654f 100644 --- a/security/moz.build +++ b/security/moz.build @@ -93,7 +93,8 @@ gyp_vars["nss_dist_obj_dir"] = "$PRODUCT_DIR/dist/bin" gyp_vars["disable_tests"] = 1 gyp_vars["disable_dbm"] = 1 gyp_vars["disable_libpkix"] = 1 -gyp_vars["enable_sslkeylogfile"] = 1 +# tor-browser#18885, tor-browser#21849 +gyp_vars["enable_sslkeylogfile"] = 0 # Whether we're using system NSS or Rust nssckbi, we don't need # to build C nssckbi gyp_vars["disable_ckbi"] = 1 diff --git a/security/nss/lib/ssl/Makefile b/security/nss/lib/ssl/Makefile index 61abff372117..24c66b948c60 100644 --- a/security/nss/lib/ssl/Makefile +++ b/security/nss/lib/ssl/Makefile @@ -37,7 +37,8 @@ endif # Enable key logging by default in debug builds, but not opt builds. # Logging still needs to be enabled at runtime through env vars. -NSS_ALLOW_SSLKEYLOGFILE ?= $(if $(BUILD_OPT),0,1) +# tor-browser#18885, tor-browser#21849 +NSS_ALLOW_SSLKEYLOGFILE ?= 0 ifeq (1,$(NSS_ALLOW_SSLKEYLOGFILE)) DEFINES += -DNSS_ALLOW_SSLKEYLOGFILE=1 endif diff --git a/toolkit/modules/AppConstants.sys.mjs b/toolkit/modules/AppConstants.sys.mjs index bf7a0ec9570a..235776df212c 100644 --- a/toolkit/modules/AppConstants.sys.mjs +++ b/toolkit/modules/AppConstants.sys.mjs @@ -174,6 +174,8 @@ export var AppConstants = Object.freeze({ MOZ_UPDATE_CHANNEL: "@MOZ_UPDATE_CHANNEL@", MOZ_WIDGET_TOOLKIT: "@MOZ_WIDGET_TOOLKIT@", + BASE_BROWSER_VERSION: "@BASE_BROWSER_VERSION@", + DEBUG_JS_MODULES: "@DEBUG_JS_MODULES@", MOZ_BING_API_CLIENTID: "@MOZ_BING_API_CLIENTID@", -- GitLab From 36634995daa925f67aef8a785c7a2e49e61cd82b Mon Sep 17 00:00:00 2001 From: Pier Angelo Vendrame Date: Mon, 12 May 2025 10:26:45 +0200 Subject: [PATCH 032/250] fixup! Base Browser's .mozconfigs. BB 43772: Do not use official branding for BB/TB/MB. We already pass --with-branding in our builds, no need to also pass this option. However, we should further audit what this option does, and try to recall why we added it at a certain point. --- browser/config/mozconfigs/base-browser | 1 - browser/config/mozconfigs/base-browser-android | 1 - 2 files changed, 2 deletions(-) diff --git a/browser/config/mozconfigs/base-browser b/browser/config/mozconfigs/base-browser index 2e19eb652537..d037bfc5c5bc 100644 --- a/browser/config/mozconfigs/base-browser +++ b/browser/config/mozconfigs/base-browser @@ -8,7 +8,6 @@ fi mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@ -ac_add_options --enable-official-branding export MOZILLA_OFFICIAL=1 ac_add_options --enable-optimize diff --git a/browser/config/mozconfigs/base-browser-android b/browser/config/mozconfigs/base-browser-android index 9a39b00ebfe7..2713f629b138 100644 --- a/browser/config/mozconfigs/base-browser-android +++ b/browser/config/mozconfigs/base-browser-android @@ -5,7 +5,6 @@ export MOZILLA_OFFICIAL=1 ac_add_options --enable-optimize ac_add_options --enable-rust-simd -ac_add_options --enable-official-branding ac_add_options --enable-application=mobile/android -- GitLab From 215becc22ee197c3e29e6872fd5f14a7a0aa0f5b Mon Sep 17 00:00:00 2001 From: Pier Angelo Vendrame Date: Wed, 6 Apr 2022 22:34:02 +0200 Subject: [PATCH 033/250] Tweaks to the build system Bug 40857: Modified the fat .aar creation file This is a workaround to build fat .aars with the compiling enviornment disabled. Mozilla does not use a similar configuration, but either runs a Firefox build and discards its output, or uses artifacts build. We might switch to artifact builds too, and drop this patch, or write a better one to upstream. But until then we need this patch. See also https://bugzilla.mozilla.org/show_bug.cgi?id=1763770. Bug 41458: Prevent `mach package-multi-locale` from actually creating a package macOS builds need some files to be moved around with ./mach package-multi-locale to create multi-locale packages. The required command isn't exposed through any other mach command. So, we patch package-multi-locale both to prevent it from failing when doing official builds and to detect any future changes on it. --- browser/app/moz.build | 3 ++- browser/installer/package-manifest.in | 8 ++++---- mobile/android/gradle/with_gecko_binaries.gradle | 2 +- python/mozbuild/mozbuild/mach_commands.py | 4 ++++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/browser/app/moz.build b/browser/app/moz.build index f41ce92556bb..4f9a417b1d2a 100644 --- a/browser/app/moz.build +++ b/browser/app/moz.build @@ -76,7 +76,8 @@ if CONFIG["CC_TYPE"] == "clang-cl": if CONFIG["OS_ARCH"] == "WINNT": RCINCLUDE = "splash.rc" DIRS += [ - "pbproxy", + # tor-browser#41798 don't build private_browsing.exe on Windows + # "pbproxy", "winlauncher", ] USE_LIBS += [ diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 8e02ea6ca2c6..8d76c4ade5e3 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -137,10 +137,10 @@ @BINPATH@/firefox.VisualElementsManifest.xml @BINPATH@/browser/VisualElements/VisualElements_150.png @BINPATH@/browser/VisualElements/VisualElements_70.png -@BINPATH@/private_browsing.exe -@BINPATH@/private_browsing.VisualElementsManifest.xml -@BINPATH@/browser/VisualElements/PrivateBrowsing_150.png -@BINPATH@/browser/VisualElements/PrivateBrowsing_70.png +; @BINPATH@/private_browsing.exe +; @BINPATH@/private_browsing.VisualElementsManifest.xml +; @BINPATH@/browser/VisualElements/PrivateBrowsing_150.png +; @BINPATH@/browser/VisualElements/PrivateBrowsing_70.png #else #ifndef XP_MACOSX @BINPATH@/@MOZ_APP_NAME@-bin diff --git a/mobile/android/gradle/with_gecko_binaries.gradle b/mobile/android/gradle/with_gecko_binaries.gradle index 3b0f6fa157a3..82d1eed9d653 100644 --- a/mobile/android/gradle/with_gecko_binaries.gradle +++ b/mobile/android/gradle/with_gecko_binaries.gradle @@ -16,7 +16,7 @@ def hasCompileArtifacts() { } ext.configureVariantWithGeckoBinaries = { variant -> - if (hasCompileArtifacts()) { + if (hasCompileArtifacts() || true) { // Local (read, not 'official') builds want to reflect developer changes to // the omnijar sources, and (when compiling) to reflect developer changes to // the native binaries. To do this, the Gradle build calls out to the diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py index c612aead4ff2..548e5198f6c1 100644 --- a/python/mozbuild/mozbuild/mach_commands.py +++ b/python/mozbuild/mozbuild/mach_commands.py @@ -3436,6 +3436,10 @@ def package_l10n(command_context, verbose=False, locales=[]): target = ["package"] if command_context.substs["MOZ_BUILD_APP"] == "mobile/android": target.append("AB_CD=multi") + else: + # tor-browser#41458 and tor-browser-build#40687: do not actually + # create the package (at least on desktop) + return 0 command_context._run_make( directory=command_context.topobjdir, -- GitLab From 7721ecabf6138b0f276e403447f75040700beb25 Mon Sep 17 00:00:00 2001 From: Pier Angelo Vendrame Date: Thu, 13 Jun 2024 09:22:53 +0200 Subject: [PATCH 034/250] BB 29320: Replace the gnu target with gnullvm for Rust. --- build/moz.configure/init.configure | 8 ++++++-- build/moz.configure/rust.configure | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure index 9bf4bb29a400..e0ea6e3965c1 100644 --- a/build/moz.configure/init.configure +++ b/build/moz.configure/init.configure @@ -484,12 +484,16 @@ def split_triplet(triplet, allow_wasi=False): canonical_kernel = "kFreeBSD" elif os.startswith("gnu"): canonical_os = canonical_kernel = "GNU" - elif os.startswith("mingw") or os in ("windows-msvc", "windows-gnu"): + elif os.startswith("mingw") or os in ( + "windows-msvc", + "windows-gnu", + "windows-gnullvm", + ): canonical_os = canonical_kernel = "WINNT" if not os.startswith("mingw"): if os == "windows-msvc": abi = "msvc" - elif os == "windows-gnu": + elif os == "windows-gnu" or os == "windows-gnullvm": abi = "mingw" # Many things down the line are looking for the string "mingw32" # until they are all fixed, we pretend that's the raw os we had diff --git a/build/moz.configure/rust.configure b/build/moz.configure/rust.configure index 6b0aa3dc4e6b..056851cf0c19 100644 --- a/build/moz.configure/rust.configure +++ b/build/moz.configure/rust.configure @@ -310,9 +310,9 @@ def detect_rustc_target( if host_or_target.abi == "msvc": suffix = "windows-msvc" elif host_or_target.abi == "mingw": - suffix = "windows-gnu" + suffix = "windows-gnullvm" elif compiler_info.type in ("gcc", "clang"): - suffix = "windows-gnu" + suffix = "windows-gnullvm" else: suffix = "windows-msvc" narrowed = [ -- GitLab From c5a06aa6b09ae7fe8016fab9aabd2f572373f98c Mon Sep 17 00:00:00 2001 From: Pier Angelo Vendrame Date: Tue, 18 Jun 2024 14:02:26 +0200 Subject: [PATCH 035/250] BB 42616: Remove VideoCaptureTest.kt. This is a workaround to fix the GeckoView build with WebRTC disabled. We should replace this workaround with a proper solution, that excludes this test when MOZ_WEBRTC is undefined/False. --- .../geckoview/test/VideoCaptureTest.kt | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/VideoCaptureTest.kt diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/VideoCaptureTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/VideoCaptureTest.kt deleted file mode 100644 index 7e1f8b127542..000000000000 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/VideoCaptureTest.kt +++ /dev/null @@ -1,58 +0,0 @@ -package org.mozilla.geckoview.test - -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.filters.SmallTest -import androidx.test.platform.app.InstrumentationRegistry -import org.junit.Assert.assertEquals -import org.junit.Test -import org.junit.runner.RunWith -import org.webrtc.CameraEnumerationAndroid.CaptureFormat -import org.webrtc.CameraEnumerator -import org.webrtc.CameraVideoCapturer -import org.webrtc.CameraVideoCapturer.CameraEventsHandler -import org.webrtc.videoengine.VideoCaptureAndroid - -@RunWith(AndroidJUnit4::class) -@SmallTest -class VideoCaptureTest { - // Always throw exception. - class BadCameraEnumerator : CameraEnumerator { - override fun getDeviceNames(): Array? { - throw java.lang.RuntimeException("") - } - - override fun isFrontFacing(deviceName: String?): Boolean { - throw java.lang.RuntimeException("") - } - - override fun isBackFacing(deviceName: String?): Boolean { - throw java.lang.RuntimeException("") - } - - override fun isInfrared(deviceName: String?): Boolean { - throw java.lang.RuntimeException("") - } - - override fun getSupportedFormats(deviceName: String?): List? { - throw java.lang.RuntimeException("") - } - - override fun createCapturer( - deviceName: String?, - eventsHandler: CameraEventsHandler?, - ): CameraVideoCapturer? { - throw java.lang.RuntimeException("") - } - } - - @Test - fun constructWithBadEnumerator() { - val ctr = VideoCaptureAndroid::class.java.getDeclaredConstructors()[0].apply { isAccessible = true } - val capture = ctr.newInstance( - InstrumentationRegistry.getInstrumentation().targetContext, - "my camera", - BadCameraEnumerator(), - ) as VideoCaptureAndroid - assertEquals(false, capture.canCapture()) - } -} -- GitLab From bcd25ea7e87a831849275c34348c07e99c88c0d1 Mon Sep 17 00:00:00 2001 From: Pier Angelo Vendrame Date: Wed, 17 Aug 2022 13:28:01 +0200 Subject: [PATCH 036/250] BB 41108: Remove privileged macOS installation from 102 --- toolkit/xre/MacRunFromDmgUtils.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolkit/xre/MacRunFromDmgUtils.mm b/toolkit/xre/MacRunFromDmgUtils.mm index 2a296c5256fd..0ac9050d2a99 100644 --- a/toolkit/xre/MacRunFromDmgUtils.mm +++ b/toolkit/xre/MacRunFromDmgUtils.mm @@ -262,7 +262,7 @@ static void ShowInstallFailedDialog() { NS_OBJC_END_TRY_IGNORE_BLOCK; } -#ifdef MOZ_UPDATER +#if defined(MOZ_UPDATER) && !defined(BASE_BROWSER_VERSION) bool LaunchElevatedDmgInstall(NSString* aBundlePath, NSArray* aArguments) { NSTask* task = [[NSTask alloc] init]; [task setExecutableURL:[NSURL fileURLWithPath:aBundlePath]]; @@ -291,7 +291,7 @@ static bool InstallFromPath(NSString* aBundlePath, NSString* aDestPath) { installSuccessful = true; } -#ifdef MOZ_UPDATER +#if defined(MOZ_UPDATER) && !defined(BASE_BROWSER_VERSION) // The installation may have been unsuccessful if the user did not have the // rights to write to the Applications directory. Check for this situation and // launch an elevated installation if necessary. Rather than creating a new, -- GitLab From 963fd782f9ba209cbb3efc05503ea6947fb45dd1 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Fri, 21 Oct 2022 11:39:58 -0700 Subject: [PATCH 037/250] BB 41149: Re-enable DLL injection protection in all builds not just nightlies --- toolkit/xre/dllservices/mozglue/WindowsDllBlocklist.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/toolkit/xre/dllservices/mozglue/WindowsDllBlocklist.cpp b/toolkit/xre/dllservices/mozglue/WindowsDllBlocklist.cpp index 40f35dd2171e..380b74e029b3 100644 --- a/toolkit/xre/dllservices/mozglue/WindowsDllBlocklist.cpp +++ b/toolkit/xre/dllservices/mozglue/WindowsDllBlocklist.cpp @@ -517,7 +517,7 @@ continue_loading: return ret; } -#if defined(BLOCK_LOADLIBRARY_INJECTION) +#if defined(BLOCK_LOADLIBRARY_INJECTION) || defined(BASE_BROWSER_VERSION) // Map of specific thread proc addresses we should block. In particular, // LoadLibrary* APIs which indicate DLL injection static void* gStartAddressesToBlock[4]; @@ -530,7 +530,7 @@ static bool ShouldBlockThread(void* aStartAddress) { return false; } -#if defined(BLOCK_LOADLIBRARY_INJECTION) +#if defined(BLOCK_LOADLIBRARY_INJECTION) || defined(BASE_BROWSER_VERSION) for (auto p : gStartAddressesToBlock) { if (p == aStartAddress) { return true; @@ -593,7 +593,7 @@ MFBT_API void DllBlocklist_Initialize(uint32_t aInitFlags) { } } -#if defined(BLOCK_LOADLIBRARY_INJECTION) +#if defined(BLOCK_LOADLIBRARY_INJECTION) || defined(BASE_BROWSER_VERSION) // Populate a list of thread start addresses to block. HMODULE hKernel = GetModuleHandleW(L"kernel32.dll"); if (hKernel) { -- GitLab From 0b4a7338c263f9040146c9be2071593860e087c3 Mon Sep 17 00:00:00 2001 From: Henry Wilkes Date: Wed, 28 Aug 2024 09:51:38 +0100 Subject: [PATCH 038/250] BB 43092: Disable wayland by default in Base Browser. --- toolkit/xre/nsAppRunner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 8fa70cacc475..cbc009acebd2 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -453,13 +453,14 @@ bool IsWaylandEnabled() { return true; } } + // Keep wayland disabled in Base Browser. See tor-browser#43092. + return false; // Enable by default when we're running on a recent enough GTK version. We'd // like to check further details like compositor version and so on ideally // to make sure we don't enable it on old Mutter or what not, but we can't, // so let's assume that if the user is running on a Wayland session by // default we're ok, since either the distro has enabled Wayland by default, // or the user has gone out of their way to use Wayland. - return !gtk_check_version(3, 24, 30); }(); return isWaylandEnabled; } -- GitLab From 83e18af902710d7f1c94740721ad575af07d6d61 Mon Sep 17 00:00:00 2001 From: Matthew Finkel Date: Wed, 11 Apr 2018 17:52:59 +0000 Subject: [PATCH 039/250] BB 24796: Comment out excess permissions from GeckoView The GeckoView AndroidManifest.xml is not preprocessed unlike Fennec's manifest, so we can't use the ifdef preprocessor guards around the permissions we do not want. Commenting the permissions is the next-best-thing. --- .../android/geckoview/src/main/AndroidManifest.xml | 14 ++++++++++++++ mobile/android/moz.configure | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/mobile/android/geckoview/src/main/AndroidManifest.xml b/mobile/android/geckoview/src/main/AndroidManifest.xml index 72f3d2726f5c..ba1365e2e98b 100644 --- a/mobile/android/geckoview/src/main/AndroidManifest.xml +++ b/mobile/android/geckoview/src/main/AndroidManifest.xml @@ -6,22 +6,34 @@ + + + + + + + + + + Date: Thu, 25 Oct 2018 19:17:09 +0000 Subject: [PATCH 040/250] BB 28125: Prevent non-Necko network connections --- .../upstream/DefaultHttpDataSource.java | 46 +---------------- .../gecko/media/GeckoMediaDrmBridgeV21.java | 50 +------------------ 2 files changed, 3 insertions(+), 93 deletions(-) diff --git a/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java b/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java index c0e8e23bfe27..3df3c39e1db6 100644 --- a/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java +++ b/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java @@ -531,50 +531,8 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou boolean followRedirects, Map requestParameters) throws IOException, URISyntaxException { - /** - * Tor Project modified the way the connection object was created. For the sake of - * simplicity, instead of duplicating the whole file we changed the connection object - * to use the ProxySelector. - */ - HttpURLConnection connection = (HttpURLConnection) openConnectionWithProxy(url.toURI()); - - connection.setConnectTimeout(connectTimeoutMillis); - connection.setReadTimeout(readTimeoutMillis); - - Map requestHeaders = new HashMap<>(); - if (defaultRequestProperties != null) { - requestHeaders.putAll(defaultRequestProperties.getSnapshot()); - } - requestHeaders.putAll(requestProperties.getSnapshot()); - requestHeaders.putAll(requestParameters); - - for (Map.Entry property : requestHeaders.entrySet()) { - connection.setRequestProperty(property.getKey(), property.getValue()); - } - - if (!(position == 0 && length == C.LENGTH_UNSET)) { - String rangeRequest = "bytes=" + position + "-"; - if (length != C.LENGTH_UNSET) { - rangeRequest += (position + length - 1); - } - connection.setRequestProperty("Range", rangeRequest); - } - connection.setRequestProperty("User-Agent", userAgent); - connection.setRequestProperty("Accept-Encoding", allowGzip ? "gzip" : "identity"); - connection.setInstanceFollowRedirects(followRedirects); - connection.setDoOutput(httpBody != null); - connection.setRequestMethod(DataSpec.getStringForHttpMethod(httpMethod)); - - if (httpBody != null) { - connection.setFixedLengthStreamingMode(httpBody.length); - connection.connect(); - OutputStream os = connection.getOutputStream(); - os.write(httpBody); - os.close(); - } else { - connection.connect(); - } - return connection; + Log.i(TAG, "This is Tor Browser. Skipping."); + throw new IOException(); } /** Creates an {@link HttpURLConnection} that is connected with the {@code url}. */ diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java index 5d0670f8101f..752c00cbda5a 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java @@ -523,55 +523,7 @@ public class GeckoMediaDrmBridgeV21 implements GeckoMediaDrm { @Override protected Void doInBackground(final Void... params) { - HttpURLConnection urlConnection = null; - BufferedReader in = null; - try { - final URI finalURI = - new URI(mURL + "&signedRequest=" + URLEncoder.encode(new String(mDrmRequest), "UTF-8")); - urlConnection = (HttpURLConnection) ProxySelector.openConnectionWithProxy(finalURI); - urlConnection.setRequestMethod("POST"); - if (DEBUG) Log.d(LOGTAG, "Provisioning, posting url =" + finalURI.toString()); - - // Add data - urlConnection.setRequestProperty("Accept", "*/*"); - urlConnection.setRequestProperty("User-Agent", getCDMUserAgent()); - urlConnection.setRequestProperty("Content-Type", "application/json"); - - // Execute HTTP Post Request - urlConnection.connect(); - - final int responseCode = urlConnection.getResponseCode(); - if (responseCode == HttpURLConnection.HTTP_OK) { - in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), UTF_8)); - String inputLine; - final StringBuffer response = new StringBuffer(); - - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - in.close(); - mResponseBody = String.valueOf(response).getBytes(UTF_8); - if (DEBUG) Log.d(LOGTAG, "Provisioning, response received."); - if (mResponseBody != null) Log.d(LOGTAG, "response length=" + mResponseBody.length); - } else { - Log.d(LOGTAG, "Provisioning, server returned HTTP error code :" + responseCode); - } - } catch (final IOException e) { - Log.e(LOGTAG, "Got exception during posting provisioning request ...", e); - } catch (final URISyntaxException e) { - Log.e(LOGTAG, "Got exception during creating uri ...", e); - } finally { - if (urlConnection != null) { - urlConnection.disconnect(); - } - try { - if (in != null) { - in.close(); - } - } catch (final IOException e) { - Log.e(LOGTAG, "Exception during closing in ...", e); - } - } + Log.i(LOGTAG, "This is Tor Browser. Skipping."); return null; } -- GitLab From 4598d54a0e192e085471f5bbf2f0de74ceec8fcd Mon Sep 17 00:00:00 2001 From: Mike Perry Date: Wed, 27 Aug 2014 15:19:10 -0700 Subject: [PATCH 041/250] BB 12974: Disable NTLM and Negotiate HTTP Auth The Mozilla bugs: https://bugzilla.mozilla.org/show_bug.cgi?id=1046421, https://bugzilla.mozilla.org/show_bug.cgi?id=1261591, tor-browser#27602 --- extensions/auth/nsHttpNegotiateAuth.cpp | 4 ++++ netwerk/protocol/http/nsHttpNTLMAuth.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/extensions/auth/nsHttpNegotiateAuth.cpp b/extensions/auth/nsHttpNegotiateAuth.cpp index a3ec224b59ee..46da4d015f75 100644 --- a/extensions/auth/nsHttpNegotiateAuth.cpp +++ b/extensions/auth/nsHttpNegotiateAuth.cpp @@ -145,6 +145,10 @@ nsHttpNegotiateAuth::ChallengeReceived(nsIHttpAuthenticableChannel* authChannel, nsIAuthModule* rawModule = (nsIAuthModule*)*continuationState; *identityInvalid = false; + + /* Always fail Negotiate auth for Tor Browser. We don't need it. */ + return NS_ERROR_ABORT; + if (rawModule) { return NS_OK; } diff --git a/netwerk/protocol/http/nsHttpNTLMAuth.cpp b/netwerk/protocol/http/nsHttpNTLMAuth.cpp index 0d8f5f083ad0..c02bd97d690f 100644 --- a/netwerk/protocol/http/nsHttpNTLMAuth.cpp +++ b/netwerk/protocol/http/nsHttpNTLMAuth.cpp @@ -167,6 +167,9 @@ nsHttpNTLMAuth::ChallengeReceived(nsIHttpAuthenticableChannel* channel, *identityInvalid = false; + /* Always fail Negotiate auth for Tor Browser. We don't need it. */ + return NS_ERROR_ABORT; + // Start a new auth sequence if the challenge is exactly "NTLM". // If native NTLM auth apis are available and enabled through prefs, // try to use them. -- GitLab From 101c64ead3aeafd0244417d571e8247125b11fd7 Mon Sep 17 00:00:00 2001 From: cypherpunks1 <2478-cypherpunks1@gitlab.torproject.org> Date: Tue, 10 Jan 2023 16:22:43 +0000 Subject: [PATCH 042/250] BB 40717: Hide Windows SSO in settings --- browser/themes/shared/preferences/preferences.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/browser/themes/shared/preferences/preferences.css b/browser/themes/shared/preferences/preferences.css index 641c9365332f..a6bf2327740c 100644 --- a/browser/themes/shared/preferences/preferences.css +++ b/browser/themes/shared/preferences/preferences.css @@ -597,6 +597,13 @@ html|label[disabled] { margin-inline-start: 0; } +@media (-moz-platform: windows) { + #windows-sso, + #windows-sso-caption { + display: none; + } +} + /** * Dialog */ -- GitLab From 49d1464fe7ce449525ce93153ba4349632f59112 Mon Sep 17 00:00:00 2001 From: Georg Koppen Date: Mon, 22 May 2017 12:44:40 +0000 Subject: [PATCH 043/250] BB 16285: Exclude ClearKey system for now In the past the ClearKey system had not been compiled when specifying --disable-eme. But that changed and it is even bundled nowadays (see: Mozilla's bug 1300654). We don't want to ship it right now as the use case for it is not really visible while the code had security vulnerabilities in the past. --- browser/installer/package-manifest.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 8d76c4ade5e3..16d2bdc12181 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -423,11 +423,11 @@ bin/libfreebl_64int_3.so #endif ; media -@RESPATH@/gmp-clearkey/0.1/@DLL_PREFIX@clearkey@DLL_SUFFIX@ -@RESPATH@/gmp-clearkey/0.1/manifest.json -#if defined(MOZ_WMF_CDM) && defined(ENABLE_TESTS) -@BINPATH@/@DLL_PREFIX@wmfclearkey@DLL_SUFFIX@ -#endif +;@RESPATH@/gmp-clearkey/0.1/@DLL_PREFIX@clearkey@DLL_SUFFIX@ +;@RESPATH@/gmp-clearkey/0.1/manifest.json +;#if defined(MOZ_WMF_CDM) && defined(ENABLE_TESTS) +;@BINPATH@/@DLL_PREFIX@wmfclearkey@DLL_SUFFIX@ +;#endif #ifdef PKG_LOCALE_MANIFEST #include @PKG_LOCALE_MANIFEST@ -- GitLab From cc700e663826198360a8639d171fb755039e63e1 Mon Sep 17 00:00:00 2001 From: Kathy Brade Date: Tue, 23 May 2017 17:05:29 -0400 Subject: [PATCH 044/250] BB 21431: Clean-up system extensions shipped in Firefox Only ship the pdfjs extension. --- browser/extensions/moz.build | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/browser/extensions/moz.build b/browser/extensions/moz.build index f6071084bc76..4e5b9bd6d6c8 100644 --- a/browser/extensions/moz.build +++ b/browser/extensions/moz.build @@ -4,10 +4,4 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -DIRS += [ - "formautofill", - "webcompat", - "pictureinpicture", - "search-detection", - "newtab", -] +DIRS += [] -- GitLab From c122cdb215b7d1e1475e2adffe6021937c826388 Mon Sep 17 00:00:00 2001 From: Henry Wilkes Date: Mon, 16 Sep 2024 16:38:10 +0100 Subject: [PATCH 045/250] BB 42831: Remove the shopping components. --- browser/base/content/browser-main.js | 2 +- browser/base/content/browser.js | 8 +-- browser/base/content/browser.js.globals | 2 - .../base/content/navigator-toolbox.inc.xhtml | 2 + browser/components/BrowserComponents.manifest | 2 - browser/components/BrowserGlue.sys.mjs | 67 +------------------ browser/components/about/AboutRedirector.cpp | 7 +- browser/components/about/components.conf | 2 +- browser/components/shopping/jar.mn | 31 +-------- browser/components/shopping/moz.build | 13 +--- browser/components/sidebar/browser-sidebar.js | 4 +- toolkit/components/shopping/jar.mn | 17 +---- .../modules/RemotePageAccessManager.sys.mjs | 21 +----- 13 files changed, 15 insertions(+), 163 deletions(-) diff --git a/browser/base/content/browser-main.js b/browser/base/content/browser-main.js index 33754aa20cd2..a19f144a05db 100644 --- a/browser/base/content/browser-main.js +++ b/browser/base/content/browser-main.js @@ -29,7 +29,7 @@ Services.scriptloader.loadSubScript("chrome://browser/content/places/places-menupopup.js", this); Services.scriptloader.loadSubScript("chrome://browser/content/search/autocomplete-popup.js", this); Services.scriptloader.loadSubScript("chrome://browser/content/search/searchbar.js", this); - Services.scriptloader.loadSubScript("chrome://browser/content/shopping/shopping-sidebar.js", this); + // Removed shopping-sidebar.js. tor-browser#42831. } window.onload = gBrowserInit.onLoad.bind(gBrowserInit); diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 9c8e7a38a260..b0ad51c3c28a 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -78,8 +78,8 @@ ChromeUtils.defineESModuleGetters(this, { SessionStartup: "resource:///modules/sessionstore/SessionStartup.sys.mjs", SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs", SharingUtils: "resource:///modules/SharingUtils.sys.mjs", - ShoppingSidebarParent: "resource:///actors/ShoppingSidebarParent.sys.mjs", - ShoppingSidebarManager: "resource:///actors/ShoppingSidebarParent.sys.mjs", + // Removed ShoppingSidebarParent and ShoppingSidebarManager. + // tor-browser#42831. ShortcutUtils: "resource://gre/modules/ShortcutUtils.sys.mjs", SiteDataManager: "resource:///modules/SiteDataManager.sys.mjs", SitePermissions: "resource:///modules/SitePermissions.sys.mjs", @@ -2967,10 +2967,6 @@ var TabsProgressListener = { return; } - // Some shops use pushState to move between individual products, so - // the shopping code needs to be told about all of these. - ShoppingSidebarManager.onLocationChange(aBrowser, aLocationURI, aFlags); - // Filter out location changes caused by anchor navigation // or history.push/pop/replaceState. if (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT) { diff --git a/browser/base/content/browser.js.globals b/browser/base/content/browser.js.globals index 3cd7bc1e5bdf..ad8e8ea91d63 100644 --- a/browser/base/content/browser.js.globals +++ b/browser/base/content/browser.js.globals @@ -143,8 +143,6 @@ "SessionStartup", "SessionStore", "SharingUtils", - "ShoppingSidebarParent", - "ShoppingSidebarManager", "ShortcutUtils", "SiteDataManager", "SitePermissions", diff --git a/browser/base/content/navigator-toolbox.inc.xhtml b/browser/base/content/navigator-toolbox.inc.xhtml index 00c8976d3e25..d59bc85f57bf 100644 --- a/browser/base/content/navigator-toolbox.inc.xhtml +++ b/browser/base/content/navigator-toolbox.inc.xhtml @@ -391,6 +391,8 @@