tbb-commits
Threads by month
- ----- 2025 -----
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
February 2022
- 5 participants
- 371 discussions

[tor-browser/tor-browser-91.5.0esr-11.5-2] Bug 13379: Sign our MAR files.
by richard@torproject.org 01 Feb '22
by richard@torproject.org 01 Feb '22
01 Feb '22
commit 38a6f4daaee6cee4cdf4c4ebb8835a498830958e
Author: Kathy Brade <brade(a)pearlcrescent.com>
Date: Wed Dec 17 16:37:11 2014 -0500
Bug 13379: Sign our MAR files.
Configure with --enable-verify-mar (when updating, require a valid
signature on the MAR file before it is applied).
Use the Tor Browser version instead of the Firefox version inside the
MAR file info block (necessary to prevent downgrade attacks).
Use NSS on all platforms for checking MAR signatures (instead of using
OS-native APIs, which Mozilla does on Mac OS and Windows). So that the
NSS and NSPR libraries the updater depends on can be found at runtime,
we add the firefox directory to the shared library search path on macOS.
On Linux, rpath is used by Mozilla to solve that problem, but that
approach won't work on macOS because the updater executable is copied
during the update process to a location that is under TorBrowser-Data,
and the location of TorBrowser-Data varies.
Also includes the fix for bug 18900.
Bug 19121: reinstate the update.xml hash check
Revert most changes from Mozilla Bug 1373267 "Remove hashFunction and
hashValue attributes from nsIUpdatePatch and code related to these
attributes." Changes to the tests were not reverted; the tests have
been changed significantly and we do not run automated updater tests
for Tor Browser at this time.
Also partial revert of commit f1241db6986e4b54473a1ed870f7584c75d51122.
Revert the nsUpdateService.js changes from Mozilla Bug 862173 "don't
verify mar file hash when using mar signing to verify the mar file
(lessens main thread I/O)."
Changes to the tests were not reverted; the tests have been changed
significantly and we do not run automated updater tests for
Tor Browser at this time.
We kept the addition to the AppConstants API in case other JS code
references it in the future.
---
.mozconfig | 1 +
.mozconfig-asan | 1 +
.mozconfig-mac | 1 +
.mozconfig-mingw | 1 +
modules/libmar/tool/mar.c | 6 +--
modules/libmar/tool/moz.build | 12 +++--
modules/libmar/verify/moz.build | 14 ++---
toolkit/modules/AppConstants.jsm | 7 +++
toolkit/mozapps/update/UpdateService.jsm | 63 +++++++++++++++++++++-
toolkit/mozapps/update/UpdateTelemetry.jsm | 1 +
toolkit/mozapps/update/nsIUpdateService.idl | 11 ++++
.../mozapps/update/updater/updater-common.build | 24 +++++++--
toolkit/mozapps/update/updater/updater.cpp | 25 +++++----
toolkit/xre/moz.build | 3 ++
toolkit/xre/nsUpdateDriver.cpp | 50 +++++++++++++++++
15 files changed, 194 insertions(+), 26 deletions(-)
diff --git a/.mozconfig b/.mozconfig
index 7fe8633a9ef4..7655f628415e 100755
--- a/.mozconfig
+++ b/.mozconfig
@@ -37,3 +37,4 @@ ac_add_options MOZ_TELEMETRY_REPORTING=
ac_add_options --enable-tor-launcher
ac_add_options --with-tor-browser-version=dev-build
ac_add_options --disable-tor-browser-update
+ac_add_options --enable-verify-mar
diff --git a/.mozconfig-asan b/.mozconfig-asan
index 98ea6ac6f3fe..8bee813bfee8 100644
--- a/.mozconfig-asan
+++ b/.mozconfig-asan
@@ -30,6 +30,7 @@ ac_add_options --enable-official-branding
ac_add_options --enable-default-toolkit=cairo-gtk3
ac_add_options --enable-tor-browser-update
+ac_add_options --enable-verify-mar
ac_add_options --disable-strip
ac_add_options --disable-install-strip
diff --git a/.mozconfig-mac b/.mozconfig-mac
index 26e2b6b92fdb..5b4624ef1f67 100644
--- a/.mozconfig-mac
+++ b/.mozconfig-mac
@@ -43,6 +43,7 @@ ac_add_options --disable-debug
ac_add_options --enable-tor-browser-data-outside-app-dir
ac_add_options --enable-tor-browser-update
+ac_add_options --enable-verify-mar
ac_add_options --disable-crashreporter
ac_add_options --disable-webrtc
diff --git a/.mozconfig-mingw b/.mozconfig-mingw
index 3ec6ff18a3e9..ce6ace1dad67 100644
--- a/.mozconfig-mingw
+++ b/.mozconfig-mingw
@@ -15,6 +15,7 @@ ac_add_options --enable-strip
ac_add_options --enable-official-branding
ac_add_options --enable-tor-browser-update
+ac_add_options --enable-verify-mar
ac_add_options --disable-bits-download
# Let's make sure no preference is enabling either Adobe's or Google's CDM.
diff --git a/modules/libmar/tool/mar.c b/modules/libmar/tool/mar.c
index 0bf2cb4bd1d4..ea2b79924914 100644
--- a/modules/libmar/tool/mar.c
+++ b/modules/libmar/tool/mar.c
@@ -65,7 +65,7 @@ static void print_usage() {
"signed_input_archive.mar base_64_encoded_signature_file "
"changed_signed_output.mar\n");
printf("(i) is the index of the certificate to extract\n");
-# if defined(XP_MACOSX) || (defined(XP_WIN) && !defined(MAR_NSS))
+# if (defined(XP_MACOSX) || defined(XP_WIN)) && !defined(MAR_NSS)
printf("Verify a MAR file:\n");
printf(" mar [-C workingDir] -D DERFilePath -v signed_archive.mar\n");
printf(
@@ -149,7 +149,7 @@ int main(int argc, char** argv) {
memset((void*)certBuffers, 0, sizeof(certBuffers));
#endif
#if !defined(NO_SIGN_VERIFY) && \
- ((!defined(MAR_NSS) && defined(XP_WIN)) || defined(XP_MACOSX))
+ (!defined(MAR_NSS) && (defined(XP_WIN) || defined(XP_MACOSX)))
memset(DERFilePaths, 0, sizeof(DERFilePaths));
memset(fileSizes, 0, sizeof(fileSizes));
#endif
@@ -181,7 +181,7 @@ int main(int argc, char** argv) {
argc -= 2;
}
#if !defined(NO_SIGN_VERIFY)
-# if (!defined(MAR_NSS) && defined(XP_WIN)) || defined(XP_MACOSX)
+# if (!defined(MAR_NSS) && (defined(XP_WIN) || defined(XP_MACOSX)))
/* -D DERFilePath, also matches -D[index] DERFilePath
We allow an index for verifying to be symmetric
with the import and export command line arguments. */
diff --git a/modules/libmar/tool/moz.build b/modules/libmar/tool/moz.build
index a6d26c66a668..d6fa1677ddf1 100644
--- a/modules/libmar/tool/moz.build
+++ b/modules/libmar/tool/moz.build
@@ -43,15 +43,21 @@ if CONFIG["MOZ_BUILD_APP"] != "tools/update-packaging":
"verifymar",
]
+ if CONFIG["TOR_BROWSER_UPDATE"]:
+ DEFINES["MAR_NSS"] = True
+
if CONFIG["OS_ARCH"] == "WINNT":
USE_STATIC_LIBS = True
OS_LIBS += [
"ws2_32",
- "crypt32",
- "advapi32",
]
- elif CONFIG["OS_ARCH"] == "Darwin":
+ if not CONFIG["TOR_BROWSER_UPDATE"]:
+ OS_LIBS += [
+ "crypt32",
+ "advapi32",
+ ]
+ elif CONFIG["OS_ARCH"] == "Darwin" and not CONFIG["TOR_BROWSER_UPDATE"]:
OS_LIBS += [
"-framework Security",
]
diff --git a/modules/libmar/verify/moz.build b/modules/libmar/verify/moz.build
index b07475655f0d..03718eee50b4 100644
--- a/modules/libmar/verify/moz.build
+++ b/modules/libmar/verify/moz.build
@@ -16,15 +16,12 @@ FORCE_STATIC_LIB = True
if CONFIG["OS_ARCH"] == "WINNT":
USE_STATIC_LIBS = True
elif CONFIG["OS_ARCH"] == "Darwin":
- UNIFIED_SOURCES += [
- "MacVerifyCrypto.cpp",
- ]
- OS_LIBS += [
- "-framework Security",
+ USE_LIBS += [
+ "nspr",
+ "nss",
+ "signmar",
]
else:
- DEFINES["MAR_NSS"] = True
- LOCAL_INCLUDES += ["../sign"]
USE_LIBS += [
"nspr",
"nss",
@@ -38,6 +35,9 @@ else:
"-Wl,-rpath=\\$$ORIGIN",
]
+DEFINES["MAR_NSS"] = True
+LOCAL_INCLUDES += ["../sign"]
+
LOCAL_INCLUDES += [
"../src",
]
diff --git a/toolkit/modules/AppConstants.jsm b/toolkit/modules/AppConstants.jsm
index ea10dc97535d..3cb1518f2ab3 100644
--- a/toolkit/modules/AppConstants.jsm
+++ b/toolkit/modules/AppConstants.jsm
@@ -212,6 +212,13 @@ this.AppConstants = Object.freeze({
false,
#endif
+ MOZ_VERIFY_MAR_SIGNATURE:
+#ifdef MOZ_VERIFY_MAR_SIGNATURE
+ true,
+#else
+ false,
+#endif
+
MOZ_MAINTENANCE_SERVICE:
#ifdef MOZ_MAINTENANCE_SERVICE
true,
diff --git a/toolkit/mozapps/update/UpdateService.jsm b/toolkit/mozapps/update/UpdateService.jsm
index 8552240a1df6..f0a48d021638 100644
--- a/toolkit/mozapps/update/UpdateService.jsm
+++ b/toolkit/mozapps/update/UpdateService.jsm
@@ -999,6 +999,20 @@ function LOG(string) {
}
}
+/**
+ * Convert a string containing binary values to hex.
+ */
+function binaryToHex(input) {
+ var result = "";
+ for (var i = 0; i < input.length; ++i) {
+ var hex = input.charCodeAt(i).toString(16);
+ if (hex.length == 1)
+ hex = "0" + hex;
+ result += hex;
+ }
+ return result;
+}
+
/**
* Gets the specified directory at the specified hierarchy under the
* update root directory and creates it if it doesn't exist.
@@ -2022,6 +2036,8 @@ function UpdatePatch(patch) {
}
break;
case "finalURL":
+ case "hashFunction":
+ case "hashValue":
case "state":
case "type":
case "URL":
@@ -2041,6 +2057,8 @@ UpdatePatch.prototype = {
// over writing nsIUpdatePatch attributes.
_attrNames: [
"errorCode",
+ "hashFunction",
+ "hashValue",
"finalURL",
"selected",
"size",
@@ -2054,6 +2072,8 @@ UpdatePatch.prototype = {
*/
serialize: function UpdatePatch_serialize(updates) {
var patch = updates.createElementNS(URI_UPDATE_NS, "patch");
+ patch.setAttribute("hashFunction", this.hashFunction);
+ patch.setAttribute("hashValue", this.hashValue);
patch.setAttribute("size", this.size);
patch.setAttribute("type", this.type);
patch.setAttribute("URL", this.URL);
@@ -5278,7 +5298,42 @@ Downloader.prototype = {
}
LOG("Downloader:_verifyDownload downloaded size == expected size.");
- return true;
+ let fileStream = Cc["@mozilla.org/network/file-input-stream;1"].
+ createInstance(Ci.nsIFileInputStream);
+ fileStream.init(destination, FileUtils.MODE_RDONLY, FileUtils.PERMS_FILE, 0);
+
+ let digest;
+ try {
+ let hash = Cc["@mozilla.org/security/hash;1"].
+ createInstance(Ci.nsICryptoHash);
+ var hashFunction = Ci.nsICryptoHash[this._patch.hashFunction.toUpperCase()];
+ if (hashFunction == undefined) {
+ throw Cr.NS_ERROR_UNEXPECTED;
+ }
+ hash.init(hashFunction);
+ hash.updateFromStream(fileStream, -1);
+ // NOTE: For now, we assume that the format of _patch.hashValue is hex
+ // encoded binary (such as what is typically output by programs like
+ // sha1sum). In the future, this may change to base64 depending on how
+ // we choose to compute these hashes.
+ digest = binaryToHex(hash.finish(false));
+ } catch (e) {
+ LOG("Downloader:_verifyDownload - failed to compute hash of the " +
+ "downloaded update archive");
+ digest = "";
+ }
+
+ fileStream.close();
+
+ if (digest == this._patch.hashValue.toLowerCase()) {
+ LOG("Downloader:_verifyDownload hashes match.");
+ return true;
+ }
+
+ LOG("Downloader:_verifyDownload hashes do not match. ");
+ AUSTLMY.pingDownloadCode(this.isCompleteUpdate,
+ AUSTLMY.DWNLD_ERR_VERIFY_NO_HASH_MATCH);
+ return false;
},
/**
@@ -5875,6 +5930,9 @@ Downloader.prototype = {
" is higher than patch size: " +
this._patch.size
);
+ // It's important that we use a different code than
+ // NS_ERROR_CORRUPTED_CONTENT so that tests can verify the difference
+ // between a hash error and a wrong download error.
AUSTLMY.pingDownloadCode(
this.isCompleteUpdate,
AUSTLMY.DWNLD_ERR_PATCH_SIZE_LARGER
@@ -5893,6 +5951,9 @@ Downloader.prototype = {
" is not equal to expected patch size: " +
this._patch.size
);
+ // It's important that we use a different code than
+ // NS_ERROR_CORRUPTED_CONTENT so that tests can verify the difference
+ // between a hash error and a wrong download error.
AUSTLMY.pingDownloadCode(
this.isCompleteUpdate,
AUSTLMY.DWNLD_ERR_PATCH_SIZE_NOT_EQUAL
diff --git a/toolkit/mozapps/update/UpdateTelemetry.jsm b/toolkit/mozapps/update/UpdateTelemetry.jsm
index dae76e09acd0..df5b8917970e 100644
--- a/toolkit/mozapps/update/UpdateTelemetry.jsm
+++ b/toolkit/mozapps/update/UpdateTelemetry.jsm
@@ -192,6 +192,7 @@ var AUSTLMY = {
DWNLD_ERR_VERIFY_NO_REQUEST: 13,
DWNLD_ERR_VERIFY_PATCH_SIZE_NOT_EQUAL: 14,
DWNLD_ERR_WRITE_FAILURE: 15,
+ DWNLD_ERR_VERIFY_NO_HASH_MATCH: 16,
// Temporary failure code to see if there are failures without an update phase
DWNLD_UNKNOWN_PHASE_ERR_WRITE_FAILURE: 40,
diff --git a/toolkit/mozapps/update/nsIUpdateService.idl b/toolkit/mozapps/update/nsIUpdateService.idl
index 78929e1cef44..5db1db71fc81 100644
--- a/toolkit/mozapps/update/nsIUpdateService.idl
+++ b/toolkit/mozapps/update/nsIUpdateService.idl
@@ -39,6 +39,17 @@ interface nsIUpdatePatch : nsISupports
*/
attribute AString finalURL;
+ /**
+ * The hash function to use when determining this file's integrity
+ */
+ attribute AString hashFunction;
+
+ /**
+ * The value of the hash function named above that should be computed if
+ * this file is not corrupt.
+ */
+ attribute AString hashValue;
+
/**
* The size of this file, in bytes.
*/
diff --git a/toolkit/mozapps/update/updater/updater-common.build b/toolkit/mozapps/update/updater/updater-common.build
index 13926ea82046..a4173889271b 100644
--- a/toolkit/mozapps/update/updater/updater-common.build
+++ b/toolkit/mozapps/update/updater/updater-common.build
@@ -4,6 +4,10 @@
# 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/.
+DEFINES["MAR_NSS"] = True
+
+link_with_nss = DEFINES["MAR_NSS"] or (CONFIG["OS_ARCH"] == "Linux" and CONFIG["MOZ_VERIFY_MAR_SIGNATURE"])
+
srcs = [
"archivereader.cpp",
"updater.cpp",
@@ -36,10 +40,14 @@ if CONFIG["OS_ARCH"] == "WINNT":
"ws2_32",
"shell32",
"shlwapi",
- "crypt32",
- "advapi32",
]
+ if not link_with_nss:
+ OS_LIBS += [
+ "crypt32",
+ "advapi32",
+ ]
+
USE_LIBS += [
"bspatch",
"mar",
@@ -47,6 +55,13 @@ USE_LIBS += [
"xz-embedded",
]
+if link_with_nss:
+ USE_LIBS += [
+ "nspr",
+ "nss",
+ "signmar",
+ ]
+
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
have_progressui = 1
srcs += [
@@ -61,9 +76,12 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
]
OS_LIBS += [
"-framework Cocoa",
- "-framework Security",
"-framework SystemConfiguration",
]
+ if not link_with_nss:
+ OS_LIBS += [
+ "-framework Security",
+ ]
UNIFIED_SOURCES += [
"/toolkit/xre/updaterfileutils_osx.mm",
]
diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp
index 646261c70967..70ca36dcc3d2 100644
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -110,9 +110,11 @@ struct UpdateServerThreadArgs {
# define stat64 stat
#endif
-#if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && !defined(XP_MACOSX)
-# include "nss.h"
-# include "prerror.h"
+#if defined(MOZ_VERIFY_MAR_SIGNATURE)
+# if defined(MAR_NSS) || (!defined(XP_WIN) && !defined(XP_MACOSX))
+# include "nss.h"
+# include "prerror.h"
+# endif
#endif
#include "crctable.h"
@@ -2726,8 +2728,13 @@ static void UpdateThreadFunc(void* param) {
if (ReadMARChannelIDs(updateSettingsPath, &MARStrings) != OK) {
rv = UPDATE_SETTINGS_FILE_CHANNEL;
} else {
+# ifdef TOR_BROWSER_UPDATE
+ const char* appVersion = TOR_BROWSER_VERSION_QUOTED;
+# else
+ const char* appVersion = MOZ_APP_VERSION;
+# endif
rv = gArchiveReader.VerifyProductInformation(
- MARStrings.MARChannelID.get(), MOZ_APP_VERSION);
+ MARStrings.MARChannelID.get(), appVersion);
}
}
}
@@ -2957,11 +2964,10 @@ int NS_main(int argc, NS_tchar** argv) {
}
#endif
-#if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && !defined(XP_MACOSX)
- // On Windows and Mac we rely on native APIs to do verifications so we don't
- // need to initialize NSS at all there.
- // Otherwise, minimize the amount of NSS we depend on by avoiding all the NSS
- // databases.
+#if defined(MOZ_VERIFY_MAR_SIGNATURE)
+# if defined(MAR_NSS) || (!defined(XP_WIN) && !defined(XP_MACOSX))
+ // If using NSS for signature verification, initialize NSS but minimize
+ // the portion we depend on by avoiding all of the NSS databases.
if (NSS_NoDB_Init(nullptr) != SECSuccess) {
PRErrorCode error = PR_GetError();
fprintf(stderr, "Could not initialize NSS: %s (%d)", PR_ErrorToName(error),
@@ -2969,6 +2975,7 @@ int NS_main(int argc, NS_tchar** argv) {
_exit(1);
}
#endif
+#endif
#ifdef XP_MACOSX
if (!isElevated) {
diff --git a/toolkit/xre/moz.build b/toolkit/xre/moz.build
index 90d06481ee9e..56a2d7173d3c 100644
--- a/toolkit/xre/moz.build
+++ b/toolkit/xre/moz.build
@@ -233,6 +233,9 @@ for var in ("APP_VERSION", "APP_ID"):
if CONFIG["MOZ_BUILD_APP"] == "browser":
DEFINES["MOZ_BUILD_APP_IS_BROWSER"] = True
+if CONFIG['TOR_BROWSER_UPDATE']:
+ DEFINES['MAR_NSS'] = True
+
LOCAL_INCLUDES += [
"../../other-licenses/nsis/Contrib/CityHash/cityhash",
"../components/find",
diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp
index f83f28288786..4d2ca85928a9 100644
--- a/toolkit/xre/nsUpdateDriver.cpp
+++ b/toolkit/xre/nsUpdateDriver.cpp
@@ -366,6 +366,42 @@ static nsresult GetUpdateDirFromAppDir(nsIFile* aAppDir, nsIFile** aResult) {
# endif
#endif
+#if defined(TOR_BROWSER_UPDATE) && defined(MOZ_VERIFY_MAR_SIGNATURE) && \
+ defined(MAR_NSS) && defined(XP_MACOSX)
+/**
+ * Ideally we would save and restore the original library path value after
+ * the updater finishes its work (and before firefox is re-launched).
+ * Doing so would avoid potential problems like the following bug:
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=1434033
+ */
+/**
+ * Appends the specified path to the library path.
+ * This is used so that the updater can find libnss3.dylib and other
+ * shared libs.
+ *
+ * @param pathToAppend A new library path to prepend to the dynamic linker's
+ * search path.
+ */
+# include "prprf.h"
+# define PATH_SEPARATOR ":"
+# define LD_LIBRARY_PATH_ENVVAR_NAME "DYLD_LIBRARY_PATH"
+static void AppendToLibPath(const char* pathToAppend) {
+ char* pathValue = getenv(LD_LIBRARY_PATH_ENVVAR_NAME);
+ if (nullptr == pathValue || '\0' == *pathValue) {
+ // Leak the string because that is required by PR_SetEnv.
+ char* s =
+ Smprintf("%s=%s", LD_LIBRARY_PATH_ENVVAR_NAME, pathToAppend).release();
+ PR_SetEnv(s);
+ } else {
+ // Leak the string because that is required by PR_SetEnv.
+ char* s = Smprintf("%s=%s" PATH_SEPARATOR "%s", LD_LIBRARY_PATH_ENVVAR_NAME,
+ pathToAppend, pathValue)
+ .release();
+ PR_SetEnv(s);
+ }
+}
+#endif
+
/**
* Applies, switches, or stages an update.
*
@@ -612,6 +648,20 @@ static void ApplyUpdate(nsIFile* greDir, nsIFile* updateDir, nsIFile* appDir,
PR_SetEnv("MOZ_SAFE_MODE_RESTART=1");
}
+#if defined(TOR_BROWSER_UPDATE) && defined(MOZ_VERIFY_MAR_SIGNATURE) && \
+ defined(MAR_NSS) && defined(XP_MACOSX)
+ // On macOS, append the app directory to the shared library search path
+ // so the system can locate the shared libraries that are needed by the
+ // updater, e.g., libnss3.dylib).
+ nsAutoCString appPath;
+ nsresult rv2 = appDir->GetNativePath(appPath);
+ if (NS_SUCCEEDED(rv2)) {
+ AppendToLibPath(appPath.get());
+ } else {
+ LOG(("ApplyUpdate -- appDir->GetNativePath() failed (0x%x)\n", rv2));
+ }
+#endif
+
LOG(("spawning updater process [%s]\n", updaterPath.get()));
#ifdef DEBUG
dump_argv("ApplyUpdate updater", argv, argc);
1
0

[tor-browser/tor-browser-91.5.0esr-11.5-2] Bug 25658: Replace security slider with security level UI
by richard@torproject.org 01 Feb '22
by richard@torproject.org 01 Feb '22
01 Feb '22
commit 0687be303374b98b7837a6a57d724f3aa87de3aa
Author: Richard Pospesel <richard(a)torproject.org>
Date: Mon Mar 4 16:09:51 2019 -0800
Bug 25658: Replace security slider with security level UI
This patch adds a new 'securitylevel' component to Tor Browser intended
to replace the torbutton 'Security Slider'.
This component adds a new Security Level toolbar button which visually
indicates the current global security level via icon (as defined by the
extensions.torbutton.security_slider pref), a drop-down hanger with a
short description of the current security level, and a new section in
the about:preferences#privacy page where users can change their current
security level. In addition, the hanger and the preferences page will
show a visual warning when the user has modified prefs associated with
the security level and provide a one-click 'Restore Defaults' button to
get the user back on recommended settings.
Strings used by this patch are pulled from the torbutton extension, but
en-US defaults are provided if there is an error loading from the
extension. With this patch applied, the usual work-flow of "./mach build
&& ./mach run" work as expected, even if the torbutton extension is
disabled.
---
browser/base/content/browser.js | 10 +
browser/base/content/browser.xhtml | 2 +
browser/base/content/main-popupset.inc.xhtml | 1 +
browser/base/content/navigator-toolbox.inc.xhtml | 2 +
browser/components/moz.build | 1 +
browser/components/preferences/preferences.xhtml | 1 +
browser/components/preferences/privacy.inc.xhtml | 2 +
browser/components/preferences/privacy.js | 20 +
.../securitylevel/content/securityLevel.js | 527 +++++++++++++++++++++
.../securitylevel/content/securityLevelButton.css | 18 +
.../content/securityLevelButton.inc.xhtml | 7 +
.../securitylevel/content/securityLevelIcon.svg | 40 ++
.../securitylevel/content/securityLevelPanel.css | 74 +++
.../content/securityLevelPanel.inc.xhtml | 47 ++
.../content/securityLevelPreferences.css | 52 ++
.../content/securityLevelPreferences.inc.xhtml | 67 +++
browser/components/securitylevel/jar.mn | 6 +
browser/components/securitylevel/moz.build | 1 +
browser/modules/TorStrings.jsm | 4 +
.../themes/shared/customizableui/panelUI.inc.css | 3 +-
20 files changed, 884 insertions(+), 1 deletion(-)
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index 9fe5302c5f58..1b1439a73c56 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -225,6 +225,11 @@ XPCOMUtils.defineLazyScriptGetter(
["DownloadsButton", "DownloadsIndicatorView"],
"chrome://browser/content/downloads/indicator.js"
);
+XPCOMUtils.defineLazyScriptGetter(
+ this,
+ ["SecurityLevelButton"],
+ "chrome://browser/content/securitylevel/securityLevel.js"
+);
XPCOMUtils.defineLazyScriptGetter(
this,
"gEditItemOverlay",
@@ -1761,6 +1766,9 @@ var gBrowserInit = {
// doesn't flicker as the window is being shown.
DownloadsButton.init();
+ // Init the SecuritySettingsButton
+ SecurityLevelButton.init();
+
// Certain kinds of automigration rely on this notification to complete
// their tasks BEFORE the browser window is shown. SessionStore uses it to
// restore tabs into windows AFTER important parts like gMultiProcessBrowser
@@ -2494,6 +2502,8 @@ var gBrowserInit = {
DownloadsButton.uninit();
+ SecurityLevelButton.uninit();
+
TorBootstrapUrlbar.uninit();
gAccessibilityServiceIndicator.uninit();
diff --git a/browser/base/content/browser.xhtml b/browser/base/content/browser.xhtml
index f16307365728..627e6ac0f8a0 100644
--- a/browser/base/content/browser.xhtml
+++ b/browser/base/content/browser.xhtml
@@ -21,6 +21,8 @@
<?xml-stylesheet href="chrome://browser/content/browser.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/tabbrowser.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/downloads/downloads.css" type="text/css"?>
+<?xml-stylesheet href="chrome://browser/content/securitylevel/securityLevelPanel.css"?>
+<?xml-stylesheet href="chrome://browser/content/securitylevel/securityLevelButton.css"?>
<?xml-stylesheet href="chrome://browser/content/places/places.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/usercontext/usercontext.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
diff --git a/browser/base/content/main-popupset.inc.xhtml b/browser/base/content/main-popupset.inc.xhtml
index e5bf9460b75d..3fc665c65d79 100644
--- a/browser/base/content/main-popupset.inc.xhtml
+++ b/browser/base/content/main-popupset.inc.xhtml
@@ -520,6 +520,7 @@
#include ../../components/controlcenter/content/protectionsPanel.inc.xhtml
#include ../../components/downloads/content/downloadsPanel.inc.xhtml
#include ../../../devtools/startup/enableDevToolsPopup.inc.xhtml
+#include ../../components/securitylevel/content/securityLevelPanel.inc.xhtml
#include browser-allTabsMenu.inc.xhtml
<tooltip id="dynamic-shortcut-tooltip"
diff --git a/browser/base/content/navigator-toolbox.inc.xhtml b/browser/base/content/navigator-toolbox.inc.xhtml
index e7f63116ff39..6ac72cb889bc 100644
--- a/browser/base/content/navigator-toolbox.inc.xhtml
+++ b/browser/base/content/navigator-toolbox.inc.xhtml
@@ -413,6 +413,8 @@
</box>
</toolbarbutton>
+#include ../../components/securitylevel/content/securityLevelButton.inc.xhtml
+
<toolbarbutton id="fxa-toolbar-menu-button" class="toolbarbutton-1 chromeclass-toolbar-additional subviewbutton-nav"
badged="true"
onmousedown="gSync.toggleAccountPanel(this, event)"
diff --git a/browser/components/moz.build b/browser/components/moz.build
index d15ff3051593..ec8fab7fbc8f 100644
--- a/browser/components/moz.build
+++ b/browser/components/moz.build
@@ -48,6 +48,7 @@ DIRS += [
"protocolhandler",
"resistfingerprinting",
"search",
+ "securitylevel",
"sessionstore",
"shell",
"syncedtabs",
diff --git a/browser/components/preferences/preferences.xhtml b/browser/components/preferences/preferences.xhtml
index 0923005c8b90..0139abf95cbd 100644
--- a/browser/components/preferences/preferences.xhtml
+++ b/browser/components/preferences/preferences.xhtml
@@ -12,6 +12,7 @@
<?xml-stylesheet href="chrome://browser/skin/preferences/search.css"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/containers.css"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/privacy.css"?>
+<?xml-stylesheet href="chrome://browser/content/securitylevel/securityLevelPreferences.css"?>
<?xml-stylesheet href="chrome://browser/content/torpreferences/torPreferences.css"?>
<!DOCTYPE html [
diff --git a/browser/components/preferences/privacy.inc.xhtml b/browser/components/preferences/privacy.inc.xhtml
index 8d51e60cb32b..d2cf2ea9c89c 100644
--- a/browser/components/preferences/privacy.inc.xhtml
+++ b/browser/components/preferences/privacy.inc.xhtml
@@ -919,6 +919,8 @@
<html:h1 data-l10n-id="security-header"/>
</hbox>
+#include ../securitylevel/content/securityLevelPreferences.inc.xhtml
+
<!-- addons, forgery (phishing) UI Security -->
<groupbox id="browsingProtectionGroup" data-category="panePrivacy" hidden="true">
<label><html:h2 data-l10n-id="security-browsing-protection"/></label>
diff --git a/browser/components/preferences/privacy.js b/browser/components/preferences/privacy.js
index 35b37b099e93..bce7bb7e8a9c 100644
--- a/browser/components/preferences/privacy.js
+++ b/browser/components/preferences/privacy.js
@@ -80,6 +80,13 @@ XPCOMUtils.defineLazyGetter(this, "AlertsServiceDND", function() {
}
});
+// TODO: module import via ChromeUtils.defineModuleGetter
+XPCOMUtils.defineLazyScriptGetter(
+ this,
+ ["SecurityLevelPreferences"],
+ "chrome://browser/content/securitylevel/securityLevel.js"
+);
+
XPCOMUtils.defineLazyServiceGetter(
this,
"listManager",
@@ -308,6 +315,18 @@ function setUpContentBlockingWarnings() {
var gPrivacyPane = {
_pane: null,
+ /**
+ * Show the Security Level UI
+ */
+ _initSecurityLevel() {
+ SecurityLevelPreferences.init();
+ let unload = () => {
+ window.removeEventListener("unload", unload);
+ SecurityLevelPreferences.uninit();
+ };
+ window.addEventListener("unload", unload);
+ },
+
/**
* Whether the prompt to restart Firefox should appear when changing the autostart pref.
*/
@@ -503,6 +522,7 @@ var gPrivacyPane = {
this.trackingProtectionReadPrefs();
this.networkCookieBehaviorReadPrefs();
this._initTrackingProtectionExtensionControl();
+ this._initSecurityLevel();
Services.telemetry.setEventRecordingEnabled("pwmgr", true);
diff --git a/browser/components/securitylevel/content/securityLevel.js b/browser/components/securitylevel/content/securityLevel.js
new file mode 100644
index 000000000000..8b8babe5b58e
--- /dev/null
+++ b/browser/components/securitylevel/content/securityLevel.js
@@ -0,0 +1,527 @@
+"use strict";
+
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+ChromeUtils.import("resource://gre/modules/Services.jsm");
+
+XPCOMUtils.defineLazyModuleGetters(this, {
+ CustomizableUI: "resource:///modules/CustomizableUI.jsm",
+ PanelMultiView: "resource:///modules/PanelMultiView.jsm",
+});
+
+ChromeUtils.defineModuleGetter(
+ this,
+ "TorStrings",
+ "resource:///modules/TorStrings.jsm"
+);
+
+/*
+ Security Level Prefs
+
+ Getters and Setters for relevant torbutton prefs
+*/
+const SecurityLevelPrefs = {
+ security_slider_pref : "extensions.torbutton.security_slider",
+ security_custom_pref : "extensions.torbutton.security_custom",
+
+ get securitySlider() {
+ try {
+ return Services.prefs.getIntPref(this.security_slider_pref);
+ } catch(e) {
+ // init pref to 4 (standard)
+ const val = 4;
+ Services.prefs.setIntPref(this.security_slider_pref, val);
+ return val;
+ }
+ },
+
+ set securitySlider(val) {
+ Services.prefs.setIntPref(this.security_slider_pref, val);
+ },
+
+ get securityCustom() {
+ try {
+ return Services.prefs.getBoolPref(this.security_custom_pref);
+ } catch(e) {
+ // init custom to false
+ const val = false;
+ Services.prefs.setBoolPref(this.security_custom_pref, val);
+ return val;
+ }
+ },
+
+ set securityCustom(val) {
+ Services.prefs.setBoolPref(this.security_custom_pref, val);
+ },
+}; /* Security Level Prefs */
+
+/*
+ Security Level Button Code
+
+ Controls init and update of the security level toolbar button
+*/
+
+const SecurityLevelButton = {
+ _securityPrefsBranch : null,
+
+ _populateXUL : function(securityLevelButton) {
+ if (securityLevelButton != null) {
+ securityLevelButton.setAttribute("tooltiptext", TorStrings.securityLevel.securityLevel);
+ securityLevelButton.setAttribute("label", TorStrings.securityLevel.securityLevel);
+ }
+ },
+
+ _configUIFromPrefs : function(securityLevelButton) {
+ if (securityLevelButton != null) {
+ let securitySlider = SecurityLevelPrefs.securitySlider;
+ securityLevelButton.removeAttribute("level");
+ const securityCustom = SecurityLevelPrefs.securityCustom;
+ switch(securitySlider) {
+ case 4:
+ securityLevelButton.setAttribute("level", `standard${securityCustom ? "_custom" : ""}`);
+ securityLevelButton.setAttribute("tooltiptext", TorStrings.securityLevel.standard.tooltip);
+ break;
+ case 2:
+ securityLevelButton.setAttribute("level", `safer${securityCustom ? "_custom" : ""}`);
+ securityLevelButton.setAttribute("tooltiptext", TorStrings.securityLevel.safer.tooltip);
+ break;
+ case 1:
+ securityLevelButton.setAttribute("level", `safest${securityCustom ? "_custom" : ""}`);
+ securityLevelButton.setAttribute("tooltiptext", TorStrings.securityLevel.safest.tooltip);
+ break;
+ }
+ }
+ },
+
+ get button() {
+ let button = document.getElementById("security-level-button");
+ if (!button) {
+ return null;
+ }
+ return button;
+ },
+
+ get anchor() {
+ let anchor = this.button.icon;
+ if (!anchor) {
+ return null;
+ }
+
+ anchor.setAttribute("consumeanchor", SecurityLevelButton.button.id);
+ return anchor;
+ },
+
+ init : function() {
+ // set the initial class based off of the current pref
+ let button = this.button;
+ this._populateXUL(button);
+ this._configUIFromPrefs(button);
+
+ this._securityPrefsBranch = Services.prefs.getBranch("extensions.torbutton.");
+ this._securityPrefsBranch.addObserver("", this, false);
+
+ CustomizableUI.addListener(this);
+
+ SecurityLevelPanel.init();
+ },
+
+ uninit : function() {
+ CustomizableUI.removeListener(this);
+
+ this._securityPrefsBranch.removeObserver("", this);
+ this._securityPrefsBranch = null;
+
+ SecurityLevelPanel.uninit();
+ },
+
+ observe : function(subject, topic, data) {
+ switch(topic) {
+ case "nsPref:changed":
+ if (data === "security_slider" || data === "security_custom") {
+ this._configUIFromPrefs(this.button);
+ }
+ break;
+ }
+ },
+
+ // callback for entering the 'Customize Firefox' screen to set icon
+ onCustomizeStart : function(window) {
+ let navigatorToolbox = document.getElementById("navigator-toolbox");
+ let button = navigatorToolbox.palette.querySelector("#security-level-button");
+ this._populateXUL(button);
+ this._configUIFromPrefs(button);
+ },
+
+ // callback when CustomizableUI modifies DOM
+ onWidgetAfterDOMChange : function(aNode, aNextNode, aContainer, aWasRemoval) {
+ if (aNode.id == "security-level-button" && !aWasRemoval) {
+ this._populateXUL(aNode);
+ this._configUIFromPrefs(aNode);
+ }
+ },
+
+ // for when the toolbar button needs to be activated and displays the Security Level panel
+ //
+ // In the toolbarbutton xul you'll notice we register this callback for both onkeypress and
+ // onmousedown. We do this to match the behavior of other panel spawning buttons such as Downloads,
+ // Library, and the Hamburger menus. Using oncommand alone would result in only getting fired
+ // after onclick, which is mousedown followed by mouseup.
+ onCommand : function(aEvent) {
+ // snippet borrowed from /browser/components/downloads/content/indicator.js DownloadsIndicatorView.onCommand(evt)
+ if (
+ // On Mac, ctrl-click will send a context menu event from the widget, so
+ // we don't want to bring up the panel when ctrl key is pressed.
+ (aEvent.type == "mousedown" &&
+ (aEvent.button != 0 ||
+ (AppConstants.platform == "macosx" && aEvent.ctrlKey))) ||
+ (aEvent.type == "keypress" && aEvent.key != " " && aEvent.key != "Enter")
+ ) {
+ return;
+ }
+
+ // we need to set this attribute for the button to be shaded correctly to look like it is pressed
+ // while the security level panel is open
+ this.button.setAttribute("open", "true");
+ SecurityLevelPanel.show();
+ aEvent.stopPropagation();
+ },
+}; /* Security Level Button */
+
+/*
+ Security Level Panel Code
+
+ Controls init and update of the panel in the security level hanger
+*/
+
+const SecurityLevelPanel = {
+ _securityPrefsBranch : null,
+ _panel : null,
+ _anchor : null,
+ _populated : false,
+
+ _selectors: Object.freeze({
+ panel: "panel#securityLevel-panel",
+ icon: "vbox#securityLevel-vbox>vbox",
+ header: "h1#securityLevel-header",
+ level: "label#securityLevel-level",
+ custom: "label#securityLevel-custom",
+ summary: "description#securityLevel-summary",
+ learnMore: "label#securityLevel-learnMore",
+ restoreDefaults: "button#securityLevel-restoreDefaults",
+ advancedSecuritySettings: "button#securityLevel-advancedSecuritySettings",
+ }),
+
+ _populateXUL : function() {
+ let selectors = this._selectors;
+
+ this._elements = {
+ panel: document.querySelector(selectors.panel),
+ icon: document.querySelector(selectors.icon),
+ header: document.querySelector(selectors.header),
+ levelLabel: document.querySelector(selectors.level),
+ customLabel: document.querySelector(selectors.custom),
+ summaryDescription: document.querySelector(selectors.summary),
+ learnMoreLabel: document.querySelector(selectors.learnMore),
+ restoreDefaultsButton: document.querySelector(selectors.restoreDefaults),
+ changeButton: document.querySelector(selectors.advancedSecuritySettings),
+ };
+ let elements = this._elements;
+
+ elements.header.textContent = TorStrings.securityLevel.securityLevel;
+ elements.customLabel.setAttribute("value", TorStrings.securityLevel.customWarning);
+ elements.learnMoreLabel.setAttribute("value", TorStrings.securityLevel.learnMore);
+ elements.learnMoreLabel.setAttribute("href", TorStrings.securityLevel.learnMoreURL);
+ elements.restoreDefaultsButton.setAttribute("label", TorStrings.securityLevel.restoreDefaults);
+ elements.changeButton.setAttribute("label", TorStrings.securityLevel.change);
+
+ this._configUIFromPrefs();
+ this._populated = true;
+ },
+
+ _configUIFromPrefs : function() {
+ // get security prefs
+ let securitySlider = SecurityLevelPrefs.securitySlider;
+ let securityCustom = SecurityLevelPrefs.securityCustom;
+
+ // get the panel elements we need to populate
+ let elements = this._elements;
+ let icon = elements.icon;
+ let labelLevel = elements.levelLabel;
+ let labelCustomWarning = elements.customLabel;
+ let summary = elements.summaryDescription;
+ let buttonRestoreDefaults = elements.restoreDefaultsButton;
+ let buttonAdvancedSecuritySettings = elements.changeButton;
+
+ // only visible when user is using custom settings
+ labelCustomWarning.hidden = !securityCustom;
+ buttonRestoreDefaults.hidden = !securityCustom;
+
+ // Descriptions change based on security level
+ switch(securitySlider) {
+ // standard
+ case 4:
+ icon.setAttribute("level", "standard");
+ labelLevel.setAttribute("value", TorStrings.securityLevel.standard.level);
+ summary.textContent = TorStrings.securityLevel.standard.summary;
+ break;
+ // safer
+ case 2:
+ icon.setAttribute("level", "safer");
+ labelLevel.setAttribute("value", TorStrings.securityLevel.safer.level);
+ summary.textContent = TorStrings.securityLevel.safer.summary;
+ break;
+ // safest
+ case 1:
+ icon.setAttribute("level", "safest");
+ labelLevel.setAttribute("value", TorStrings.securityLevel.safest.level);
+ summary.textContent = TorStrings.securityLevel.safest.summary;
+ break;
+ }
+
+ // override the summary text with custom warning
+ if (securityCustom) {
+ summary.textContent = TorStrings.securityLevel.custom.summary;
+ }
+ },
+
+ init : function() {
+ this._securityPrefsBranch = Services.prefs.getBranch("extensions.torbutton.");
+ this._securityPrefsBranch.addObserver("", this, false);
+ },
+
+ uninit : function() {
+ this._securityPrefsBranch.removeObserver("", this);
+ this._securityPrefsBranch = null;
+ },
+
+ show : function() {
+ // we have to defer this until after the browser has finished init'ing before
+ // we can populate the panel
+ if (!this._populated) {
+ this._populateXUL();
+ }
+
+ let panel = document.getElementById("securityLevel-panel");
+ panel.hidden = false;
+ PanelMultiView.openPopup(panel, SecurityLevelButton.anchor, "bottomcenter topright",
+ 0, 0, false, null).catch(Cu.reportError);
+ },
+
+ hide : function() {
+ let panel = document.getElementById("securityLevel-panel");
+ PanelMultiView.hidePopup(panel);
+ },
+
+ restoreDefaults : function() {
+ SecurityLevelPrefs.securityCustom = false;
+ // hide and reshow so that layout re-renders properly
+ this.hide();
+ this.show(this._anchor);
+ },
+
+ openAdvancedSecuritySettings : function() {
+ openPreferences("privacy-securitylevel");
+ this.hide();
+ },
+
+ // callback when prefs change
+ observe : function(subject, topic, data) {
+ switch(topic) {
+ case "nsPref:changed":
+ if (data == "security_slider" || data == "security_custom") {
+ this._configUIFromPrefs();
+ }
+ break;
+ }
+ },
+
+ // callback when the panel is displayed
+ onPopupShown : function(event) {
+ SecurityLevelButton.button.setAttribute("open", "true");
+ },
+
+ // callback when the panel is hidden
+ onPopupHidden : function(event) {
+ SecurityLevelButton.button.removeAttribute("open");
+ }
+}; /* Security Level Panel */
+
+/*
+ Security Level Preferences Code
+
+ Code to handle init and update of security level section in about:preferences#privacy
+*/
+
+const SecurityLevelPreferences =
+{
+ _securityPrefsBranch : null,
+
+ _populateXUL : function() {
+ let groupbox = document.getElementById("securityLevel-groupbox");
+
+ let labelHeader = groupbox.querySelector("#securityLevel-header");
+ labelHeader.textContent = TorStrings.securityLevel.securityLevel;
+
+ let spanOverview = groupbox.querySelector("#securityLevel-overview");
+ spanOverview.textContent = TorStrings.securityLevel.overview;
+
+ let labelLearnMore = groupbox.querySelector("#securityLevel-learnMore");
+ labelLearnMore.setAttribute("value", TorStrings.securityLevel.learnMore);
+ labelLearnMore.setAttribute("href", TorStrings.securityLevel.learnMoreURL);
+
+ let radiogroup = document.getElementById("securityLevel-radiogroup");
+ radiogroup.addEventListener("command", SecurityLevelPreferences.selectSecurityLevel);
+
+ let populateRadioElements = function(vboxQuery, stringStruct) {
+ let vbox = groupbox.querySelector(vboxQuery);
+
+ let radio = vbox.querySelector("radio");
+ radio.setAttribute("label", stringStruct.level);
+
+ let customWarning = vbox.querySelector("#securityLevel-customWarning");
+ customWarning.setAttribute("value", TorStrings.securityLevel.customWarning);
+
+ let labelSummary = vbox.querySelector("#securityLevel-summary");
+ labelSummary.textContent = stringStruct.summary;
+
+ let labelRestoreDefaults = vbox.querySelector("#securityLevel-restoreDefaults");
+ labelRestoreDefaults.setAttribute("value", TorStrings.securityLevel.restoreDefaults);
+ labelRestoreDefaults.addEventListener("click", SecurityLevelPreferences.restoreDefaults);
+
+ let description1 = vbox.querySelector("#securityLevel-description1");
+ if (description1) {
+ description1.textContent = stringStruct.description1;
+ }
+ let description2 = vbox.querySelector("#securityLevel-description2");
+ if (description2) {
+ description2.textContent = stringStruct.description2;
+ }
+ let description3 = vbox.querySelector("#securityLevel-description3");
+ if (description3) {
+ description3.textContent = stringStruct.description3;
+ }
+ };
+
+ populateRadioElements("#securityLevel-vbox-standard", TorStrings.securityLevel.standard);
+ populateRadioElements("#securityLevel-vbox-safer", TorStrings.securityLevel.safer);
+ populateRadioElements("#securityLevel-vbox-safest", TorStrings.securityLevel.safest);
+ },
+
+ _configUIFromPrefs : function() {
+ // read our prefs
+ let securitySlider = SecurityLevelPrefs.securitySlider;
+ let securityCustom = SecurityLevelPrefs.securityCustom;
+
+ // get our elements
+ let groupbox = document.getElementById("securityLevel-groupbox");
+
+ let radiogroup = groupbox.querySelector("#securityLevel-radiogroup");
+ let labelStandardCustom = groupbox.querySelector("#securityLevel-vbox-standard label#securityLevel-customWarning");
+ let labelSaferCustom = groupbox.querySelector("#securityLevel-vbox-safer label#securityLevel-customWarning");
+ let labelSafestCustom = groupbox.querySelector("#securityLevel-vbox-safest label#securityLevel-customWarning");
+ let labelStandardRestoreDefaults = groupbox.querySelector("#securityLevel-vbox-standard label#securityLevel-restoreDefaults");
+ let labelSaferRestoreDefaults = groupbox.querySelector("#securityLevel-vbox-safer label#securityLevel-restoreDefaults");
+ let labelSafestRestoreDefaults = groupbox.querySelector("#securityLevel-vbox-safest label#securityLevel-restoreDefaults");
+
+ // hide custom label by default until we know which level we're at
+ labelStandardCustom.hidden = true;
+ labelSaferCustom.hidden = true;
+ labelSafestCustom.hidden = true;
+
+ labelStandardRestoreDefaults.hidden = true;
+ labelSaferRestoreDefaults.hidden = true;
+ labelSafestRestoreDefaults.hidden = true;
+
+ switch(securitySlider) {
+ // standard
+ case 4:
+ radiogroup.value = "standard";
+ labelStandardCustom.hidden = !securityCustom;
+ labelStandardRestoreDefaults.hidden = !securityCustom;
+ break;
+ // safer
+ case 2:
+ radiogroup.value = "safer";
+ labelSaferCustom.hidden = !securityCustom;
+ labelSaferRestoreDefaults.hidden = !securityCustom;
+ break;
+ // safest
+ case 1:
+ radiogroup.value = "safest";
+ labelSafestCustom.hidden = !securityCustom;
+ labelSafestRestoreDefaults.hidden = !securityCustom;
+ break;
+ }
+ },
+
+ init : function() {
+ // populate XUL with localized strings
+ this._populateXUL();
+
+ // read prefs and populate UI
+ this._configUIFromPrefs();
+
+ // register for pref chagnes
+ this._securityPrefsBranch = Services.prefs.getBranch("extensions.torbutton.");
+ this._securityPrefsBranch.addObserver("", this, false);
+ },
+
+ uninit : function() {
+ // unregister for pref change events
+ this._securityPrefsBranch.removeObserver("", this);
+ this._securityPrefsBranch = null;
+ },
+
+ // callback for when prefs change
+ observe : function(subject, topic, data) {
+ switch(topic) {
+ case "nsPref:changed":
+ if (data == "security_slider" ||
+ data == "security_custom") {
+ this._configUIFromPrefs();
+ }
+ break;
+ }
+ },
+
+ selectSecurityLevel : function() {
+ // radio group elements
+ let radiogroup = document.getElementById("securityLevel-radiogroup");
+
+ // update pref based on selected radio option
+ switch (radiogroup.value) {
+ case "standard":
+ SecurityLevelPrefs.securitySlider = 4;
+ break;
+ case "safer":
+ SecurityLevelPrefs.securitySlider = 2;
+ break;
+ case "safest":
+ SecurityLevelPrefs.securitySlider = 1;
+ break;
+ }
+
+ SecurityLevelPreferences.restoreDefaults();
+ },
+
+ restoreDefaults : function() {
+ SecurityLevelPrefs.securityCustom = false;
+ },
+}; /* Security Level Prefereces */
+
+Object.defineProperty(this, "SecurityLevelButton", {
+ value: SecurityLevelButton,
+ enumerable: true,
+ writable: false
+});
+
+Object.defineProperty(this, "SecurityLevelPanel", {
+ value: SecurityLevelPanel,
+ enumerable: true,
+ writable: false
+});
+
+Object.defineProperty(this, "SecurityLevelPreferences", {
+ value: SecurityLevelPreferences,
+ enumerable: true,
+ writable: false
+});
diff --git a/browser/components/securitylevel/content/securityLevelButton.css b/browser/components/securitylevel/content/securityLevelButton.css
new file mode 100644
index 000000000000..38701250e9c9
--- /dev/null
+++ b/browser/components/securitylevel/content/securityLevelButton.css
@@ -0,0 +1,18 @@
+toolbarbutton#security-level-button[level="standard"] {
+ list-style-image: url("chrome://browser/content/securitylevel/securityLevelIcon.svg#standard");
+}
+toolbarbutton#security-level-button[level="safer"] {
+ list-style-image: url("chrome://browser/content/securitylevel/securityLevelIcon.svg#safer");
+}
+toolbarbutton#security-level-button[level="safest"] {
+ list-style-image: url("chrome://browser/content/securitylevel/securityLevelIcon.svg#safest");
+}
+toolbarbutton#security-level-button[level="standard_custom"] {
+ list-style-image: url("chrome://browser/content/securitylevel/securityLevelIcon.svg#standard_custom");
+}
+toolbarbutton#security-level-button[level="safer_custom"] {
+ list-style-image: url("chrome://browser/content/securitylevel/securityLevelIcon.svg#safer_custom");
+}
+toolbarbutton#security-level-button[level="safest_custom"] {
+ list-style-image: url("chrome://browser/content/securitylevel/securityLevelIcon.svg#safest_custom");
+}
\ No newline at end of file
diff --git a/browser/components/securitylevel/content/securityLevelButton.inc.xhtml b/browser/components/securitylevel/content/securityLevelButton.inc.xhtml
new file mode 100644
index 000000000000..96ee1ec0ca49
--- /dev/null
+++ b/browser/components/securitylevel/content/securityLevelButton.inc.xhtml
@@ -0,0 +1,7 @@
+<toolbarbutton id="security-level-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
+ badged="true"
+ removable="true"
+ onmousedown="SecurityLevelButton.onCommand(event);"
+ onkeypress="SecurityLevelButton.onCommand(event);"
+ closemenu="none"
+ cui-areatype="toolbar"/>
diff --git a/browser/components/securitylevel/content/securityLevelIcon.svg b/browser/components/securitylevel/content/securityLevelIcon.svg
new file mode 100644
index 000000000000..38cdbcb68afc
--- /dev/null
+++ b/browser/components/securitylevel/content/securityLevelIcon.svg
@@ -0,0 +1,40 @@
+<svg width="16" height="16" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <style>
+ use:not(:target) {
+ display: none;
+ }
+ </style>
+ <defs>
+ <g id="standard_icon" stroke="none" stroke-width="1">
+ <path clip-rule="evenodd" d="m8.49614.283505c-.30743-.175675-.68485-.175675-.99228.000001l-6 3.428574c-.31157.17804-.50386.50938-.50386.86824v1.41968c0 4 2.98667 9.0836 7 10 4.0133-.9164 7-6 7-10v-1.41968c0-.35886-.1923-.6902-.5039-.86824zm-.49614 1.216495-5.75 3.28571v1.2746c0 1.71749.65238 3.7522 1.78726 5.46629 1.07287 1.6204 2.47498 2.8062 3.96274 3.2425 1.48776-.4363 2.8899-1.6221 3.9627-3.2425 1.1349-1.71409 1.7873-3.7488 1.7873-5.46629v-1.2746z" fill-rule="evenodd" />
+ </g>
+ <g id="safer_icon" stroke="none" stroke-width="1">
+ <path clip-rule="evenodd" d="m8.49614.283505c-.30743-.175675-.68485-.175675-.99228.000001l-6 3.428574c-.31157.17804-.50386.50938-.50386.86824v1.41968c0 4 2.98667 9.0836 7 10 4.0133-.9164 7-6 7-10v-1.41968c0-.35886-.1923-.6902-.5039-.86824zm-.49614 1.216495-5.75 3.28571v1.2746c0 1.71749.65238 3.7522 1.78726 5.46629 1.07287 1.6204 2.47498 2.8062 3.96274 3.2425 1.48776-.4363 2.8899-1.6221 3.9627-3.2425 1.1349-1.71409 1.7873-3.7488 1.7873-5.46629v-1.2746z" fill-rule="evenodd"/>
+ <path d="m3.5 6.12062v-.40411c0-.08972.04807-.17255.12597-.21706l4-2.28572c.16666-.09523.37403.02511.37403.21707v10.0766c-1.01204-.408-2.054-1.3018-2.92048-2.6105-1.02134-1.54265-1.57952-3.34117-1.57952-4.77628z"/>
+ </g>
+ <g id="safest_icon" stroke="none" stroke-width="1">
+ <path clip-rule="evenodd" d="m8.49614.283505c-.30743-.175675-.68485-.175675-.99228.000001l-6 3.428574c-.31157.17804-.50386.50938-.50386.86824v1.41968c0 4 2.98667 9.0836 7 10 4.0133-.9164 7-6 7-10v-1.41968c0-.35886-.1923-.6902-.5039-.86824zm-.49614 1.216495-5.75 3.28571v1.2746c0 1.71749.65238 3.7522 1.78726 5.46629 1.07287 1.6204 2.47498 2.8062 3.96274 3.2425 1.48776-.4363 2.8899-1.6221 3.9627-3.2425 1.1349-1.71409 1.7873-3.7488 1.7873-5.46629v-1.2746z" fill-rule="evenodd"/>
+ <path d="m3.5 6.12062v-.40411c0-.08972.04807-.17255.12597-.21706l4.25-2.42857c.07685-.04392.17121-.04392.24806 0l4.24997 2.42857c.0779.04451.126.12734.126.21706v.40411c0 1.43511-.5582 3.23363-1.5795 4.77628-.8665 1.3087-1.90846 2.2025-2.9205 2.6105-1.01204-.408-2.054-1.3018-2.92048-2.6105-1.02134-1.54265-1.57952-3.34117-1.57952-4.77628z"/>
+ </g>
+ <g id="standard_custom_icon" stroke="none" stroke-width="1">
+ <path d="m9.37255.784312-.87641-.500806c-.30743-.175676-.68485-.175676-.99228 0l-6 3.428574c-.31157.17804-.50386.50938-.50386.86824v1.41968c0 4 2.98667 9.0836 7 10 3.7599-.8585 6.6186-5.3745 6.9647-9.23043-.4008.20936-.8392.35666-1.3024.42914-.2132 1.43414-.8072 2.98009-1.6996 4.32789-1.0728 1.6204-2.47494 2.8062-3.9627 3.2425-1.48776-.4363-2.88987-1.6221-3.96274-3.2425-1.13488-1.71409-1.78726-3.7488-1.78726-5.46629v-1.2746l5.75-3.28571.86913.49664c.10502-.43392.27664-.84184.50342-1.212328z"/>
+ <circle cx="13" cy="3" fill="#ffbd2e" r="3"/>
+ </g>
+ <g id="safer_custom_icon" stroke="none" stroke-width="1">
+ <path d="m9.37255.784312-.87641-.500806c-.30743-.175676-.68485-.175676-.99228 0l-6 3.428574c-.31157.17804-.50386.50938-.50386.86824v1.41968c0 4 2.98667 9.0836 7 10 3.7599-.8585 6.6186-5.3745 6.9647-9.23043-.4008.20936-.8392.35666-1.3024.42914-.2132 1.43414-.8072 2.98009-1.6996 4.32789-1.0728 1.6204-2.47494 2.8062-3.9627 3.2425-1.48776-.4363-2.88987-1.6221-3.96274-3.2425-1.13488-1.71409-1.78726-3.7488-1.78726-5.46629v-1.2746l5.75-3.28571.86913.49664c.10502-.43392.27664-.84184.50342-1.212328z"/>
+ <path d="m3.5 6.12062v-.40411c0-.08972.04807-.17255.12597-.21706l4-2.28572c.16666-.09523.37403.02511.37403.21707v10.0766c-1.01204-.408-2.054-1.3018-2.92048-2.6105-1.02134-1.54265-1.57952-3.34117-1.57952-4.77628z"/>
+ <circle cx="13" cy="3" fill="#ffbd2e" r="3"/>
+ </g>
+ <g id="safest_custom_icon" stroke="none" stroke-width="1">
+ <path d="m9.37255.784312-.87641-.500806c-.30743-.175676-.68485-.175676-.99228 0l-6 3.428574c-.31157.17804-.50386.50938-.50386.86824v1.41968c0 4 2.98667 9.0836 7 10 3.7599-.8585 6.6186-5.3745 6.9647-9.23043-.4008.20936-.8392.35666-1.3024.42914-.2132 1.43414-.8072 2.98009-1.6996 4.32789-1.0728 1.6204-2.47494 2.8062-3.9627 3.2425-1.48776-.4363-2.88987-1.6221-3.96274-3.2425-1.13488-1.71409-1.78726-3.7488-1.78726-5.46629v-1.2746l5.75-3.28571.86913.49664c.10502-.43392.27664-.84184.50342-1.212328z"/>
+ <path d="m8.77266 3.44151-.64863-.37064c-.07685-.04392-.17121-.04392-.24806 0l-4.25 2.42857c-.0779.04451-.12597.12735-.12597.21706v.40412c0 1.4351.55818 3.23362 1.57952 4.77618.86648 1.3087 1.90844 2.2026 2.92048 2.6106 1.01204-.408 2.054-1.3018 2.9205-2.6106.7761-1.17217 1.2847-2.49215 1.4843-3.68816-1.9219-.26934-3.43158-1.82403-3.63214-3.76713z"/>
+ <circle cx="13" cy="3" fill="#ffbd2e" r="3"/>
+ </g>
+ </defs>
+ <use id="standard" fill="context-fill" fill-opacity="context-fill-opacity" href="#standard_icon" />
+ <use id="safer" fill="context-fill" fill-opacity="context-fill-opacity" href="#safer_icon" />
+ <use id="safest" fill="context-fill" fill-opacity="context-fill-opacity" href="#safest_icon" />
+ <use id="standard_custom" fill="context-fill" fill-opacity="context-fill-opacity" href="#standard_custom_icon" />
+ <use id="safer_custom" fill="context-fill" fill-opacity="context-fill-opacity" href="#safer_custom_icon" />
+ <use id="safest_custom" fill="context-fill" fill-opacity="context-fill-opacity" href="#safest_custom_icon" />
+</svg>
diff --git a/browser/components/securitylevel/content/securityLevelPanel.css b/browser/components/securitylevel/content/securityLevelPanel.css
new file mode 100644
index 000000000000..6462c02f1594
--- /dev/null
+++ b/browser/components/securitylevel/content/securityLevelPanel.css
@@ -0,0 +1,74 @@
+/* Security Level CSS */
+
+panelview#securityLevel-panelview {
+ width: 25em;
+}
+
+vbox#securityLevel-vbox > vbox {
+ background-repeat: no-repeat;
+ /* icon center-line should be in-line with right margin */
+ /* -margin + panelWidth - imageWidth/2 */
+ background-position: calc(-16px + 25em - 4.5em) 0.4em;
+ background-size: 9em 9em;
+ -moz-context-properties: fill, fill-opacity;
+ fill-opacity: 1;
+ fill: var(--button-bgcolor);
+ min-height: 10em;
+}
+
+vbox#securityLevel-vbox > vbox[level="standard"] {
+ background-image: url("chrome://browser/content/securitylevel/securityLevelIcon.svg#standard");
+}
+vbox#securityLevel-vbox > vbox[level="safer"] {
+ background-image: url("chrome://browser/content/securitylevel/securityLevelIcon.svg#safer");
+}
+vbox#securityLevel-vbox > vbox[level="safest"] {
+ background-image: url("chrome://browser/content/securitylevel/securityLevelIcon.svg#safest");
+}
+
+vbox#securityLevel-vbox > toolbarseparator {
+ margin-inline: 16px;
+}
+
+vbox#securityLevel-vbox > vbox {
+ margin-inline: 0;
+ padding-inline: 16px;
+}
+
+vbox#securityLevel-vbox > vbox * {
+ margin-inline: 0;
+}
+
+vbox#securityLevel-vbox > vbox > hbox {
+}
+
+label#securityLevel-level {
+ font-size: 1.25em;
+ font-weight: 600;
+ padding-top: 0.15em;
+}
+
+label#securityLevel-custom {
+ border-radius: 4px;
+ background-color: var(--yellow-50);
+ color: black;
+ font-size: 1em;
+ height: 1.6em;
+ line-height: 1.0em;
+ padding: 0.4em 0.5em;
+ margin-left: 1em!important;
+}
+
+description#securityLevel-summary {
+ margin-top: 1em;
+ padding-right: 5em;
+}
+
+vbox#securityLevel-vbox > hbox.panel-footer {
+ display: flex;
+}
+
+
+button#securityLevel-advancedSecuritySettings {
+ margin-block: 0;
+}
diff --git a/browser/components/securitylevel/content/securityLevelPanel.inc.xhtml b/browser/components/securitylevel/content/securityLevelPanel.inc.xhtml
new file mode 100644
index 000000000000..02d93b738ff5
--- /dev/null
+++ b/browser/components/securitylevel/content/securityLevelPanel.inc.xhtml
@@ -0,0 +1,47 @@
+<panel id="securityLevel-panel"
+ role="group"
+ type="arrow"
+ orient="vertical"
+ level="top"
+ hidden="true"
+ class="panel-no-padding"
+ onpopupshown="SecurityLevelPanel.onPopupShown(event);"
+ onpopuphidden="SecurityLevelPanel.onPopupHidden(event);">
+ <panelmultiview mainViewId="securityLevel-panelview">
+ <panelview id="securityLevel-panelview" descriptionheightworkaround="true">
+ <vbox id="securityLevel-vbox">
+ <box class="panel-header">
+ <html:h1 id="securityLevel-header"/>
+ </box>
+ <toolbarseparator></toolbarseparator>
+ <vbox>
+ <hbox>
+ <label id="securityLevel-level"/>
+ <vbox>
+ <spacer flex="1"/>
+ <label id="securityLevel-custom"/>
+ <spacer flex="1"/>
+ </vbox>
+ <spacer flex="1"/>
+ </hbox>
+ <description id="securityLevel-summary"/>
+ <hbox>
+ <label
+ id="securityLevel-learnMore"
+ class="learnMore text-link"
+ onclick="SecurityLevelPanel.hide();"
+ is="text-link"/>
+ <spacer/>
+ </hbox>
+ </vbox>
+ <hbox class="panel-footer">
+ <button id="securityLevel-restoreDefaults"
+ oncommand="SecurityLevelPanel.restoreDefaults();"/>
+ <button id="securityLevel-advancedSecuritySettings"
+ default="true"
+ oncommand="SecurityLevelPanel.openAdvancedSecuritySettings();"/>
+ </hbox>
+ </vbox>
+ </panelview>
+ </panelmultiview>
+</panel>
diff --git a/browser/components/securitylevel/content/securityLevelPreferences.css b/browser/components/securitylevel/content/securityLevelPreferences.css
new file mode 100644
index 000000000000..12a7cccffe09
--- /dev/null
+++ b/browser/components/securitylevel/content/securityLevelPreferences.css
@@ -0,0 +1,52 @@
+label#securityLevel-customWarning {
+ border-radius: 4px;
+ background-color: var(--yellow-50);
+ color: black;
+ font-size: 1em;
+ height: 1.6em;
+ padding: 0.4em 0.5em;
+}
+
+radiogroup#securityLevel-radiogroup description {
+ color: var(--in-content-page-color)!important;
+}
+
+radiogroup#securityLevel-radiogroup radio {
+ font-weight: bold;
+}
+
+radiogroup#securityLevel-radiogroup > vbox {
+ border: 1px solid var(--in-content-box-border-color);
+ border-radius: 4px;
+ margin: 3px 0;
+ padding: 9px;
+}
+
+radiogroup#securityLevel-radiogroup[value=standard] > vbox#securityLevel-vbox-standard,
+radiogroup#securityLevel-radiogroup[value=safer] > vbox#securityLevel-vbox-safer,
+radiogroup#securityLevel-radiogroup[value=safest] > vbox#securityLevel-vbox-safest {
+ --section-highlight-background-color: color-mix(in srgb, var(--in-content-accent-color) 20%, transparent);
+ background-color: var(--section-highlight-background-color);
+ border: 1px solid var(--in-content-accent-color);
+
+}
+
+vbox#securityLevel-descriptionList {
+ display: none;
+ margin-inline-start:
+}
+
+radiogroup#securityLevel-radiogroup[value=safer] > vbox#securityLevel-vbox-safer > vbox#securityLevel-descriptionList,
+radiogroup#securityLevel-radiogroup[value=safest] > vbox#securityLevel-vbox-safest > vbox#securityLevel-descriptionList {
+ display: inherit;
+}
+
+vbox#securityLevel-descriptionList > description {
+ display: list-item;
+}
+
+vbox#securityLevel-vbox-standard,
+vbox#securityLevel-vbox-safer,
+vbox#securityLevel-vbox-safest {
+ margin-top: 0.4em;
+}
diff --git a/browser/components/securitylevel/content/securityLevelPreferences.inc.xhtml b/browser/components/securitylevel/content/securityLevelPreferences.inc.xhtml
new file mode 100644
index 000000000000..b050dad81621
--- /dev/null
+++ b/browser/components/securitylevel/content/securityLevelPreferences.inc.xhtml
@@ -0,0 +1,67 @@
+<groupbox id="securityLevel-groupbox" data-category="panePrivacy" hidden="true">
+ <label><html:h2 id="securityLevel-header"/></label>
+ <vbox data-subcategory="securitylevel" flex="1">
+ <description flex="1">
+ <html:span id="securityLevel-overview" class="tail-with-learn-more"/>
+ <label id="securityLevel-learnMore" class="learnMore text-link" is="text-link"/>
+ </description>
+ <radiogroup id="securityLevel-radiogroup">
+ <vbox id="securityLevel-vbox-standard">
+ <hbox>
+ <radio value="standard"/>
+ <vbox>
+ <spacer flex="1"/>
+ <label id="securityLevel-customWarning"/>
+ <spacer flex="1"/>
+ </vbox>
+ <spacer flex="1"/>
+ </hbox>
+ <description flex="1" class="indent">
+ <html:span id="securityLevel-summary" class="tail-with-learn-more"/>
+ <label id="securityLevel-restoreDefaults"
+ class="learnMore text-link"/>
+ </description>
+ </vbox>
+ <vbox id="securityLevel-vbox-safer">
+ <hbox>
+ <radio value="safer"/>
+ <vbox>
+ <spacer flex="1"/>
+ <label id="securityLevel-customWarning"/>
+ <spacer flex="1"/>
+ </vbox>
+ </hbox>
+ <description flex="1" class="indent">
+ <html:span id="securityLevel-summary" class="tail-with-learn-more"/>
+ <label id="securityLevel-restoreDefaults"
+ class="learnMore text-link"/>
+ </description>
+ <vbox id="securityLevel-descriptionList" class="indent">
+ <description id="securityLevel-description1" class="indent"/>
+ <description id="securityLevel-description2" class="indent"/>
+ <description id="securityLevel-description3" class="indent"/>
+ </vbox>
+ </vbox>
+ <vbox id="securityLevel-vbox-safest">
+ <hbox>
+ <radio value="safest"/>
+ <vbox>
+ <spacer flex="1"/>
+ <label id="securityLevel-customWarning"/>
+ <spacer flex="1"/>
+ </vbox>
+ </hbox>
+ <description flex="1" class="indent">
+ <html:span id="securityLevel-summary" class="tail-with-learn-more"/>
+ <label id="securityLevel-restoreDefaults"
+ class="learnMore text-link"/>
+ </description>
+ <vbox id="securityLevel-descriptionList" class="indent">
+ <description id="securityLevel-description1" class="indent"/>
+ <description id="securityLevel-description2" class="indent"/>
+ <description id="securityLevel-description3" class="indent"/>
+ </vbox>
+ </vbox>
+ </radiogroup>
+ </vbox>
+</groupbox>
diff --git a/browser/components/securitylevel/jar.mn b/browser/components/securitylevel/jar.mn
new file mode 100644
index 000000000000..61aa4169f9ec
--- /dev/null
+++ b/browser/components/securitylevel/jar.mn
@@ -0,0 +1,6 @@
+browser.jar:
+ content/browser/securitylevel/securityLevel.js (content/securityLevel.js)
+ content/browser/securitylevel/securityLevelPanel.css (content/securityLevelPanel.css)
+ content/browser/securitylevel/securityLevelButton.css (content/securityLevelButton.css)
+ content/browser/securitylevel/securityLevelPreferences.css (content/securityLevelPreferences.css)
+ content/browser/securitylevel/securityLevelIcon.svg (content/securityLevelIcon.svg)
diff --git a/browser/components/securitylevel/moz.build b/browser/components/securitylevel/moz.build
new file mode 100644
index 000000000000..2661ad7cb9f3
--- /dev/null
+++ b/browser/components/securitylevel/moz.build
@@ -0,0 +1 @@
+JAR_MANIFESTS += ["jar.mn"]
diff --git a/browser/modules/TorStrings.jsm b/browser/modules/TorStrings.jsm
index 96d3de8186e2..0ccbbb41a782 100644
--- a/browser/modules/TorStrings.jsm
+++ b/browser/modules/TorStrings.jsm
@@ -230,6 +230,10 @@ var TorStrings = {
"advanced_security_settings",
"Advanced Security Settings\u2026"
),
+ change: getString(
+ "change",
+ "Change\u2026"
+ ),
};
return retval;
})() /* Security Level Strings */,
diff --git a/browser/themes/shared/customizableui/panelUI.inc.css b/browser/themes/shared/customizableui/panelUI.inc.css
index e1d64c707518..abecf34cdb92 100644
--- a/browser/themes/shared/customizableui/panelUI.inc.css
+++ b/browser/themes/shared/customizableui/panelUI.inc.css
@@ -1430,7 +1430,8 @@ menuitem.panel-subview-footer@menuStateActive@,
#editBookmarkPanel toolbarseparator,
#downloadsPanel-mainView toolbarseparator,
.cui-widget-panelview menuseparator,
-.cui-widget-panel toolbarseparator {
+.cui-widget-panel toolbarseparator,
+#securityLevel-panel toolbarseparator {
appearance: none;
min-height: 0;
border-top: 1px solid var(--panel-separator-color);
1
0

[tor-browser/tor-browser-91.5.0esr-11.5-2] Bug 16940: After update, load local change notes.
by richard@torproject.org 01 Feb '22
by richard@torproject.org 01 Feb '22
01 Feb '22
commit 824fb2e096e268beb8ca8197cdb59123ba70392e
Author: Kathy Brade <brade(a)pearlcrescent.com>
Date: Wed Nov 25 11:36:20 2015 -0500
Bug 16940: After update, load local change notes.
Add an about:tbupdate page that displays the first section from
TorBrowser/Docs/ChangeLog.txt and includes a link to the remote
post-update page (typically our blog entry for the release).
Always load about:tbupdate in a content process, but implement the
code that reads the file system (changelog) in the chrome process
for compatibility with future sandboxing efforts.
Also fix bug 29440. Now about:tbupdate is styled as a fairly simple
changelog page that is designed to be displayed via a link that is on
about:tor.
---
browser/actors/AboutTBUpdateChild.jsm | 12 +++
browser/actors/AboutTBUpdateParent.jsm | 120 +++++++++++++++++++++
browser/actors/moz.build | 6 ++
.../base/content/abouttbupdate/aboutTBUpdate.css | 74 +++++++++++++
.../base/content/abouttbupdate/aboutTBUpdate.js | 27 +++++
.../base/content/abouttbupdate/aboutTBUpdate.xhtml | 39 +++++++
browser/base/content/browser-siteIdentity.js | 4 +-
browser/base/content/browser.js | 4 +
browser/base/jar.mn | 5 +
browser/components/BrowserContentHandler.jsm | 55 +++++++---
browser/components/BrowserGlue.jsm | 15 +++
browser/components/about/AboutRedirector.cpp | 6 ++
browser/components/about/components.conf | 3 +
browser/components/moz.build | 5 +-
.../locales/en-US/chrome/browser/aboutTBUpdate.dtd | 8 ++
browser/locales/jar.mn | 3 +
toolkit/modules/RemotePageAccessManager.jsm | 5 +
17 files changed, 375 insertions(+), 16 deletions(-)
diff --git a/browser/actors/AboutTBUpdateChild.jsm b/browser/actors/AboutTBUpdateChild.jsm
new file mode 100644
index 000000000000..4670da19b3db
--- /dev/null
+++ b/browser/actors/AboutTBUpdateChild.jsm
@@ -0,0 +1,12 @@
+// Copyright (c) 2020, The Tor Project, Inc.
+// See LICENSE for licensing information.
+//
+// vim: set sw=2 sts=2 ts=8 et syntax=javascript:
+
+var EXPORTED_SYMBOLS = ["AboutTBUpdateChild"];
+
+const { RemotePageChild } = ChromeUtils.import(
+ "resource://gre/actors/RemotePageChild.jsm"
+);
+
+class AboutTBUpdateChild extends RemotePageChild {}
diff --git a/browser/actors/AboutTBUpdateParent.jsm b/browser/actors/AboutTBUpdateParent.jsm
new file mode 100644
index 000000000000..56a10394565a
--- /dev/null
+++ b/browser/actors/AboutTBUpdateParent.jsm
@@ -0,0 +1,120 @@
+// Copyright (c) 2020, The Tor Project, Inc.
+// See LICENSE for licensing information.
+//
+// vim: set sw=2 sts=2 ts=8 et syntax=javascript:
+
+"use strict";
+
+this.EXPORTED_SYMBOLS = ["AboutTBUpdateParent"];
+
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
+const { AppConstants } = ChromeUtils.import(
+ "resource://gre/modules/AppConstants.jsm"
+);
+
+const kRequestUpdateMessageName = "FetchUpdateData";
+
+/**
+ * This code provides services to the about:tbupdate page. Whenever
+ * about:tbupdate needs to do something chrome-privileged, it sends a
+ * message that's handled here. It is modeled after Mozilla's about:home
+ * implementation.
+ */
+class AboutTBUpdateParent extends JSWindowActorParent {
+ receiveMessage(aMessage) {
+ if (aMessage.name == kRequestUpdateMessageName) {
+ return this.releaseNoteInfo;
+ }
+ return undefined;
+ }
+
+ get moreInfoURL() {
+ try {
+ return Services.prefs.getCharPref("torbrowser.post_update.url");
+ } catch (e) {}
+
+ // Use the default URL as a fallback.
+ return Services.urlFormatter.formatURLPref("startup.homepage_override_url");
+ }
+
+ // Read the text from the beginning of the changelog file that is located
+ // at TorBrowser/Docs/ChangeLog.txt and return an object that contains
+ // the following properties:
+ // version e.g., Tor Browser 8.5
+ // releaseDate e.g., March 31 2019
+ // releaseNotes details of changes (lines 2 - end of ChangeLog.txt)
+ // We attempt to parse the first line of ChangeLog.txt to extract the
+ // version and releaseDate. If parsing fails, we return the entire first
+ // line in version and omit releaseDate.
+ //
+ // On Mac OS, when building with --enable-tor-browser-data-outside-app-dir
+ // to support Gatekeeper signing, the ChangeLog.txt file is located in
+ // TorBrowser.app/Contents/Resources/TorBrowser/Docs/.
+ get releaseNoteInfo() {
+ let info = { moreInfoURL: this.moreInfoURL };
+
+ try {
+ let f;
+ if (AppConstants.TOR_BROWSER_DATA_OUTSIDE_APP_DIR) {
+ // "XREExeF".parent is the directory that contains firefox, i.e.,
+ // Browser/ or, on Mac OS, TorBrowser.app/Contents/MacOS/.
+ f = Services.dirsvc.get("XREExeF", Ci.nsIFile).parent;
+ if (AppConstants.platform === "macosx") {
+ f = f.parent;
+ f.append("Resources");
+ }
+ f.append("TorBrowser");
+ } else {
+ // "DefProfRt" is .../TorBrowser/Data/Browser
+ f = Services.dirsvc.get("DefProfRt", Ci.nsIFile);
+ f = f.parent.parent; // Remove "Data/Browser"
+ }
+
+ f.append("Docs");
+ f.append("ChangeLog.txt");
+
+ let fs = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(
+ Ci.nsIFileInputStream
+ );
+ fs.init(f, -1, 0, 0);
+ let s = NetUtil.readInputStreamToString(fs, fs.available());
+ fs.close();
+
+ // Truncate at the first empty line.
+ s = s.replace(/[\r\n][\r\n][\s\S]*$/m, "");
+
+ // Split into first line (version plus releaseDate) and
+ // remainder (releaseNotes).
+ // This first match() uses multiline mode with two capture groups:
+ // first line: (.*$)
+ // remaining lines: ([\s\S]+)
+ // [\s\S] matches all characters including end of line. This trick
+ // is needed because when using JavaScript regex in multiline mode,
+ // . does not match an end of line character.
+ let matchArray = s.match(/(.*$)\s*([\s\S]+)/m);
+ if (matchArray && matchArray.length == 3) {
+ info.releaseNotes = matchArray[2];
+ let line1 = matchArray[1];
+ // Extract the version and releaseDate. The first line looks like:
+ // Tor Browser 8.5 -- May 1 2019
+ // The regex uses two capture groups:
+ // text that does not include a hyphen: (^[^-]*)
+ // remaining text: (.*$)
+ // In between we match optional whitespace, one or more hyphens, and
+ // optional whitespace by using: \s*-+\s*
+ matchArray = line1.match(/(^[^-]*)\s*-+\s*(.*$)/);
+ if (matchArray && matchArray.length == 3) {
+ info.version = matchArray[1];
+ info.releaseDate = matchArray[2];
+ } else {
+ info.version = line1; // Match failed: return entire line in version.
+ }
+ } else {
+ info.releaseNotes = s; // Only one line: use as releaseNotes.
+ }
+ } catch (e) {}
+
+ return info;
+ }
+}
diff --git a/browser/actors/moz.build b/browser/actors/moz.build
index 48e3dde6b832..00b0a3630f7c 100644
--- a/browser/actors/moz.build
+++ b/browser/actors/moz.build
@@ -89,3 +89,9 @@ FINAL_TARGET_FILES.actors += [
"WebRTCChild.jsm",
"WebRTCParent.jsm",
]
+
+if CONFIG["TOR_BROWSER_UPDATE"]:
+ FINAL_TARGET_FILES.actors += [
+ "AboutTBUpdateChild.jsm",
+ "AboutTBUpdateParent.jsm",
+ ]
diff --git a/browser/base/content/abouttbupdate/aboutTBUpdate.css b/browser/base/content/abouttbupdate/aboutTBUpdate.css
new file mode 100644
index 000000000000..7c1a34b77f17
--- /dev/null
+++ b/browser/base/content/abouttbupdate/aboutTBUpdate.css
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2019, The Tor Project, Inc.
+ * See LICENSE for licensing information.
+ *
+ * vim: set sw=2 sts=2 ts=8 et syntax=css:
+ */
+
+:root {
+ --abouttor-text-color: white;
+ --abouttor-bg-toron-color: #420C5D;
+}
+
+body {
+ font-family: Helvetica, Arial, sans-serif;
+ color: var(--abouttor-text-color);
+ background-color: var(--abouttor-bg-toron-color);
+ background-attachment: fixed;
+ background-size: 100% 100%;
+}
+
+a {
+ color: var(--abouttor-text-color);
+}
+
+.two-column-grid {
+ display: inline-grid;
+ grid-template-columns: auto auto;
+ grid-column-gap: 50px;
+ margin: 10px 0px 0px 50px;
+}
+
+.two-column-grid div {
+ margin-top: 40px;
+ align-self: baseline; /* Align baseline of text across the row. */
+}
+
+.label-column {
+ font-size: 14px;
+ font-weight: 400;
+}
+
+/*
+ * Use a reduced top margin to bring the row that contains the
+ * "visit our website" link closer to the row that precedes it. This
+ * looks better because the "visit our website" row does not have a
+ * label in the left column.
+ */
+div.more-info-row {
+ margin-top: 5px;
+ font-size: 14px;
+}
+
+#version-content {
+ font-size: 50px;
+ font-weight: 300;
+}
+
+body:not([havereleasedate]) .release-date-cell {
+ display: none;
+}
+
+#releasedate-content {
+ font-size: 17px;
+}
+
+#releasenotes-label {
+ align-self: start; /* Anchor "Release Notes" label at the top. */
+}
+
+#releasenotes-content {
+ font-family: monospace;
+ font-size: 15px;
+ white-space: pre;
+}
diff --git a/browser/base/content/abouttbupdate/aboutTBUpdate.js b/browser/base/content/abouttbupdate/aboutTBUpdate.js
new file mode 100644
index 000000000000..ec070e2cb131
--- /dev/null
+++ b/browser/base/content/abouttbupdate/aboutTBUpdate.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2020, The Tor Project, Inc.
+// See LICENSE for licensing information.
+//
+// vim: set sw=2 sts=2 ts=8 et syntax=javascript:
+
+/* eslint-env mozilla/frame-script */
+
+// aData may contain the following string properties:
+// version
+// releaseDate
+// moreInfoURL
+// releaseNotes
+function onUpdate(aData) {
+ document.getElementById("version-content").textContent = aData.version;
+ if (aData.releaseDate) {
+ document.body.setAttribute("havereleasedate", "true");
+ document.getElementById("releasedate-content").textContent =
+ aData.releaseDate;
+ }
+ if (aData.moreInfoURL) {
+ document.getElementById("infolink").setAttribute("href", aData.moreInfoURL);
+ }
+ document.getElementById("releasenotes-content").textContent =
+ aData.releaseNotes;
+}
+
+RPMSendQuery("FetchUpdateData").then(onUpdate);
diff --git a/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml b/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml
new file mode 100644
index 000000000000..8489cfef5083
--- /dev/null
+++ b/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE html [
+ <!ENTITY % htmlDTD
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "DTD/xhtml1-strict.dtd">
+ %htmlDTD;
+ <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
+ %globalDTD;
+ <!ENTITY % tbUpdateDTD SYSTEM "chrome://browser/locale/aboutTBUpdate.dtd">
+ %tbUpdateDTD;
+]>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Security-Policy" content="default-src chrome:; object-src 'none'" />
+ <title>&aboutTBUpdate.changelogTitle;</title>
+ <link rel="stylesheet" type="text/css"
+ href="chrome://browser/content/abouttbupdate/aboutTBUpdate.css"/>
+ <script src="chrome://browser/content/abouttbupdate/aboutTBUpdate.js"
+ type="text/javascript"/>
+</head>
+<body dir="&locale.dir;">
+<div class="two-column-grid">
+ <div class="label-column">&aboutTBUpdate.version;</div>
+ <div id="version-content"/>
+
+ <div class="label-column release-date-cell">&aboutTBUpdate.releaseDate;</div>
+ <div id="releasedate-content" class="release-date-cell"/>
+
+ <div class="more-info-row"/>
+ <div class="more-info-row">&aboutTBUpdate.linkPrefix;<a id="infolink">&aboutTBUpdate.linkLabel;</a>&aboutTBUpdate.linkSuffix;</div>
+
+ <div id="releasenotes-label"
+ class="label-column">&aboutTBUpdate.releaseNotes;</div>
+ <div id="releasenotes-content"></div>
+</div>
+</body>
+</html>
diff --git a/browser/base/content/browser-siteIdentity.js b/browser/base/content/browser-siteIdentity.js
index 6901ce71814a..acbcc79fb21e 100644
--- a/browser/base/content/browser-siteIdentity.js
+++ b/browser/base/content/browser-siteIdentity.js
@@ -57,7 +57,9 @@ var gIdentityHandler = {
* RegExp used to decide if an about url should be shown as being part of
* the browser UI.
*/
- _secureInternalPages: /^(?:accounts|addons|cache|certificate|config|crashes|downloads|license|logins|preferences|protections|rights|sessionrestore|support|welcomeback|tor|torconnect)(?:[?#]|$)/i,
+ _secureInternalPages: (AppConstants.TOR_BROWSER_UPDATE ?
+ /^(?:accounts|addons|cache|certificate|config|crashes|downloads|license|logins|preferences|protections|rights|sessionrestore|support|welcomeback|tor|torconnect|tbupdate)(?:[?#]|$)/i :
+ /^(?:accounts|addons|cache|certificate|config|crashes|downloads|license|logins|preferences|protections|rights|sessionrestore|support|welcomeback|tor|torconnect)(?:[?#]|$)/i),
/**
* Whether the established HTTPS connection is considered "broken".
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index 1b1439a73c56..d1a07e4cf887 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -650,6 +650,10 @@ var gInitialPages = [
"about:welcome",
];
+if (AppConstants.TOR_BROWSER_UPDATE) {
+ gInitialPages.push("about:tbupdate");
+}
+
function isInitialPage(url) {
if (!(url instanceof Ci.nsIURI)) {
try {
diff --git a/browser/base/jar.mn b/browser/base/jar.mn
index 7be13da2dd5d..6554f6a5707e 100644
--- a/browser/base/jar.mn
+++ b/browser/base/jar.mn
@@ -33,6 +33,11 @@ browser.jar:
content/browser/aboutTabCrashed.css (content/aboutTabCrashed.css)
content/browser/aboutTabCrashed.js (content/aboutTabCrashed.js)
content/browser/aboutTabCrashed.xhtml (content/aboutTabCrashed.xhtml)
+#ifdef TOR_BROWSER_UPDATE
+ content/browser/abouttbupdate/aboutTBUpdate.xhtml (content/abouttbupdate/aboutTBUpdate.xhtml)
+ content/browser/abouttbupdate/aboutTBUpdate.js (content/abouttbupdate/aboutTBUpdate.js)
+ content/browser/abouttbupdate/aboutTBUpdate.css (content/abouttbupdate/aboutTBUpdate.css)
+#endif
* content/browser/browser.css (content/browser.css)
content/browser/browser.js (content/browser.js)
* content/browser/browser.xhtml (content/browser.xhtml)
diff --git a/browser/components/BrowserContentHandler.jsm b/browser/components/BrowserContentHandler.jsm
index d8e24e641447..9f6c8a33a730 100644
--- a/browser/components/BrowserContentHandler.jsm
+++ b/browser/components/BrowserContentHandler.jsm
@@ -629,6 +629,23 @@ nsBrowserContentHandler.prototype = {
}
}
+ // Retrieve the home page early so we can compare it against about:tor
+ // to decide whether or not we need an override page (second tab) after
+ // an update was applied.
+ var startPage = "";
+ try {
+ var choice = prefb.getIntPref("browser.startup.page");
+ if (choice == 1 || choice == 3) {
+ startPage = HomePage.get();
+ }
+ } catch (e) {
+ Cu.reportError(e);
+ }
+
+ if (startPage == "about:blank") {
+ startPage = "";
+ }
+
var override;
var overridePage = "";
var additionalPage = "";
@@ -674,6 +691,16 @@ nsBrowserContentHandler.prototype = {
// into account because that requires waiting for the session file
// to be read. If a crash occurs after updating, before restarting,
// we may open the startPage in addition to restoring the session.
+ //
+ // Tor Browser: Instead of opening the post-update "override page"
+ // directly, we ensure that about:tor will be opened in a special
+ // mode that notifies the user that their browser was updated.
+ // The about:tor page will provide a link to the override page
+ // where the user can learn more about the update, as well as a
+ // link to the Tor Browser changelog page (about:tbupdate). The
+ // override page URL comes from the openURL attribute within the
+ // updates.xml file or, if no showURL action is present, from the
+ // startup.homepage_override_url pref.
willRestoreSession = SessionStartup.isAutomaticRestoreEnabled();
overridePage = Services.urlFormatter.formatURLPref(
@@ -693,6 +720,20 @@ nsBrowserContentHandler.prototype = {
overridePage = overridePage.replace("%OLD_VERSION%", old_mstone);
overridePage = overridePage.replace("%OLD_TOR_BROWSER_VERSION%",
old_tbversion);
+#ifdef TOR_BROWSER_UPDATE
+ if (overridePage)
+ {
+ prefb.setCharPref("torbrowser.post_update.url", overridePage);
+ prefb.setBoolPref("torbrowser.post_update.shouldNotify", true);
+ // If the user's homepage is about:tor, we will inform them
+ // about the update on that page; otherwise, we arrange to
+ // open about:tor in a secondary tab.
+ if (startPage === "about:tor")
+ overridePage = "";
+ else
+ overridePage = "about:tor";
+ }
+#endif
break;
case OVERRIDE_NEW_BUILD_ID:
if (UpdateManager.readyUpdate) {
@@ -765,20 +806,6 @@ nsBrowserContentHandler.prototype = {
}
}
- var startPage = "";
- try {
- var choice = prefb.getIntPref("browser.startup.page");
- if (choice == 1 || choice == 3) {
- startPage = HomePage.get();
- }
- } catch (e) {
- Cu.reportError(e);
- }
-
- if (startPage == "about:blank") {
- startPage = "";
- }
-
let skipStartPage =
override == OVERRIDE_NEW_PROFILE &&
prefb.getBoolPref("browser.startup.firstrunSkipsHomepage");
diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm
index 2953decbd4e4..21912b6913f2 100644
--- a/browser/components/BrowserGlue.jsm
+++ b/browser/components/BrowserGlue.jsm
@@ -765,6 +765,21 @@ let JSWINDOWACTORS = {
},
};
+if (AppConstants.TOR_BROWSER_UPDATE) {
+ JSWINDOWACTORS["AboutTBUpdate"] = {
+ parent: {
+ moduleURI: "resource:///actors/AboutTBUpdateParent.jsm",
+ },
+ child: {
+ moduleURI: "resource:///actors/AboutTBUpdateChild.jsm",
+ events: {
+ DOMWindowCreated: { capture: true },
+ },
+ },
+ matches: ["about:tbupdate"],
+ };
+}
+
(function earlyBlankFirstPaint() {
let startTime = Cu.now();
if (
diff --git a/browser/components/about/AboutRedirector.cpp b/browser/components/about/AboutRedirector.cpp
index 21f673f601d2..fd828a630c92 100644
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -122,6 +122,12 @@ static const RedirEntry kRedirMap[] = {
nsIAboutModule::HIDE_FROM_ABOUTABOUT},
{"restartrequired", "chrome://browser/content/aboutRestartRequired.xhtml",
nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::HIDE_FROM_ABOUTABOUT},
+#ifdef TOR_BROWSER_UPDATE
+ {"tbupdate", "chrome://browser/content/abouttbupdate/aboutTBUpdate.xhtml",
+ nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
+ nsIAboutModule::URI_MUST_LOAD_IN_CHILD | nsIAboutModule::ALLOW_SCRIPT |
+ nsIAboutModule::HIDE_FROM_ABOUTABOUT},
+#endif
{"torconnect", "chrome://browser/content/torconnect/aboutTorConnect.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::URI_CAN_LOAD_IN_CHILD | nsIAboutModule::ALLOW_SCRIPT |
diff --git a/browser/components/about/components.conf b/browser/components/about/components.conf
index 733abef1a80f..0916bb75e1d5 100644
--- a/browser/components/about/components.conf
+++ b/browser/components/about/components.conf
@@ -31,6 +31,9 @@ pages = [
'welcomeback',
]
+if defined('TOR_BROWSER_UPDATE'):
+ pages.append('tbupdate')
+
Classes = [
{
'cid': '{7e4bb6ad-2fc4-4dc6-89ef-23e8e5ccf980}',
diff --git a/browser/components/moz.build b/browser/components/moz.build
index ec8fab7fbc8f..d29df1d3df99 100644
--- a/browser/components/moz.build
+++ b/browser/components/moz.build
@@ -88,11 +88,14 @@ EXTRA_COMPONENTS += [
]
EXTRA_JS_MODULES += [
- "BrowserContentHandler.jsm",
"BrowserGlue.jsm",
"distribution.js",
]
+EXTRA_PP_JS_MODULES += [
+ "BrowserContentHandler.jsm",
+]
+
BROWSER_CHROME_MANIFESTS += [
"safebrowsing/content/test/browser.ini",
"tests/browser/browser.ini",
diff --git a/browser/locales/en-US/chrome/browser/aboutTBUpdate.dtd b/browser/locales/en-US/chrome/browser/aboutTBUpdate.dtd
new file mode 100644
index 000000000000..2d1e59b40eaf
--- /dev/null
+++ b/browser/locales/en-US/chrome/browser/aboutTBUpdate.dtd
@@ -0,0 +1,8 @@
+<!ENTITY aboutTBUpdate.changelogTitle "Tor Browser Changelog">
+<!ENTITY aboutTBUpdate.updated "Tor Browser has been updated.">
+<!ENTITY aboutTBUpdate.linkPrefix "For the most up-to-date information about this release, ">
+<!ENTITY aboutTBUpdate.linkLabel "visit our website">
+<!ENTITY aboutTBUpdate.linkSuffix ".">
+<!ENTITY aboutTBUpdate.version "Version">
+<!ENTITY aboutTBUpdate.releaseDate "Release Date">
+<!ENTITY aboutTBUpdate.releaseNotes "Release Notes">
diff --git a/browser/locales/jar.mn b/browser/locales/jar.mn
index fd6e0ac76843..90bc7a0d4757 100644
--- a/browser/locales/jar.mn
+++ b/browser/locales/jar.mn
@@ -20,6 +20,9 @@
locale/browser/accounts.properties (%chrome/browser/accounts.properties)
locale/browser/app-extension-fields.properties (%chrome/browser/app-extension-fields.properties)
+#ifdef TOR_BROWSER_UPDATE
+ locale/browser/aboutTBUpdate.dtd (%chrome/browser/aboutTBUpdate.dtd)
+#endif
locale/browser/browser.dtd (%chrome/browser/browser.dtd)
locale/browser/browser.properties (%chrome/browser/browser.properties)
locale/browser/customizableui/customizableWidgets.properties (%chrome/browser/customizableui/customizableWidgets.properties)
diff --git a/toolkit/modules/RemotePageAccessManager.jsm b/toolkit/modules/RemotePageAccessManager.jsm
index 486409ab5c8b..9a762dc19d76 100644
--- a/toolkit/modules/RemotePageAccessManager.jsm
+++ b/toolkit/modules/RemotePageAccessManager.jsm
@@ -214,6 +214,11 @@ let RemotePageAccessManager = {
RPMAddMessageListener: ["*"],
RPMRemoveMessageListener: ["*"],
},
+ "about:tbupdate": {
+ RPMSendQuery: [
+ "FetchUpdateData",
+ ],
+ },
"about:torconnect": {
RPMAddMessageListener: [
"torconnect:state-change",
1
0

[tor-browser/tor-browser-91.5.0esr-11.5-2] Bug 40091: Load HTTPS Everywhere as a builtin addon in desktop
by richard@torproject.org 01 Feb '22
by richard@torproject.org 01 Feb '22
01 Feb '22
commit 5024367261743d3ca9fd8ab0453946af5315c978
Author: Alex Catarineu <acat(a)torproject.org>
Date: Fri Sep 4 12:34:35 2020 +0200
Bug 40091: Load HTTPS Everywhere as a builtin addon in desktop
This loads HTTPS Everywhere as a builtin addon from a hardcoded
resource:// URI in desktop. It also ensures that the non-builtin
HTTPS Everywhere addon is always uninstalled on browser startup.
The reason of making this desktop-only is that there are some issues
when installing a builtin extension from geckoview side, making
the extension not available on first startup. So, at least for
now we handle the Fenix case separately. See #40118 for a followup
for investigating these.
---
browser/components/BrowserGlue.jsm | 37 ++++++++++++++++++++++
toolkit/components/extensions/Extension.jsm | 10 ++++--
.../mozapps/extensions/internal/XPIProvider.jsm | 13 ++++++++
3 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm
index fdb8a35f96ac..2953decbd4e4 100644
--- a/browser/components/BrowserGlue.jsm
+++ b/browser/components/BrowserGlue.jsm
@@ -45,6 +45,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
DownloadsViewableInternally:
"resource:///modules/DownloadsViewableInternally.jsm",
E10SUtils: "resource://gre/modules/E10SUtils.jsm",
+ ExtensionData: "resource://gre/modules/Extension.jsm",
ExtensionsUI: "resource:///modules/ExtensionsUI.jsm",
FeatureGate: "resource://featuregates/FeatureGate.jsm",
FxAccounts: "resource://gre/modules/FxAccounts.jsm",
@@ -119,6 +120,13 @@ XPCOMUtils.defineLazyServiceGetters(this, {
PushService: ["@mozilla.org/push/Service;1", "nsIPushService"],
});
+XPCOMUtils.defineLazyServiceGetters(this, {
+ resProto: [
+ "@mozilla.org/network/protocol;1?name=resource",
+ "nsISubstitutingProtocolHandler",
+ ],
+});
+
const PREF_PDFJS_ISDEFAULT_CACHE_STATE = "pdfjs.enabledCache.state";
/**
@@ -1399,6 +1407,35 @@ BrowserGlue.prototype = {
"resource://builtin-themes/alpenglow/"
);
+ // Install https-everywhere builtin addon if needed.
+ (async () => {
+ const HTTPS_EVERYWHERE_ID = "https-everywhere-eff(a)eff.org";
+ const HTTPS_EVERYWHERE_BUILTIN_URL =
+ "resource://torbutton/content/extensions/https-everywhere/";
+ // This does something similar as GeckoViewWebExtension.jsm: it tries
+ // to load the manifest to retrieve the version of the builtin and
+ // compares it to the currently installed one to see whether we need
+ // to install or not. Here we delegate that to
+ // AddonManager.maybeInstallBuiltinAddon.
+ try {
+ const resolvedURI = Services.io.newURI(
+ resProto.resolveURI(Services.io.newURI(HTTPS_EVERYWHERE_BUILTIN_URL))
+ );
+ const extensionData = new ExtensionData(resolvedURI);
+ const manifest = await extensionData.loadManifest();
+
+ await AddonManager.maybeInstallBuiltinAddon(
+ HTTPS_EVERYWHERE_ID,
+ manifest.version,
+ HTTPS_EVERYWHERE_BUILTIN_URL
+ );
+ } catch (e) {
+ const log = Log.repository.getLogger("HttpsEverywhereBuiltinLoader");
+ log.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter()));
+ log.error("Could not install https-everywhere extension", e);
+ }
+ })();
+
if (AppConstants.MOZ_NORMANDY) {
Normandy.init();
}
diff --git a/toolkit/components/extensions/Extension.jsm b/toolkit/components/extensions/Extension.jsm
index 08c5cf8a9190..783ec7c3391d 100644
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -267,6 +267,7 @@ const LOGGER_ID_BASE = "addons.webextension.";
const UUID_MAP_PREF = "extensions.webextensions.uuids";
const LEAVE_STORAGE_PREF = "extensions.webextensions.keepStorageOnUninstall";
const LEAVE_UUID_PREF = "extensions.webextensions.keepUuidOnUninstall";
+const PERSISTENT_EXTENSIONS = new Set(["https-everywhere-eff(a)eff.org"]);
const COMMENT_REGEXP = new RegExp(
String.raw`
@@ -413,7 +414,8 @@ var ExtensionAddonObserver = {
);
}
- if (!Services.prefs.getBoolPref(LEAVE_STORAGE_PREF, false)) {
+ if (!Services.prefs.getBoolPref(LEAVE_STORAGE_PREF, false) &&
+ !PERSISTENT_EXTENSIONS.has(addon.id)) {
// Clear browser.storage.local backends.
AsyncShutdown.profileChangeTeardown.addBlocker(
`Clear Extension Storage ${addon.id} (File Backend)`,
@@ -461,7 +463,8 @@ var ExtensionAddonObserver = {
ExtensionPermissions.removeAll(addon.id);
- if (!Services.prefs.getBoolPref(LEAVE_UUID_PREF, false)) {
+ if (!Services.prefs.getBoolPref(LEAVE_UUID_PREF, false) &&
+ !PERSISTENT_EXTENSIONS.has(addon.id)) {
// Clear the entry in the UUID map
UUIDMap.remove(addon.id);
}
@@ -2696,7 +2699,8 @@ class Extension extends ExtensionData {
);
} else if (
this.startupReason === "ADDON_INSTALL" &&
- !Services.prefs.getBoolPref(LEAVE_STORAGE_PREF, false)
+ !Services.prefs.getBoolPref(LEAVE_STORAGE_PREF, false) &&
+ !PERSISTENT_EXTENSIONS.has(this.id)
) {
// If the extension has been just installed, set it as migrated,
// because there will not be any data to migrate.
diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
index 04d57a42348e..fd1e3f75935d 100644
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -1495,6 +1495,19 @@ var XPIStates = {
continue;
}
+ // Uninstall HTTPS Everywhere if it is installed in the user profile.
+ if (
+ id === "https-everywhere-eff(a)eff.org" &&
+ loc.name === KEY_APP_PROFILE
+ ) {
+ logger.debug(
+ "Uninstalling the HTTPS Everywhere extension from user profile."
+ );
+ loc.installer.uninstallAddon(id);
+ changed = true;
+ continue;
+ }
+
let xpiState = loc.get(id);
if (!xpiState) {
// If the location is not supported for sideloading, skip new
1
0

[tor-browser/tor-browser-91.5.0esr-11.5-2] Bug 30237: Add v3 onion services client authentication prompt
by richard@torproject.org 01 Feb '22
by richard@torproject.org 01 Feb '22
01 Feb '22
commit d07242fde5cab23362bebbfbfeab3286f9d76c6c
Author: Kathy Brade <brade(a)pearlcrescent.com>
Date: Tue Nov 12 16:11:05 2019 -0500
Bug 30237: Add v3 onion services client authentication prompt
When Tor informs the browser that client authentication is needed,
temporarily load about:blank instead of about:neterror and prompt
for the user's key.
If a correctly formatted key is entered, use Tor's ONION_CLIENT_AUTH_ADD
control port command to add the key (via Torbutton's control port
module) and reload the page.
If the user cancels the prompt, display the standard about:neterror
"Unable to connect" page. This requires a small change to
browser/actors/NetErrorChild.jsm to account for the fact that the
docShell no longer has the failedChannel information. The failedChannel
is used to extract TLS-related error info, which is not applicable
in the case of a canceled .onion authentication prompt.
Add a leaveOpen option to PopupNotifications.show so we can display
error messages within the popup notification doorhanger without
closing the prompt.
Add support for onion services strings to the TorStrings module.
Add support for Tor extended SOCKS errors (Tor proposal 304) to the
socket transport and SOCKS layers. Improved display of all of these
errors will be implemented as part of bug 30025.
Also fixes bug 19757:
Add a "Remember this key" checkbox to the client auth prompt.
Add an "Onion Services Authentication" section within the
about:preferences "Privacy & Security section" to allow
viewing and removal of v3 onion client auth keys that have
been stored on disk.
Also fixes bug 19251: use enhanced error pages for onion service errors.
---
browser/actors/NetErrorChild.jsm | 7 +
browser/base/content/browser.js | 10 +
browser/base/content/browser.xhtml | 1 +
browser/base/content/certerror/aboutNetError.js | 10 +-
browser/base/content/certerror/aboutNetError.xhtml | 1 +
browser/base/content/main-popupset.inc.xhtml | 1 +
browser/base/content/navigator-toolbox.inc.xhtml | 1 +
browser/base/content/tab-content.js | 6 +
browser/components/moz.build | 1 +
.../content/authNotificationIcon.inc.xhtml | 6 +
.../onionservices/content/authPopup.inc.xhtml | 16 ++
.../onionservices/content/authPreferences.css | 20 ++
.../content/authPreferences.inc.xhtml | 19 ++
.../onionservices/content/authPreferences.js | 66 +++++
.../components/onionservices/content/authPrompt.js | 316 +++++++++++++++++++++
.../components/onionservices/content/authUtil.jsm | 47 +++
.../onionservices/content/netError/browser.svg | 3 +
.../onionservices/content/netError/network.svg | 3 +
.../content/netError/onionNetError.css | 88 ++++++
.../content/netError/onionNetError.js | 243 ++++++++++++++++
.../onionservices/content/netError/onionsite.svg | 8 +
.../onionservices/content/onionservices.css | 69 +++++
.../onionservices/content/savedKeysDialog.js | 259 +++++++++++++++++
.../onionservices/content/savedKeysDialog.xhtml | 42 +++
browser/components/onionservices/jar.mn | 9 +
browser/components/onionservices/moz.build | 1 +
browser/components/preferences/preferences.xhtml | 1 +
browser/components/preferences/privacy.inc.xhtml | 2 +
browser/components/preferences/privacy.js | 7 +
browser/themes/shared/notification-icons.inc.css | 3 +
docshell/base/nsDocShell.cpp | 81 +++++-
dom/ipc/BrowserParent.cpp | 21 ++
dom/ipc/BrowserParent.h | 3 +
dom/ipc/PBrowser.ipdl | 9 +
js/xpconnect/src/xpc.msg | 10 +
netwerk/base/nsSocketTransport2.cpp | 6 +
netwerk/socket/nsSOCKSIOLayer.cpp | 49 ++++
toolkit/modules/PopupNotifications.jsm | 6 +
toolkit/modules/RemotePageAccessManager.jsm | 1 +
.../lib/environments/frame-script.js | 1 +
xpcom/base/ErrorList.py | 22 ++
41 files changed, 1473 insertions(+), 2 deletions(-)
diff --git a/browser/actors/NetErrorChild.jsm b/browser/actors/NetErrorChild.jsm
index 82978412fe24..164fb7c95cd1 100644
--- a/browser/actors/NetErrorChild.jsm
+++ b/browser/actors/NetErrorChild.jsm
@@ -13,6 +13,8 @@ const { RemotePageChild } = ChromeUtils.import(
"resource://gre/actors/RemotePageChild.jsm"
);
+const { TorStrings } = ChromeUtils.import("resource:///modules/TorStrings.jsm");
+
XPCOMUtils.defineLazyServiceGetter(
this,
"gSerializationHelper",
@@ -33,6 +35,7 @@ class NetErrorChild extends RemotePageChild {
"RPMAddToHistogram",
"RPMRecordTelemetryEvent",
"RPMGetHttpResponseHeader",
+ "RPMGetTorStrings",
];
this.exportFunctions(exportableFunctions);
}
@@ -115,4 +118,8 @@ class NetErrorChild extends RemotePageChild {
return "";
}
+
+ RPMGetTorStrings() {
+ return Cu.cloneInto(TorStrings.onionServices, this.contentWindow);
+ }
}
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index d1a07e4cf887..4f7852d1b510 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -230,6 +230,11 @@ XPCOMUtils.defineLazyScriptGetter(
["SecurityLevelButton"],
"chrome://browser/content/securitylevel/securityLevel.js"
);
+XPCOMUtils.defineLazyScriptGetter(
+ this,
+ ["OnionAuthPrompt"],
+ "chrome://browser/content/onionservices/authPrompt.js"
+);
XPCOMUtils.defineLazyScriptGetter(
this,
"gEditItemOverlay",
@@ -1773,6 +1778,9 @@ var gBrowserInit = {
// Init the SecuritySettingsButton
SecurityLevelButton.init();
+ // Init the OnionAuthPrompt
+ OnionAuthPrompt.init();
+
// Certain kinds of automigration rely on this notification to complete
// their tasks BEFORE the browser window is shown. SessionStore uses it to
// restore tabs into windows AFTER important parts like gMultiProcessBrowser
@@ -2508,6 +2516,8 @@ var gBrowserInit = {
SecurityLevelButton.uninit();
+ OnionAuthPrompt.uninit();
+
TorBootstrapUrlbar.uninit();
gAccessibilityServiceIndicator.uninit();
diff --git a/browser/base/content/browser.xhtml b/browser/base/content/browser.xhtml
index 627e6ac0f8a0..394a46414018 100644
--- a/browser/base/content/browser.xhtml
+++ b/browser/base/content/browser.xhtml
@@ -34,6 +34,7 @@
<?xml-stylesheet href="chrome://browser/skin/places/editBookmark.css" type="text/css"?>
<?xml-stylesheet href="chrome://torbutton/skin/tor-circuit-display.css" type="text/css"?>
<?xml-stylesheet href="chrome://torbutton/skin/torbutton.css" type="text/css"?>
+<?xml-stylesheet href="chrome://browser/content/onionservices/onionservices.css" type="text/css"?>
# All DTD information is stored in a separate file so that it can be shared by
# hiddenWindowMac.xhtml.
diff --git a/browser/base/content/certerror/aboutNetError.js b/browser/base/content/certerror/aboutNetError.js
index edf97c2a5daf..60f602ba6530 100644
--- a/browser/base/content/certerror/aboutNetError.js
+++ b/browser/base/content/certerror/aboutNetError.js
@@ -3,6 +3,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env mozilla/frame-script */
+/* import-globals-from ../../components/onionservices/content/netError/onionNetError.js */
import "chrome://global/content/certviewer/pvutils_bundle.js";
import "chrome://global/content/certviewer/asn1js_bundle.js";
@@ -317,7 +318,10 @@ async function initPage() {
errDesc = document.getElementById("ed_generic");
}
- setErrorPageStrings(err);
+ const isOnionError = err.startsWith("onionServices.");
+ if (!isOnionError) {
+ setErrorPageStrings(err);
+ }
var sd = document.getElementById("errorShortDescText");
if (sd) {
@@ -469,6 +473,10 @@ async function initPage() {
span.textContent = HOST_NAME;
}
}
+
+ if (isOnionError) {
+ OnionServicesAboutNetError.initPage(document);
+ }
}
function setupBlockingReportingUI() {
diff --git a/browser/base/content/certerror/aboutNetError.xhtml b/browser/base/content/certerror/aboutNetError.xhtml
index c645a2f2cc77..bf9a8fd58347 100644
--- a/browser/base/content/certerror/aboutNetError.xhtml
+++ b/browser/base/content/certerror/aboutNetError.xhtml
@@ -209,5 +209,6 @@
</div>
</body>
<script src="chrome://browser/content/certerror/aboutNetErrorCodes.js"/>
+ <script src="chrome://browser/content/onionservices/netError/onionNetError.js"/>
<script type="module" src="chrome://browser/content/certerror/aboutNetError.js"/>
</html>
diff --git a/browser/base/content/main-popupset.inc.xhtml b/browser/base/content/main-popupset.inc.xhtml
index 3fc665c65d79..a96aaa9c187d 100644
--- a/browser/base/content/main-popupset.inc.xhtml
+++ b/browser/base/content/main-popupset.inc.xhtml
@@ -521,6 +521,7 @@
#include ../../components/downloads/content/downloadsPanel.inc.xhtml
#include ../../../devtools/startup/enableDevToolsPopup.inc.xhtml
#include ../../components/securitylevel/content/securityLevelPanel.inc.xhtml
+#include ../../components/onionservices/content/authPopup.inc.xhtml
#include browser-allTabsMenu.inc.xhtml
<tooltip id="dynamic-shortcut-tooltip"
diff --git a/browser/base/content/navigator-toolbox.inc.xhtml b/browser/base/content/navigator-toolbox.inc.xhtml
index e10e0580b8ec..810a77e57766 100644
--- a/browser/base/content/navigator-toolbox.inc.xhtml
+++ b/browser/base/content/navigator-toolbox.inc.xhtml
@@ -268,6 +268,7 @@
data-l10n-id="urlbar-indexed-db-notification-anchor"/>
<image id="password-notification-icon" class="notification-anchor-icon login-icon" role="button"
data-l10n-id="urlbar-password-notification-anchor"/>
+#include ../../components/onionservices/content/authNotificationIcon.inc.xhtml
<stack id="plugins-notification-icon" class="notification-anchor-icon" role="button" align="center" data-l10n-id="urlbar-plugins-notification-anchor">
<image class="plugin-icon" />
<image id="plugin-icon-badge" />
diff --git a/browser/base/content/tab-content.js b/browser/base/content/tab-content.js
index 83e55cf5ed87..96360a4307d2 100644
--- a/browser/base/content/tab-content.js
+++ b/browser/base/content/tab-content.js
@@ -7,4 +7,10 @@
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+var { OnionAuthUtil } = ChromeUtils.import(
+ "chrome://browser/content/onionservices/authUtil.jsm"
+);
+
Services.obs.notifyObservers(this, "tab-content-frameloader-created");
+
+OnionAuthUtil.addCancelMessageListener(this, docShell);
diff --git a/browser/components/moz.build b/browser/components/moz.build
index d29df1d3df99..c30497374912 100644
--- a/browser/components/moz.build
+++ b/browser/components/moz.build
@@ -38,6 +38,7 @@ DIRS += [
"extensions",
"migration",
"newtab",
+ "onionservices",
"originattributes",
"ion",
"places",
diff --git a/browser/components/onionservices/content/authNotificationIcon.inc.xhtml b/browser/components/onionservices/content/authNotificationIcon.inc.xhtml
new file mode 100644
index 000000000000..91274d612739
--- /dev/null
+++ b/browser/components/onionservices/content/authNotificationIcon.inc.xhtml
@@ -0,0 +1,6 @@
+# Copyright (c) 2020, The Tor Project, Inc.
+
+<image id="tor-clientauth-notification-icon"
+ class="notification-anchor-icon tor-clientauth-icon"
+ role="button"
+ tooltiptext="&torbutton.onionServices.authPrompt.tooltip;"/>
diff --git a/browser/components/onionservices/content/authPopup.inc.xhtml b/browser/components/onionservices/content/authPopup.inc.xhtml
new file mode 100644
index 000000000000..bd0ec3aa0b00
--- /dev/null
+++ b/browser/components/onionservices/content/authPopup.inc.xhtml
@@ -0,0 +1,16 @@
+# Copyright (c) 2020, The Tor Project, Inc.
+
+<popupnotification id="tor-clientauth-notification" hidden="true">
+ <popupnotificationcontent orient="vertical">
+ <description id="tor-clientauth-notification-desc"/>
+ <label id="tor-clientauth-notification-learnmore"
+ class="text-link popup-notification-learnmore-link"
+ is="text-link"/>
+ <html:div>
+ <html:input id="tor-clientauth-notification-key" type="password"/>
+ <html:div id="tor-clientauth-warning"/>
+ <checkbox id="tor-clientauth-persistkey-checkbox"
+ label="&torbutton.onionServices.authPrompt.persistCheckboxLabel;"/>
+ </html:div>
+ </popupnotificationcontent>
+</popupnotification>
diff --git a/browser/components/onionservices/content/authPreferences.css b/browser/components/onionservices/content/authPreferences.css
new file mode 100644
index 000000000000..b3fb79b26ddc
--- /dev/null
+++ b/browser/components/onionservices/content/authPreferences.css
@@ -0,0 +1,20 @@
+/* Copyright (c) 2020, The Tor Project, Inc. */
+
+#torOnionServiceKeys-overview-container {
+ margin-right: 30px;
+}
+
+#onionservices-savedkeys-tree treechildren::-moz-tree-cell-text {
+ font-size: 80%;
+}
+
+#onionservices-savedkeys-errorContainer {
+ margin-top: 4px;
+ min-height: 3em;
+}
+
+#onionservices-savedkeys-errorIcon {
+ margin-right: 4px;
+ list-style-image: url("chrome://browser/skin/warning.svg");
+ visibility: hidden;
+}
diff --git a/browser/components/onionservices/content/authPreferences.inc.xhtml b/browser/components/onionservices/content/authPreferences.inc.xhtml
new file mode 100644
index 000000000000..f69c9dde66a2
--- /dev/null
+++ b/browser/components/onionservices/content/authPreferences.inc.xhtml
@@ -0,0 +1,19 @@
+# Copyright (c) 2020, The Tor Project, Inc.
+
+<groupbox id="torOnionServiceKeys" orient="vertical"
+ data-category="panePrivacy" hidden="true">
+ <label><html:h2 id="torOnionServiceKeys-header"/></label>
+ <hbox>
+ <description id="torOnionServiceKeys-overview-container" flex="1">
+ <html:span id="torOnionServiceKeys-overview"
+ class="tail-with-learn-more"/>
+ <label id="torOnionServiceKeys-learnMore" class="learnMore text-link"
+ is="text-link"/>
+ </description>
+ <vbox align="end">
+ <button id="torOnionServiceKeys-savedKeys"
+ is="highlightable-button"
+ class="accessory-button"/>
+ </vbox>
+ </hbox>
+</groupbox>
diff --git a/browser/components/onionservices/content/authPreferences.js b/browser/components/onionservices/content/authPreferences.js
new file mode 100644
index 000000000000..52f8272020cc
--- /dev/null
+++ b/browser/components/onionservices/content/authPreferences.js
@@ -0,0 +1,66 @@
+// Copyright (c) 2020, The Tor Project, Inc.
+
+"use strict";
+
+ChromeUtils.defineModuleGetter(
+ this,
+ "TorStrings",
+ "resource:///modules/TorStrings.jsm"
+);
+
+/*
+ Onion Services Client Authentication Preferences Code
+
+ Code to handle init and update of onion services authentication section
+ in about:preferences#privacy
+*/
+
+const OnionServicesAuthPreferences = {
+ selector: {
+ groupBox: "#torOnionServiceKeys",
+ header: "#torOnionServiceKeys-header",
+ overview: "#torOnionServiceKeys-overview",
+ learnMore: "#torOnionServiceKeys-learnMore",
+ savedKeysButton: "#torOnionServiceKeys-savedKeys",
+ },
+
+ init() {
+ // populate XUL with localized strings
+ this._populateXUL();
+ },
+
+ _populateXUL() {
+ const groupbox = document.querySelector(this.selector.groupBox);
+
+ let elem = groupbox.querySelector(this.selector.header);
+ elem.textContent = TorStrings.onionServices.authPreferences.header;
+
+ elem = groupbox.querySelector(this.selector.overview);
+ elem.textContent = TorStrings.onionServices.authPreferences.overview;
+
+ elem = groupbox.querySelector(this.selector.learnMore);
+ elem.setAttribute("value", TorStrings.onionServices.learnMore);
+ elem.setAttribute("href", TorStrings.onionServices.learnMoreURL);
+
+ elem = groupbox.querySelector(this.selector.savedKeysButton);
+ elem.setAttribute(
+ "label",
+ TorStrings.onionServices.authPreferences.savedKeys
+ );
+ elem.addEventListener("command", () =>
+ OnionServicesAuthPreferences.onViewSavedKeys()
+ );
+ },
+
+ onViewSavedKeys() {
+ gSubDialog.open(
+ "chrome://browser/content/onionservices/savedKeysDialog.xhtml"
+ );
+ },
+}; // OnionServicesAuthPreferences
+
+Object.defineProperty(this, "OnionServicesAuthPreferences", {
+ value: OnionServicesAuthPreferences,
+ enumerable: true,
+ writable: false,
+});
diff --git a/browser/components/onionservices/content/authPrompt.js b/browser/components/onionservices/content/authPrompt.js
new file mode 100644
index 000000000000..d4a59ac46487
--- /dev/null
+++ b/browser/components/onionservices/content/authPrompt.js
@@ -0,0 +1,316 @@
+// Copyright (c) 2020, The Tor Project, Inc.
+
+"use strict";
+
+XPCOMUtils.defineLazyModuleGetters(this, {
+ OnionAuthUtil: "chrome://browser/content/onionservices/authUtil.jsm",
+ CommonUtils: "resource://services-common/utils.js",
+ TorStrings: "resource:///modules/TorStrings.jsm",
+});
+
+const OnionAuthPrompt = (function() {
+ // OnionServicesAuthPrompt objects run within the main/chrome process.
+ // aReason is the topic passed within the observer notification that is
+ // causing this auth prompt to be displayed.
+ function OnionServicesAuthPrompt(aBrowser, aFailedURI, aReason, aOnionName) {
+ this._browser = aBrowser;
+ this._failedURI = aFailedURI;
+ this._reasonForPrompt = aReason;
+ this._onionName = aOnionName;
+ }
+
+ OnionServicesAuthPrompt.prototype = {
+ show(aWarningMessage) {
+ let mainAction = {
+ label: TorStrings.onionServices.authPrompt.done,
+ accessKey: TorStrings.onionServices.authPrompt.doneAccessKey,
+ leaveOpen: true, // Callback is responsible for closing the notification.
+ callback: this._onDone.bind(this),
+ };
+
+ let dialogBundle = Services.strings.createBundle(
+ "chrome://global/locale/dialog.properties");
+
+ let cancelAccessKey = dialogBundle.GetStringFromName("accesskey-cancel");
+ if (!cancelAccessKey)
+ cancelAccessKey = "c"; // required by PopupNotifications.show()
+
+ let cancelAction = {
+ label: dialogBundle.GetStringFromName("button-cancel"),
+ accessKey: cancelAccessKey,
+ callback: this._onCancel.bind(this),
+ };
+
+ let _this = this;
+ let options = {
+ autofocus: true,
+ hideClose: true,
+ persistent: true,
+ removeOnDismissal: false,
+ eventCallback(aTopic) {
+ if (aTopic === "showing") {
+ _this._onPromptShowing(aWarningMessage);
+ } else if (aTopic === "shown") {
+ _this._onPromptShown();
+ } else if (aTopic === "removed") {
+ _this._onPromptRemoved();
+ }
+ }
+ };
+
+ this._prompt = PopupNotifications.show(this._browser,
+ OnionAuthUtil.domid.notification, "",
+ OnionAuthUtil.domid.anchor,
+ mainAction, [cancelAction], options);
+ },
+
+ _onPromptShowing(aWarningMessage) {
+ let xulDoc = this._browser.ownerDocument;
+ let descElem = xulDoc.getElementById(OnionAuthUtil.domid.description);
+ if (descElem) {
+ // Handle replacement of the onion name within the localized
+ // string ourselves so we can show the onion name as bold text.
+ // We do this by splitting the localized string and creating
+ // several HTML <span> elements.
+ while (descElem.firstChild)
+ descElem.removeChild(descElem.firstChild);
+
+ let fmtString = TorStrings.onionServices.authPrompt.description;
+ let prefix = "";
+ let suffix = "";
+ const kToReplace = "%S";
+ let idx = fmtString.indexOf(kToReplace);
+ if (idx < 0) {
+ prefix = fmtString;
+ } else {
+ prefix = fmtString.substring(0, idx);
+ suffix = fmtString.substring(idx + kToReplace.length);
+ }
+
+ const kHTMLNS = "http://www.w3.org/1999/xhtml";
+ let span = xulDoc.createElementNS(kHTMLNS, "span");
+ span.textContent = prefix;
+ descElem.appendChild(span);
+ span = xulDoc.createElementNS(kHTMLNS, "span");
+ span.id = OnionAuthUtil.domid.onionNameSpan;
+ span.textContent = this._onionName;
+ descElem.appendChild(span);
+ span = xulDoc.createElementNS(kHTMLNS, "span");
+ span.textContent = suffix;
+ descElem.appendChild(span);
+ }
+
+ // Set "Learn More" label and href.
+ let learnMoreElem = xulDoc.getElementById(OnionAuthUtil.domid.learnMore);
+ if (learnMoreElem) {
+ learnMoreElem.setAttribute("value", TorStrings.onionServices.learnMore);
+ learnMoreElem.setAttribute("href", TorStrings.onionServices.learnMoreURL);
+ }
+
+ this._showWarning(aWarningMessage);
+ let checkboxElem = this._getCheckboxElement();
+ if (checkboxElem) {
+ checkboxElem.checked = false;
+ }
+ },
+
+ _onPromptShown() {
+ let keyElem = this._getKeyElement();
+ if (keyElem) {
+ keyElem.setAttribute("placeholder",
+ TorStrings.onionServices.authPrompt.keyPlaceholder);
+ this._boundOnKeyFieldKeyPress = this._onKeyFieldKeyPress.bind(this);
+ this._boundOnKeyFieldInput = this._onKeyFieldInput.bind(this);
+ keyElem.addEventListener("keypress", this._boundOnKeyFieldKeyPress);
+ keyElem.addEventListener("input", this._boundOnKeyFieldInput);
+ keyElem.focus();
+ }
+ },
+
+ _onPromptRemoved() {
+ if (this._boundOnKeyFieldKeyPress) {
+ let keyElem = this._getKeyElement();
+ if (keyElem) {
+ keyElem.value = "";
+ keyElem.removeEventListener("keypress",
+ this._boundOnKeyFieldKeyPress);
+ this._boundOnKeyFieldKeyPress = undefined;
+ keyElem.removeEventListener("input", this._boundOnKeyFieldInput);
+ this._boundOnKeyFieldInput = undefined;
+ }
+ }
+ },
+
+ _onKeyFieldKeyPress(aEvent) {
+ if (aEvent.keyCode == aEvent.DOM_VK_RETURN) {
+ this._onDone();
+ } else if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE) {
+ this._prompt.remove();
+ this._onCancel();
+ }
+ },
+
+ _onKeyFieldInput(aEvent) {
+ this._showWarning(undefined); // Remove the warning.
+ },
+
+ _onDone() {
+ let keyElem = this._getKeyElement();
+ if (!keyElem)
+ return;
+
+ let base64key = this._keyToBase64(keyElem.value);
+ if (!base64key) {
+ this._showWarning(TorStrings.onionServices.authPrompt.invalidKey);
+ return;
+ }
+
+ this._prompt.remove();
+
+ // Use Torbutton's controller module to add the private key to Tor.
+ let controllerFailureMsg =
+ TorStrings.onionServices.authPrompt.failedToSetKey;
+ try {
+ let { controller } =
+ Cu.import("resource://torbutton/modules/tor-control-port.js", {});
+ let torController = controller(aError => {
+ this.show(controllerFailureMsg);
+ });
+ let onionAddr = this._onionName.toLowerCase().replace(/\.onion$/, "");
+ let checkboxElem = this._getCheckboxElement();
+ let isPermanent = (checkboxElem && checkboxElem.checked);
+ torController.onionAuthAdd(onionAddr, base64key, isPermanent)
+ .then(aResponse => {
+ // Success! Reload the page.
+ this._browser.sendMessageToActor(
+ "Browser:Reload",
+ {},
+ "BrowserTab"
+ );
+ })
+ .catch(aError => {
+ if (aError.torMessage)
+ this.show(aError.torMessage);
+ else
+ this.show(controllerFailureMsg);
+ });
+ } catch (e) {
+ this.show(controllerFailureMsg);
+ }
+ },
+
+ _onCancel() {
+ // Arrange for an error page to be displayed.
+ this._browser.messageManager.sendAsyncMessage(
+ OnionAuthUtil.message.authPromptCanceled,
+ {failedURI: this._failedURI.spec,
+ reasonForPrompt: this._reasonForPrompt});
+ },
+
+ _getKeyElement() {
+ let xulDoc = this._browser.ownerDocument;
+ return xulDoc.getElementById(OnionAuthUtil.domid.keyElement);
+ },
+
+ _getCheckboxElement() {
+ let xulDoc = this._browser.ownerDocument;
+ return xulDoc.getElementById(OnionAuthUtil.domid.checkboxElement);
+ },
+
+ _showWarning(aWarningMessage) {
+ let xulDoc = this._browser.ownerDocument;
+ let warningElem =
+ xulDoc.getElementById(OnionAuthUtil.domid.warningElement);
+ let keyElem = this._getKeyElement();
+ if (warningElem) {
+ if (aWarningMessage) {
+ warningElem.textContent = aWarningMessage;
+ warningElem.removeAttribute("hidden");
+ if (keyElem)
+ keyElem.className = "invalid";
+ } else {
+ warningElem.setAttribute("hidden", "true");
+ if (keyElem)
+ keyElem.className = "";
+ }
+ }
+ },
+
+ // Returns undefined if the key is the wrong length or format.
+ _keyToBase64(aKeyString) {
+ if (!aKeyString)
+ return undefined;
+
+ let base64key;
+ if (aKeyString.length == 52) {
+ // The key is probably base32-encoded. Attempt to decode.
+ // Although base32 specifies uppercase letters, we accept lowercase
+ // as well because users may type in lowercase or copy a key out of
+ // a tor onion-auth file (which uses lowercase).
+ let rawKey;
+ try {
+ rawKey = CommonUtils.decodeBase32(aKeyString.toUpperCase());
+ } catch (e) {}
+
+ if (rawKey) try {
+ base64key = btoa(rawKey);
+ } catch (e) {}
+ } else if ((aKeyString.length == 44) &&
+ /^[a-zA-Z0-9+/]*=*$/.test(aKeyString)) {
+ // The key appears to be a correctly formatted base64 value. If not,
+ // tor will return an error when we try to add the key via the
+ // control port.
+ base64key = aKeyString;
+ }
+
+ return base64key;
+ },
+ };
+
+ let retval = {
+ init() {
+ Services.obs.addObserver(this, OnionAuthUtil.topic.clientAuthMissing);
+ Services.obs.addObserver(this, OnionAuthUtil.topic.clientAuthIncorrect);
+ },
+
+ uninit() {
+ Services.obs.removeObserver(this, OnionAuthUtil.topic.clientAuthMissing);
+ Services.obs.removeObserver(this, OnionAuthUtil.topic.clientAuthIncorrect);
+ },
+
+ // aSubject is the DOM Window or browser where the prompt should be shown.
+ // aData contains the .onion name.
+ observe(aSubject, aTopic, aData) {
+ if ((aTopic != OnionAuthUtil.topic.clientAuthMissing) &&
+ (aTopic != OnionAuthUtil.topic.clientAuthIncorrect)) {
+ return;
+ }
+
+ let browser;
+ if (aSubject instanceof Ci.nsIDOMWindow) {
+ let contentWindow = aSubject.QueryInterface(Ci.nsIDOMWindow);
+ browser = contentWindow.docShell.chromeEventHandler;
+ } else {
+ browser = aSubject.QueryInterface(Ci.nsIBrowser);
+ }
+
+ if (!gBrowser.browsers.some(aBrowser => aBrowser == browser)) {
+ return; // This window does not contain the subject browser; ignore.
+ }
+
+ let failedURI = browser.currentURI;
+ let authPrompt = new OnionServicesAuthPrompt(browser, failedURI,
+ aTopic, aData);
+ authPrompt.show(undefined);
+ }
+ };
+
+ return retval;
+})(); /* OnionAuthPrompt */
+
+
+Object.defineProperty(this, "OnionAuthPrompt", {
+ value: OnionAuthPrompt,
+ enumerable: true,
+ writable: false
+});
diff --git a/browser/components/onionservices/content/authUtil.jsm b/browser/components/onionservices/content/authUtil.jsm
new file mode 100644
index 000000000000..c9d83774da1f
--- /dev/null
+++ b/browser/components/onionservices/content/authUtil.jsm
@@ -0,0 +1,47 @@
+// Copyright (c) 2020, The Tor Project, Inc.
+
+"use strict";
+
+var EXPORTED_SYMBOLS = [
+ "OnionAuthUtil",
+];
+
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
+const OnionAuthUtil = {
+ topic: {
+ clientAuthMissing: "tor-onion-services-clientauth-missing",
+ clientAuthIncorrect: "tor-onion-services-clientauth-incorrect",
+ },
+ message: {
+ authPromptCanceled: "Tor:OnionServicesAuthPromptCanceled",
+ },
+ domid: {
+ anchor: "tor-clientauth-notification-icon",
+ notification: "tor-clientauth",
+ description: "tor-clientauth-notification-desc",
+ learnMore: "tor-clientauth-notification-learnmore",
+ onionNameSpan: "tor-clientauth-notification-onionname",
+ keyElement: "tor-clientauth-notification-key",
+ warningElement: "tor-clientauth-warning",
+ checkboxElement: "tor-clientauth-persistkey-checkbox",
+ },
+
+ addCancelMessageListener(aTabContent, aDocShell) {
+ aTabContent.addMessageListener(this.message.authPromptCanceled,
+ (aMessage) => {
+ // Upon cancellation of the client authentication prompt, display
+ // the appropriate error page. When calling the docShell
+ // displayLoadError() function, we pass undefined for the failed
+ // channel so that displayLoadError() can determine that it should
+ // not display the client authentication prompt a second time.
+ let failedURI = Services.io.newURI(aMessage.data.failedURI);
+ let reasonForPrompt = aMessage.data.reasonForPrompt;
+ let errorCode =
+ (reasonForPrompt === this.topic.clientAuthMissing) ?
+ Cr.NS_ERROR_TOR_ONION_SVC_MISSING_CLIENT_AUTH :
+ Cr.NS_ERROR_TOR_ONION_SVC_BAD_CLIENT_AUTH;
+ aDocShell.displayLoadError(errorCode, failedURI, undefined, undefined);
+ });
+ },
+};
diff --git a/browser/components/onionservices/content/netError/browser.svg b/browser/components/onionservices/content/netError/browser.svg
new file mode 100644
index 000000000000..1359679f7171
--- /dev/null
+++ b/browser/components/onionservices/content/netError/browser.svg
@@ -0,0 +1,3 @@
+<svg fill="none" height="60" viewBox="0 0 60 60" width="60" xmlns="http://www.w3.org/2000/svg">
+ <path fill="context-fill" fill-opacity="context-fill-opacity" d="m49 6h-37.5c-1.98912 0-3.89678.79018-5.3033 2.1967s-2.1967 3.3142-2.1967 5.3033v33.75c0 1.9891.79018 3.8968 2.1967 5.3033s3.31418 2.1967 5.3033 2.1967h37.5c1.9891 0 3.8968-.7902 5.3033-2.1967s2.1967-3.3142 2.1967-5.3033v-33.75c0-1.9891-.7902-3.89678-2.1967-5.3033s-3.3142-2.1967-5.3033-2.1967zm-38.0625 4.6875h38.625l2.25 2.25v8.0625h-43.125v-8.0625zm38.625 39.375h-38.625l-2.25-2.25v-22.125h43.125v22.125z"/>
+</svg>
diff --git a/browser/components/onionservices/content/netError/network.svg b/browser/components/onionservices/content/netError/network.svg
new file mode 100644
index 000000000000..68610e30bfca
--- /dev/null
+++ b/browser/components/onionservices/content/netError/network.svg
@@ -0,0 +1,3 @@
+<svg fill="none" height="60" viewBox="0 0 60 60" width="60" xmlns="http://www.w3.org/2000/svg">
+ <path fill="context-fill" fill-opacity="context-fill-opacity" d="m30 1.875c-7.4592 0-14.6129 2.96316-19.8874 8.2376-5.27444 5.2745-8.2376 12.4282-8.2376 19.8874s2.96316 14.6129 8.2376 19.8874c5.2745 5.2744 12.4282 8.2376 19.8874 8.2376s14.6129-2.9632 19.8874-8.2376c5.2744-5.2745 8.2376-12.4282 8.2376-19.8874s-2.9632-14.6129-8.2376-19.8874c-5.2745-5.27444-12.4282-8.2376-19.8874-8.2376zm9.1762 6.5625c3.8504 1.6533 7.1876 4.3079 9.6646 7.6877 2.477 3.3799 4.0034 7.3615 4.4205 11.531h-8.3588c-.4617-6.9829-2.9858-13.6716-7.2525-19.2187zm-7.6837 0c5.0739 5.1814 8.1562 11.9874 8.7037 19.2187h-20.3924c.5475-7.2313 3.6298-14.0373 8.7037-19.2187zm-10.6725 0h1.53c-4.2651 5.548-6.789 12.2362-7.2525 19.2187h-8.35875c.41632-4.1692 1.942-8.1508 4.41835-11.5306 2.4764-3.3799 5.813-6.0346 9.6629-7.6881zm0 43.125c-3.8504-1.6528-7.1874-4.3074-9.6639-7.6874-2.47642-3.38-4.0018-7.3619-4.41735-11.5313h8.35875c.4617 6.9829 2.9858 13.6716 7.2525 19.2187zm7.6875 0c-5.0739-5.1814-8.1562-11.9874-8.7037-19.2
187h20.3887c-.5475 7.2313-3.6298 14.0373-8.7037 19.2187zm10.6725 0h-1.5338c4.2683-5.5462 6.7926-12.2354 7.2525-19.2187h8.3588c-.4156 4.1689-1.9406 8.1504-4.4163 11.5302-2.4757 3.3799-5.8118 6.0348-9.6612 7.6885z"/>
+</svg>
diff --git a/browser/components/onionservices/content/netError/onionNetError.css b/browser/components/onionservices/content/netError/onionNetError.css
new file mode 100644
index 000000000000..2c92b187b71c
--- /dev/null
+++ b/browser/components/onionservices/content/netError/onionNetError.css
@@ -0,0 +1,88 @@
+/* Copyright (c) 2020, The Tor Project, Inc. */
+
+#onionErrorDiagramContainer {
+ margin: 0px auto 40px 0px;
+ /* 3 icons 64px wide each seperated by a 64px gap */
+ width: 384px;
+ display: grid;
+ grid-row-gap: 15px;
+ grid-column-gap: 64px;
+ grid-template-columns: 1fr 1fr 1fr;
+}
+
+#onionErrorDiagramContainer > div {
+ margin: auto;
+ position: relative; /* needed to allow overlay of the ok or error icon */
+}
+
+.onionErrorImage {
+ width: 64px;
+ height: 64px;
+ background-size: 64px 64px;
+ background-position: center;
+ background-repeat: no-repeat;
+ -moz-context-properties: fill;
+ fill: var(--in-content-icon-color);
+ opacity: 50%;
+}
+
+/* TODO: remove these --warning-color definitions after we
+ are esr92 based (tor-browser#40640 */
+.onionErrorImage {
+ --warning-color: #ffa436;
+}
+
+@media (-moz-toolbar-prefers-color-scheme: dark) {
+ .onionErrorImage {
+ --warning-color: #ffbd4f;
+ }
+}
+
+@media (prefers-contrast) {
+ .onionErrorImage {
+ --warning-color: var(--in-content-page-color);
+ }
+}
+
+.onionErrorImage[status] {
+ opacity: 100%;
+}
+
+#onionErrorBrowserImage {
+ background-image: url("browser.svg");
+}
+
+#onionErrorNetworkImage {
+ background-image: url("network.svg");
+}
+
+#onionErrorOnionSiteImage {
+ background-image: url("onionsite.svg");
+}
+
+/* rules to support overlay of the ok or error icon */
+.onionErrorImage[status]::after {
+ content: " ";
+ position: absolute;
+ left: -8px;
+ top: calc((64px - 24px) / 2);
+ width: 24px;
+ height: 24px;
+ -moz-context-properties: fill;
+ fill: var(--in-content-page-background);
+
+ background-repeat: no-repeat;
+ background-position: center;
+ border: 3px solid var(--in-content-page-background);
+ border-radius: 50%;
+}
+
+.onionErrorImage[status="ok"]::after {
+ background-color: var(--in-content-icon-color);
+ background-image: url("chrome://global/skin/icons/check.svg");
+}
+
+.onionErrorImage[status="error"]::after {
+ background-color: var(--warning-color);
+ background-image: url("chrome://global/skin/icons/close.svg");
+}
diff --git a/browser/components/onionservices/content/netError/onionNetError.js b/browser/components/onionservices/content/netError/onionNetError.js
new file mode 100644
index 000000000000..745c58ec6124
--- /dev/null
+++ b/browser/components/onionservices/content/netError/onionNetError.js
@@ -0,0 +1,243 @@
+// Copyright (c) 2020, The Tor Project, Inc.
+
+"use strict";
+
+/* eslint-env mozilla/frame-script */
+
+var OnionServicesAboutNetError = {
+ _selector: {
+ textContainer: "div#text-container",
+ header: ".title-text",
+ longDesc: "#errorLongDesc",
+ learnMoreContainer: "#learnMoreContainer",
+ learnMoreLink: "#learnMoreLink",
+ contentContainer: "#errorLongContent",
+ tryAgainButtonContainer: "#netErrorButtonContainer",
+ },
+ _status: {
+ ok: "ok",
+ error: "error",
+ },
+
+ _diagramInfoMap: undefined,
+
+ // Public functions (called from outside this file).
+ //
+ // This initPage() function may need to be updated if the structure of
+ // browser/base/content/aboutNetError.xhtml changes. Specifically, it
+ // references the following elements:
+ // query string parameter e
+ // class title-text
+ // id errorLongDesc
+ // id learnMoreContainer
+ // id learnMoreLink
+ // id errorLongContent
+ initPage(aDoc) {
+ const searchParams = new URLSearchParams(aDoc.documentURI.split("?")[1]);
+ const err = searchParams.get("e");
+
+ const errPrefix = "onionServices.";
+ const errName = err.substring(errPrefix.length);
+
+ this._strings = RPMGetTorStrings();
+
+ const stringsObj = this._strings[errName];
+ if (!stringsObj) {
+ return;
+ }
+
+ this._insertStylesheet(aDoc);
+
+ const pageTitle = stringsObj.pageTitle;
+ const header = stringsObj.header;
+ const longDescription = stringsObj.longDescription; // optional
+ const learnMoreURL = stringsObj.learnMoreURL;
+
+ if (pageTitle) {
+ aDoc.title = pageTitle;
+ }
+
+ if (header) {
+ const headerElem = aDoc.querySelector(this._selector.header);
+ if (headerElem) {
+ headerElem.textContent = header;
+ }
+ }
+
+ const ld = aDoc.querySelector(this._selector.longDesc);
+ if (ld) {
+ if (longDescription) {
+ const hexErr = this._hexErrorFromName(errName);
+ ld.textContent = longDescription.replace("%S", hexErr);
+ } else {
+ // This onion service error does not have a long description. Since
+ // it is set to a generic error string by the code in
+ // browser/base/content/aboutNetError.js, hide it here.
+ ld.style.display = "none";
+ }
+ }
+
+ if (learnMoreURL) {
+ const lmContainer = aDoc.querySelector(this._selector.learnMoreContainer);
+ if (lmContainer) {
+ lmContainer.style.display = "block";
+ }
+ const lmLink = lmContainer.querySelector(this._selector.learnMoreLink);
+ if (lmLink) {
+ lmLink.setAttribute("href", learnMoreURL);
+ }
+ }
+
+ // Remove the "Try Again" button if the user made a typo in the .onion
+ // address since it is not useful in that case.
+ if (errName === "badAddress") {
+ const tryAgainButton = aDoc.querySelector(
+ this._selector.tryAgainButtonContainer
+ );
+ if (tryAgainButton) {
+ tryAgainButton.style.display = "none";
+ }
+ }
+
+ this._insertDiagram(aDoc, errName);
+ }, // initPage()
+
+ _insertStylesheet(aDoc) {
+ const url =
+ "chrome://browser/content/onionservices/netError/onionNetError.css";
+ let linkElem = aDoc.createElement("link");
+ linkElem.rel = "stylesheet";
+ linkElem.href = url;
+ linkElem.type = "text/css";
+ aDoc.head.appendChild(linkElem);
+ },
+
+ _insertDiagram(aDoc, aErrorName) {
+ // The onion error diagram consists of a grid of div elements.
+ // The first row contains three images (Browser, Network, Onionsite) and
+ // the second row contains labels for the images that are in the first row.
+ // The _diagramInfoMap describes for each type of onion service error
+ // whether a small ok or error status icon is overlaid on top of the main
+ // Browser/Network/Onionsite images.
+ if (!this._diagramInfoMap) {
+ this._diagramInfoMap = new Map();
+ this._diagramInfoMap.set("descNotFound", {
+ browser: this._status.ok,
+ network: this._status.ok,
+ onionSite: this._status.error,
+ });
+ this._diagramInfoMap.set("descInvalid", {
+ browser: this._status.ok,
+ network: this._status.error,
+ });
+ this._diagramInfoMap.set("introFailed", {
+ browser: this._status.ok,
+ network: this._status.error,
+ });
+ this._diagramInfoMap.set("rendezvousFailed", {
+ browser: this._status.ok,
+ network: this._status.error,
+ });
+ this._diagramInfoMap.set("clientAuthMissing", {
+ browser: this._status.error,
+ });
+ this._diagramInfoMap.set("clientAuthIncorrect", {
+ browser: this._status.error,
+ });
+ this._diagramInfoMap.set("badAddress", {
+ browser: this._status.error,
+ });
+ this._diagramInfoMap.set("introTimedOut", {
+ browser: this._status.ok,
+ network: this._status.error,
+ });
+ }
+
+ const diagramInfo = this._diagramInfoMap.get(aErrorName);
+
+ const container = this._createDiv(aDoc, "onionErrorDiagramContainer");
+ const imageClass = "onionErrorImage";
+
+ const browserImage = this._createDiv(
+ aDoc,
+ "onionErrorBrowserImage",
+ imageClass,
+ container
+ );
+ if (diagramInfo && diagramInfo.browser) {
+ browserImage.setAttribute("status", diagramInfo.browser);
+ }
+
+ const networkImage = this._createDiv(
+ aDoc,
+ "onionErrorNetworkImage",
+ imageClass,
+ container
+ );
+ if (diagramInfo && diagramInfo.network) {
+ networkImage.setAttribute("status", diagramInfo.network);
+ }
+
+ const onionSiteImage = this._createDiv(
+ aDoc,
+ "onionErrorOnionSiteImage",
+ imageClass,
+ container
+ );
+ if (diagramInfo && diagramInfo.onionSite) {
+ onionSiteImage.setAttribute("status", diagramInfo.onionSite);
+ }
+
+ let labelDiv = this._createDiv(aDoc, undefined, undefined, container);
+ labelDiv.textContent = this._strings.errorPage.browser;
+ labelDiv = this._createDiv(aDoc, undefined, undefined, container);
+ labelDiv.textContent = this._strings.errorPage.network;
+ labelDiv = this._createDiv(aDoc, undefined, undefined, container);
+ labelDiv.textContent = this._strings.errorPage.onionSite;
+
+ const textContainer = aDoc.querySelector(
+ this._selector.textContainer
+ );
+ textContainer?.insertBefore(container, textContainer.firstChild);
+ }, // _insertDiagram()
+
+ _createDiv(aDoc, aID, aClass, aParentElem) {
+ const div = aDoc.createElement("div");
+ if (aID) {
+ div.id = aID;
+ }
+ if (aClass) {
+ div.setAttribute("class", aClass);
+ }
+ if (aParentElem) {
+ aParentElem.appendChild(div);
+ }
+
+ return div;
+ },
+
+ _hexErrorFromName(aErrorName) {
+ // We do not have access to the original Tor SOCKS error code here, so
+ // perform a reverse mapping from the error name.
+ switch (aErrorName) {
+ case "descNotFound":
+ return "0xF0";
+ case "descInvalid":
+ return "0xF1";
+ case "introFailed":
+ return "0xF2";
+ case "rendezvousFailed":
+ return "0xF3";
+ case "clientAuthMissing":
+ return "0xF4";
+ case "clientAuthIncorrect":
+ return "0xF5";
+ case "badAddress":
+ return "0xF6";
+ case "introTimedOut":
+ return "0xF7";
+ }
+
+ return "";
+ },
+};
diff --git a/browser/components/onionservices/content/netError/onionsite.svg b/browser/components/onionservices/content/netError/onionsite.svg
new file mode 100644
index 000000000000..c1b2d7382dc9
--- /dev/null
+++ b/browser/components/onionservices/content/netError/onionsite.svg
@@ -0,0 +1,8 @@
+<svg fill="none" height="60" viewBox="0 0 60 60" width="60" xmlns="http://www.w3.org/2000/svg">
+ <g fill="context-fill" fill-opacity="context-fill-opacity">
+ <path clip-rule="evenodd" d="m11.25 6h37.5c1.9891 0 3.8968.79018 5.3033 2.1967s2.1967 3.3142 2.1967 5.3033v33.75c0 1.9891-.7902 3.8968-2.1967 5.3033s-3.3142 2.1967-5.3033 2.1967h-37.5c-1.98912 0-3.89678-.7902-5.3033-2.1967s-2.1967-3.3142-2.1967-5.3033v-33.75c0-1.9891.79018-3.89678 2.1967-5.3033s3.31418-2.1967 5.3033-2.1967zm-.5625 4.6875h38.625l2.25 2.25v34.875l-2.25 2.25h-38.625l-2.25-2.25v-34.875z" fill-rule="evenodd"/>
+ <path d="m15.9606 22c-.52 0-1.0187-.2107-1.3863-.5858-.3677-.3751-.5743-.8838-.5743-1.4142s.2066-1.0391.5743-1.4142c.3676-.3751.8663-.5858 1.3863-.5858h14.0788c.52 0 1.0187.2107 1.3863.5858.3677.3751.5743.8838.5743 1.4142s-.2066 1.0391-.5743 1.4142c-.3676.3751-.8663.5858-1.3863.5858z"/>
+ <path d="m44.0709 32h-28.1418c-.5116 0-1.0023-.2107-1.3641-.5858s-.565-.8838-.565-1.4142.2032-1.0391.565-1.4142.8525-.5858 1.3641-.5858h28.1418c.5116 0 1.0023.2107 1.3641.5858s.565.8838.565 1.4142-.2032 1.0391-.565 1.4142-.8525.5858-1.3641.5858z"/>
+ <path d="m44.0709 42h-28.1418c-.5116 0-1.0023-.2107-1.3641-.5858s-.565-.8838-.565-1.4142.2032-1.0391.565-1.4142.8525-.5858 1.3641-.5858h28.1418c.5116 0 1.0023.2107 1.3641.5858s.565.8838.565 1.4142-.2032 1.0391-.565 1.4142-.8525.5858-1.3641.5858z"/>
+ </g>
+</svg>
diff --git a/browser/components/onionservices/content/onionservices.css b/browser/components/onionservices/content/onionservices.css
new file mode 100644
index 000000000000..e2621ec8266d
--- /dev/null
+++ b/browser/components/onionservices/content/onionservices.css
@@ -0,0 +1,69 @@
+/* Copyright (c) 2020, The Tor Project, Inc. */
+
+@namespace html url("http://www.w3.org/1999/xhtml");
+
+html|*#tor-clientauth-notification-onionname {
+ font-weight: bold;
+}
+
+html|*#tor-clientauth-notification-key {
+ box-sizing: border-box;
+ width: 100%;
+ margin-top: 15px;
+ padding: 6px;
+}
+
+/* Start of rules adapted from
+ * browser/components/newtab/css/activity-stream-mac.css (linux and windows
+ * use the same rules).
+ */
+html|*#tor-clientauth-notification-key.invalid {
+ border: 1px solid #D70022;
+ box-shadow: 0 0 0 1px #D70022, 0 0 0 4px rgba(215, 0, 34, 0.3);
+}
+
+html|*#tor-clientauth-warning {
+ display: inline-block;
+ animation: fade-up-tt 450ms;
+ background: #D70022;
+ border-radius: 2px;
+ color: #FFF;
+ inset-inline-start: 3px;
+ padding: 5px 12px;
+ position: relative;
+ top: 6px;
+ z-index: 1;
+}
+
+html|*#tor-clientauth-warning[hidden] {
+ display: none;
+}
+
+html|*#tor-clientauth-warning::before {
+ background: #D70022;
+ bottom: -8px;
+ content: '.';
+ height: 16px;
+ inset-inline-start: 12px;
+ position: absolute;
+ text-indent: -999px;
+ top: -7px;
+ transform: rotate(45deg);
+ white-space: nowrap;
+ width: 16px;
+ z-index: -1;
+}
+
+@keyframes fade-up-tt {
+ 0% {
+ opacity: 0;
+ transform: translateY(15px);
+ }
+ 100% {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+/* End of rules adapted from
+ * browser/components/newtab/css/activity-stream-mac.css
+ */
diff --git a/browser/components/onionservices/content/savedKeysDialog.js b/browser/components/onionservices/content/savedKeysDialog.js
new file mode 100644
index 000000000000..b1376bbabe85
--- /dev/null
+++ b/browser/components/onionservices/content/savedKeysDialog.js
@@ -0,0 +1,259 @@
+// Copyright (c) 2020, The Tor Project, Inc.
+
+"use strict";
+
+ChromeUtils.defineModuleGetter(
+ this,
+ "TorStrings",
+ "resource:///modules/TorStrings.jsm"
+);
+
+ChromeUtils.defineModuleGetter(
+ this,
+ "controller",
+ "resource://torbutton/modules/tor-control-port.js"
+);
+
+var gOnionServicesSavedKeysDialog = {
+ selector: {
+ dialog: "#onionservices-savedkeys-dialog",
+ intro: "#onionservices-savedkeys-intro",
+ tree: "#onionservices-savedkeys-tree",
+ onionSiteCol: "#onionservices-savedkeys-siteCol",
+ onionKeyCol: "#onionservices-savedkeys-keyCol",
+ errorIcon: "#onionservices-savedkeys-errorIcon",
+ errorMessage: "#onionservices-savedkeys-errorMessage",
+ removeButton: "#onionservices-savedkeys-remove",
+ removeAllButton: "#onionservices-savedkeys-removeall",
+ },
+
+ _tree: undefined,
+ _isBusy: false, // true when loading data, deleting a key, etc.
+
+ // Public functions (called from outside this file).
+ async deleteSelectedKeys() {
+ this._setBusyState(true);
+
+ const indexesToDelete = [];
+ const count = this._tree.view.selection.getRangeCount();
+ for (let i = 0; i < count; ++i) {
+ const minObj = {};
+ const maxObj = {};
+ this._tree.view.selection.getRangeAt(i, minObj, maxObj);
+ for (let idx = minObj.value; idx <= maxObj.value; ++idx) {
+ indexesToDelete.push(idx);
+ }
+ }
+
+ if (indexesToDelete.length > 0) {
+ const controllerFailureMsg =
+ TorStrings.onionServices.authPreferences.failedToRemoveKey;
+ try {
+ const torController = controller(aError => {
+ this._showError(controllerFailureMsg);
+ });
+
+ // Remove in reverse index order to avoid issues caused by index changes.
+ for (let i = indexesToDelete.length - 1; i >= 0; --i) {
+ await this._deleteOneKey(torController, indexesToDelete[i]);
+ }
+ } catch (e) {
+ if (e.torMessage) {
+ this._showError(e.torMessage);
+ } else {
+ this._showError(controllerFailureMsg);
+ }
+ }
+ }
+
+ this._setBusyState(false);
+ },
+
+ async deleteAllKeys() {
+ this._tree.view.selection.selectAll();
+ await this.deleteSelectedKeys();
+ },
+
+ updateButtonsState() {
+ const haveSelection = this._tree.view.selection.getRangeCount() > 0;
+ const dialog = document.querySelector(this.selector.dialog);
+ const removeSelectedBtn = dialog.querySelector(this.selector.removeButton);
+ removeSelectedBtn.disabled = this._isBusy || !haveSelection;
+ const removeAllBtn = dialog.querySelector(this.selector.removeAllButton);
+ removeAllBtn.disabled = this._isBusy || this.rowCount === 0;
+ },
+
+ // Private functions.
+ _onLoad() {
+ document.mozSubdialogReady = this._init();
+ },
+
+ async _init() {
+ await this._populateXUL();
+
+ window.addEventListener("keypress", this._onWindowKeyPress.bind(this));
+
+ // We don't use await here because we want _loadSavedKeys() to run
+ // in the background and not block loading of this dialog.
+ this._loadSavedKeys();
+ },
+
+ async _populateXUL() {
+ const dialog = document.querySelector(this.selector.dialog);
+ const authPrefStrings = TorStrings.onionServices.authPreferences;
+ dialog.setAttribute("title", authPrefStrings.dialogTitle);
+
+ let elem = dialog.querySelector(this.selector.intro);
+ elem.textContent = authPrefStrings.dialogIntro;
+
+ elem = dialog.querySelector(this.selector.onionSiteCol);
+ elem.setAttribute("label", authPrefStrings.onionSite);
+
+ elem = dialog.querySelector(this.selector.onionKeyCol);
+ elem.setAttribute("label", authPrefStrings.onionKey);
+
+ elem = dialog.querySelector(this.selector.removeButton);
+ elem.setAttribute("label", authPrefStrings.remove);
+
+ elem = dialog.querySelector(this.selector.removeAllButton);
+ elem.setAttribute("label", authPrefStrings.removeAll);
+
+ this._tree = dialog.querySelector(this.selector.tree);
+ },
+
+ async _loadSavedKeys() {
+ const controllerFailureMsg =
+ TorStrings.onionServices.authPreferences.failedToGetKeys;
+ this._setBusyState(true);
+
+ try {
+ this._tree.view = this;
+
+ const torController = controller(aError => {
+ this._showError(controllerFailureMsg);
+ });
+
+ const keyInfoList = await torController.onionAuthViewKeys();
+ if (keyInfoList) {
+ // Filter out temporary keys.
+ this._keyInfoList = keyInfoList.filter(aKeyInfo => {
+ if (!aKeyInfo.Flags) {
+ return false;
+ }
+
+ const flags = aKeyInfo.Flags.split(",");
+ return flags.includes("Permanent");
+ });
+
+ // Sort by the .onion address.
+ this._keyInfoList.sort((aObj1, aObj2) => {
+ const hsAddr1 = aObj1.hsAddress.toLowerCase();
+ const hsAddr2 = aObj2.hsAddress.toLowerCase();
+ if (hsAddr1 < hsAddr2) {
+ return -1;
+ }
+ return hsAddr1 > hsAddr2 ? 1 : 0;
+ });
+ }
+
+ // Render the tree content.
+ this._tree.rowCountChanged(0, this.rowCount);
+ } catch (e) {
+ if (e.torMessage) {
+ this._showError(e.torMessage);
+ } else {
+ this._showError(controllerFailureMsg);
+ }
+ }
+
+ this._setBusyState(false);
+ },
+
+ // This method may throw; callers should catch errors.
+ async _deleteOneKey(aTorController, aIndex) {
+ const keyInfoObj = this._keyInfoList[aIndex];
+ await aTorController.onionAuthRemove(keyInfoObj.hsAddress);
+ this._tree.view.selection.clearRange(aIndex, aIndex);
+ this._keyInfoList.splice(aIndex, 1);
+ this._tree.rowCountChanged(aIndex + 1, -1);
+ },
+
+ _setBusyState(aIsBusy) {
+ this._isBusy = aIsBusy;
+ this.updateButtonsState();
+ },
+
+ _onWindowKeyPress(event) {
+ if (event.keyCode === KeyEvent.DOM_VK_ESCAPE) {
+ window.close();
+ } else if (event.keyCode === KeyEvent.DOM_VK_DELETE) {
+ this.deleteSelectedKeys();
+ }
+ },
+
+ _showError(aMessage) {
+ const dialog = document.querySelector(this.selector.dialog);
+ const errorIcon = dialog.querySelector(this.selector.errorIcon);
+ errorIcon.style.visibility = aMessage ? "visible" : "hidden";
+ const errorDesc = dialog.querySelector(this.selector.errorMessage);
+ errorDesc.textContent = aMessage ? aMessage : "";
+ },
+
+ // XUL tree widget view implementation.
+ get rowCount() {
+ return this._keyInfoList ? this._keyInfoList.length : 0;
+ },
+
+ getCellText(aRow, aCol) {
+ let val = "";
+ if (this._keyInfoList && aRow < this._keyInfoList.length) {
+ const keyInfo = this._keyInfoList[aRow];
+ if (aCol.id.endsWith("-siteCol")) {
+ val = keyInfo.hsAddress;
+ } else if (aCol.id.endsWith("-keyCol")) {
+ val = keyInfo.typeAndKey;
+ // Omit keyType because it is always "x25519".
+ const idx = val.indexOf(":");
+ if (idx > 0) {
+ val = val.substring(idx + 1);
+ }
+ }
+ }
+
+ return val;
+ },
+
+ isSeparator(index) {
+ return false;
+ },
+
+ isSorted() {
+ return false;
+ },
+
+ isContainer(index) {
+ return false;
+ },
+
+ setTree(tree) {},
+
+ getImageSrc(row, column) {},
+
+ getCellValue(row, column) {},
+
+ cycleHeader(column) {},
+
+ getRowProperties(row) {
+ return "";
+ },
+
+ getColumnProperties(column) {
+ return "";
+ },
+
+ getCellProperties(row, column) {
+ return "";
+ },
+};
+
+window.addEventListener("load", () => gOnionServicesSavedKeysDialog._onLoad());
diff --git a/browser/components/onionservices/content/savedKeysDialog.xhtml b/browser/components/onionservices/content/savedKeysDialog.xhtml
new file mode 100644
index 000000000000..3db9bb05ea82
--- /dev/null
+++ b/browser/components/onionservices/content/savedKeysDialog.xhtml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!-- Copyright (c) 2020, The Tor Project, Inc. -->
+
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css" type="text/css"?>
+<?xml-stylesheet href="chrome://browser/content/onionservices/authPreferences.css" type="text/css"?>
+
+<window id="onionservices-savedkeys-dialog"
+ windowtype="OnionServices:SavedKeys"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ style="width: 45em;">
+
+ <script src="chrome://browser/content/onionservices/savedKeysDialog.js"/>
+
+ <vbox id="onionservices-savedkeys" class="contentPane" flex="1">
+ <label id="onionservices-savedkeys-intro"
+ control="onionservices-savedkeys-tree"/>
+ <separator class="thin"/>
+ <tree id="onionservices-savedkeys-tree" flex="1" hidecolumnpicker="true"
+ width="750"
+ style="height: 20em;"
+ onselect="gOnionServicesSavedKeysDialog.updateButtonsState();">
+ <treecols>
+ <treecol id="onionservices-savedkeys-siteCol" flex="1" persist="width"/>
+ <splitter class="tree-splitter"/>
+ <treecol id="onionservices-savedkeys-keyCol" flex="1" persist="width"/>
+ </treecols>
+ <treechildren/>
+ </tree>
+ <hbox id="onionservices-savedkeys-errorContainer" align="baseline" flex="1">
+ <image id="onionservices-savedkeys-errorIcon"/>
+ <description id="onionservices-savedkeys-errorMessage" flex="1"/>
+ </hbox>
+ <separator class="thin"/>
+ <hbox id="onionservices-savedkeys-buttons">
+ <button id="onionservices-savedkeys-remove" disabled="true"
+ oncommand="gOnionServicesSavedKeysDialog.deleteSelectedKeys();"/>
+ <button id="onionservices-savedkeys-removeall"
+ oncommand="gOnionServicesSavedKeysDialog.deleteAllKeys();"/>
+ </hbox>
+ </vbox>
+</window>
diff --git a/browser/components/onionservices/jar.mn b/browser/components/onionservices/jar.mn
new file mode 100644
index 000000000000..9d6ce88d1841
--- /dev/null
+++ b/browser/components/onionservices/jar.mn
@@ -0,0 +1,9 @@
+browser.jar:
+ content/browser/onionservices/authPreferences.css (content/authPreferences.css)
+ content/browser/onionservices/authPreferences.js (content/authPreferences.js)
+ content/browser/onionservices/authPrompt.js (content/authPrompt.js)
+ content/browser/onionservices/authUtil.jsm (content/authUtil.jsm)
+ content/browser/onionservices/netError/ (content/netError/*)
+ content/browser/onionservices/onionservices.css (content/onionservices.css)
+ content/browser/onionservices/savedKeysDialog.js (content/savedKeysDialog.js)
+ content/browser/onionservices/savedKeysDialog.xhtml (content/savedKeysDialog.xhtml)
diff --git a/browser/components/onionservices/moz.build b/browser/components/onionservices/moz.build
new file mode 100644
index 000000000000..2661ad7cb9f3
--- /dev/null
+++ b/browser/components/onionservices/moz.build
@@ -0,0 +1 @@
+JAR_MANIFESTS += ["jar.mn"]
diff --git a/browser/components/preferences/preferences.xhtml b/browser/components/preferences/preferences.xhtml
index 0139abf95cbd..07ab5cc7b626 100644
--- a/browser/components/preferences/preferences.xhtml
+++ b/browser/components/preferences/preferences.xhtml
@@ -12,6 +12,7 @@
<?xml-stylesheet href="chrome://browser/skin/preferences/search.css"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/containers.css"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/privacy.css"?>
+<?xml-stylesheet href="chrome://browser/content/onionservices/authPreferences.css"?>
<?xml-stylesheet href="chrome://browser/content/securitylevel/securityLevelPreferences.css"?>
<?xml-stylesheet href="chrome://browser/content/torpreferences/torPreferences.css"?>
diff --git a/browser/components/preferences/privacy.inc.xhtml b/browser/components/preferences/privacy.inc.xhtml
index d2cf2ea9c89c..18d01fee6b33 100644
--- a/browser/components/preferences/privacy.inc.xhtml
+++ b/browser/components/preferences/privacy.inc.xhtml
@@ -505,6 +505,8 @@
<label id="fips-desc" hidden="true" data-l10n-id="forms-master-pw-fips-desc"></label>
</groupbox>
+#include ../onionservices/content/authPreferences.inc.xhtml
+
<!-- The form autofill section is inserted in to this box
after the form autofill extension has initialized. -->
<groupbox id="formAutofillGroupBox"
diff --git a/browser/components/preferences/privacy.js b/browser/components/preferences/privacy.js
index bce7bb7e8a9c..932d4291e486 100644
--- a/browser/components/preferences/privacy.js
+++ b/browser/components/preferences/privacy.js
@@ -80,6 +80,12 @@ XPCOMUtils.defineLazyGetter(this, "AlertsServiceDND", function() {
}
});
+XPCOMUtils.defineLazyScriptGetter(
+ this,
+ ["OnionServicesAuthPreferences"],
+ "chrome://browser/content/onionservices/authPreferences.js"
+);
+
// TODO: module import via ChromeUtils.defineModuleGetter
XPCOMUtils.defineLazyScriptGetter(
this,
@@ -522,6 +528,7 @@ var gPrivacyPane = {
this.trackingProtectionReadPrefs();
this.networkCookieBehaviorReadPrefs();
this._initTrackingProtectionExtensionControl();
+ OnionServicesAuthPreferences.init();
this._initSecurityLevel();
Services.telemetry.setEventRecordingEnabled("pwmgr", true);
diff --git a/browser/themes/shared/notification-icons.inc.css b/browser/themes/shared/notification-icons.inc.css
index 658fa7f7430a..67dd640baf16 100644
--- a/browser/themes/shared/notification-icons.inc.css
+++ b/browser/themes/shared/notification-icons.inc.css
@@ -137,6 +137,9 @@
list-style-image: url(chrome://browser/skin/notification-icons/persistent-storage.svg);
}
+/* Reuse Firefox's login (key) icon for the Tor onion services auth. prompt */
+.popup-notification-icon[popupid="tor-clientauth"],
+.tor-clientauth-icon,
.popup-notification-icon[popupid="password"],
.login-icon {
list-style-image: url(chrome://browser/skin/login.svg);
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
index 2a792c314d4c..11583bec32a5 100644
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -3587,6 +3587,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
}
} else {
// Errors requiring simple formatting
+ bool isOnionAuthError = false;
switch (aError) {
case NS_ERROR_MALFORMED_URI:
// URI is malformed
@@ -3669,10 +3670,44 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
// HTTP/2 or HTTP/3 stack detected a protocol error
error = "networkProtocolError";
break;
-
+ case NS_ERROR_TOR_ONION_SVC_NOT_FOUND:
+ error = "onionServices.descNotFound";
+ break;
+ case NS_ERROR_TOR_ONION_SVC_IS_INVALID:
+ error = "onionServices.descInvalid";
+ break;
+ case NS_ERROR_TOR_ONION_SVC_INTRO_FAILED:
+ error = "onionServices.introFailed";
+ break;
+ case NS_ERROR_TOR_ONION_SVC_REND_FAILED:
+ error = "onionServices.rendezvousFailed";
+ break;
+ case NS_ERROR_TOR_ONION_SVC_MISSING_CLIENT_AUTH:
+ error = "onionServices.clientAuthMissing";
+ isOnionAuthError = true;
+ break;
+ case NS_ERROR_TOR_ONION_SVC_BAD_CLIENT_AUTH:
+ error = "onionServices.clientAuthIncorrect";
+ isOnionAuthError = true;
+ break;
+ case NS_ERROR_TOR_ONION_SVC_BAD_ADDRESS:
+ error = "onionServices.badAddress";
+ break;
+ case NS_ERROR_TOR_ONION_SVC_INTRO_TIMEDOUT:
+ error = "onionServices.introTimedOut";
+ break;
default:
break;
}
+
+ // The presence of aFailedChannel indicates that we arrived here due to a
+ // failed connection attempt. Note that we will arrive here a second time
+ // if the user cancels the Tor client auth prompt, but in that case we
+ // will not have a failed channel and therefore we will not prompt again.
+ if (isOnionAuthError && aFailedChannel) {
+ // Display about:blank while the Tor client auth prompt is open.
+ errorPage.AssignLiteral("blank");
+ }
}
// If the HTTPS-Only Mode upgraded this request and the upgrade might have
@@ -3755,6 +3790,20 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
nsAutoString str;
rv =
stringBundle->FormatStringFromName(errorDescriptionID, formatStrs, str);
+ if (NS_FAILED(rv)) {
+ // As a fallback, check torbutton.properties for the error string.
+ const char bundleURL[] = "chrome://torbutton/locale/torbutton.properties";
+ nsCOMPtr<nsIStringBundleService> stringBundleService =
+ mozilla::services::GetStringBundleService();
+ if (stringBundleService) {
+ nsCOMPtr<nsIStringBundle> tbStringBundle;
+ if (NS_SUCCEEDED(stringBundleService->CreateBundle(
+ bundleURL, getter_AddRefs(tbStringBundle)))) {
+ rv = tbStringBundle->FormatStringFromName(errorDescriptionID,
+ formatStrs, str);
+ }
+ }
+ }
NS_ENSURE_SUCCESS(rv, rv);
messageStr.Assign(str);
}
@@ -6173,6 +6222,7 @@ nsresult nsDocShell::FilterStatusForErrorPage(
aStatus == NS_ERROR_FILE_ACCESS_DENIED ||
aStatus == NS_ERROR_CORRUPTED_CONTENT ||
aStatus == NS_ERROR_INVALID_CONTENT_ENCODING ||
+ NS_ERROR_GET_MODULE(aStatus) == NS_ERROR_MODULE_TOR ||
NS_ERROR_GET_MODULE(aStatus) == NS_ERROR_MODULE_SECURITY) {
// Errors to be shown for any frame
return aStatus;
@@ -7956,6 +8006,35 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType,
FireOnLocationChange(this, aRequest, mCurrentURI, locationFlags);
}
+ // Arrange to show a Tor onion service client authentication prompt if
+ // appropriate.
+ if ((mLoadType == LOAD_ERROR_PAGE) && failedChannel) {
+ nsresult status = NS_OK;
+ if (NS_SUCCEEDED(failedChannel->GetStatus(&status)) &&
+ ((status == NS_ERROR_TOR_ONION_SVC_MISSING_CLIENT_AUTH) ||
+ (status == NS_ERROR_TOR_ONION_SVC_BAD_CLIENT_AUTH))) {
+ nsAutoCString onionHost;
+ failedURI->GetHost(onionHost);
+ const char* topic = (status == NS_ERROR_TOR_ONION_SVC_MISSING_CLIENT_AUTH)
+ ? "tor-onion-services-clientauth-missing"
+ : "tor-onion-services-clientauth-incorrect";
+ if (XRE_IsContentProcess()) {
+ nsCOMPtr<nsIBrowserChild> browserChild = GetBrowserChild();
+ if (browserChild) {
+ static_cast<BrowserChild*>(browserChild.get())
+ ->SendShowOnionServicesAuthPrompt(onionHost, nsCString(topic));
+ }
+ } else {
+ nsCOMPtr<nsPIDOMWindowOuter> browserWin = GetWindow();
+ nsCOMPtr<nsIObserverService> obsSvc = services::GetObserverService();
+ if (browserWin && obsSvc) {
+ obsSvc->NotifyObservers(browserWin, topic,
+ NS_ConvertUTF8toUTF16(onionHost).get());
+ }
+ }
+ }
+ }
+
return NS_OK;
}
diff --git a/dom/ipc/BrowserParent.cpp b/dom/ipc/BrowserParent.cpp
index 05d77937f986..4145111ae849 100644
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -3810,6 +3810,27 @@ mozilla::ipc::IPCResult BrowserParent::RecvShowCanvasPermissionPrompt(
return IPC_OK();
}
+mozilla::ipc::IPCResult BrowserParent::RecvShowOnionServicesAuthPrompt(
+ const nsCString& aOnionName, const nsCString& aTopic) {
+ nsCOMPtr<nsIBrowser> browser =
+ mFrameElement ? mFrameElement->AsBrowser() : nullptr;
+ if (!browser) {
+ // If the tab is being closed, the browser may not be available.
+ // In this case we can ignore the request.
+ return IPC_OK();
+ }
+ nsCOMPtr<nsIObserverService> os = services::GetObserverService();
+ if (!os) {
+ return IPC_FAIL_NO_REASON(this);
+ }
+ nsresult rv = os->NotifyObservers(browser, aTopic.get(),
+ NS_ConvertUTF8toUTF16(aOnionName).get());
+ if (NS_FAILED(rv)) {
+ return IPC_FAIL_NO_REASON(this);
+ }
+ return IPC_OK();
+}
+
mozilla::ipc::IPCResult BrowserParent::RecvVisitURI(nsIURI* aURI,
nsIURI* aLastVisitedURI,
const uint32_t& aFlags) {
diff --git a/dom/ipc/BrowserParent.h b/dom/ipc/BrowserParent.h
index 80e4d055e26c..a36ebfc8ca05 100644
--- a/dom/ipc/BrowserParent.h
+++ b/dom/ipc/BrowserParent.h
@@ -736,6 +736,9 @@ class BrowserParent final : public PBrowserParent,
mozilla::ipc::IPCResult RecvShowCanvasPermissionPrompt(
const nsCString& aOrigin, const bool& aHideDoorHanger);
+ mozilla::ipc::IPCResult RecvShowOnionServicesAuthPrompt(
+ const nsCString& aOnionName, const nsCString& aTopic);
+
mozilla::ipc::IPCResult RecvSetSystemFont(const nsCString& aFontName);
mozilla::ipc::IPCResult RecvGetSystemFont(nsCString* aFontName);
diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl
index 9750219fa46a..5706c7f5da00 100644
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -577,6 +577,15 @@ parent:
async RequestPointerCapture(uint32_t aPointerId) returns (bool aSuccess);
async ReleasePointerCapture(uint32_t aPointerId);
+ /**
+ * This function is used to notify the parent that it should display a
+ * onion services client authentication prompt.
+ *
+ * @param aOnionHost The hostname of the .onion that needs authentication.
+ * @param aTopic The reason for the prompt.
+ */
+ async ShowOnionServicesAuthPrompt(nsCString aOnionHost, nsCString aTopic);
+
child:
async NativeSynthesisResponse(uint64_t aObserverId, nsCString aResponse);
async UpdateEpoch(uint32_t aEpoch);
diff --git a/js/xpconnect/src/xpc.msg b/js/xpconnect/src/xpc.msg
index c7fbdd23f378..07f529957bd0 100644
--- a/js/xpconnect/src/xpc.msg
+++ b/js/xpconnect/src/xpc.msg
@@ -248,5 +248,15 @@ XPC_MSG_DEF(NS_ERROR_FINGERPRINTING_URI , "The URI is fingerprinti
XPC_MSG_DEF(NS_ERROR_CRYPTOMINING_URI , "The URI is cryptomining")
XPC_MSG_DEF(NS_ERROR_SOCIALTRACKING_URI , "The URI is social tracking")
+/* Codes related to Tor */
+XPC_MSG_DEF(NS_ERROR_TOR_ONION_SVC_NOT_FOUND , "Tor onion service descriptor cannot be found")
+XPC_MSG_DEF(NS_ERROR_TOR_ONION_SVC_IS_INVALID , "Tor onion service descriptor is invalid")
+XPC_MSG_DEF(NS_ERROR_TOR_ONION_SVC_INTRO_FAILED , "Tor onion service introduction failed")
+XPC_MSG_DEF(NS_ERROR_TOR_ONION_SVC_REND_FAILED , "Tor onion service rendezvous failed")
+XPC_MSG_DEF(NS_ERROR_TOR_ONION_SVC_MISSING_CLIENT_AUTH, "Tor onion service missing client authorization")
+XPC_MSG_DEF(NS_ERROR_TOR_ONION_SVC_BAD_CLIENT_AUTH , "Tor onion service wrong client authorization")
+XPC_MSG_DEF(NS_ERROR_TOR_ONION_SVC_BAD_ADDRESS , "Tor onion service bad address")
+XPC_MSG_DEF(NS_ERROR_TOR_ONION_SVC_INTRO_TIMEDOUT , "Tor onion service introduction timed out")
+
/* Profile manager error codes */
XPC_MSG_DEF(NS_ERROR_DATABASE_CHANGED , "Flushing the profiles to disk would have overwritten changes made elsewhere.")
diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp
index 8f44441e1fd0..99a6f3b60ac3 100644
--- a/netwerk/base/nsSocketTransport2.cpp
+++ b/netwerk/base/nsSocketTransport2.cpp
@@ -216,6 +216,12 @@ nsresult ErrorAccordingToNSPR(PRErrorCode errorCode) {
default:
if (psm::IsNSSErrorCode(errorCode)) {
rv = psm::GetXPCOMFromNSSError(errorCode);
+ } else {
+ // If we received a Tor extended error code via SOCKS, pass it through.
+ nsresult res = nsresult(errorCode);
+ if (NS_ERROR_GET_MODULE(res) == NS_ERROR_MODULE_TOR) {
+ rv = res;
+ }
}
break;
diff --git a/netwerk/socket/nsSOCKSIOLayer.cpp b/netwerk/socket/nsSOCKSIOLayer.cpp
index 119a3cbf4c51..f9fc29552ace 100644
--- a/netwerk/socket/nsSOCKSIOLayer.cpp
+++ b/netwerk/socket/nsSOCKSIOLayer.cpp
@@ -979,6 +979,55 @@ PRStatus nsSOCKSSocketInfo::ReadV5ConnectResponseTop() {
"08, Address type not supported."));
c = PR_BAD_ADDRESS_ERROR;
break;
+ case 0xF0: // Tor SOCKS5_HS_NOT_FOUND
+ LOGERROR(
+ ("socks5: connect failed: F0,"
+ " Tor onion service descriptor can not be found."));
+ c = static_cast<uint32_t>(NS_ERROR_TOR_ONION_SVC_NOT_FOUND);
+ break;
+ case 0xF1: // Tor SOCKS5_HS_IS_INVALID
+ LOGERROR(
+ ("socks5: connect failed: F1,"
+ " Tor onion service descriptor is invalid."));
+ c = static_cast<uint32_t>(NS_ERROR_TOR_ONION_SVC_IS_INVALID);
+ break;
+ case 0xF2: // Tor SOCKS5_HS_INTRO_FAILED
+ LOGERROR(
+ ("socks5: connect failed: F2,"
+ " Tor onion service introduction failed."));
+ c = static_cast<uint32_t>(NS_ERROR_TOR_ONION_SVC_INTRO_FAILED);
+ break;
+ case 0xF3: // Tor SOCKS5_HS_REND_FAILED
+ LOGERROR(
+ ("socks5: connect failed: F3,"
+ " Tor onion service rendezvous failed."));
+ c = static_cast<uint32_t>(NS_ERROR_TOR_ONION_SVC_REND_FAILED);
+ break;
+ case 0xF4: // Tor SOCKS5_HS_MISSING_CLIENT_AUTH
+ LOGERROR(
+ ("socks5: connect failed: F4,"
+ " Tor onion service missing client authorization."));
+ c = static_cast<uint32_t>(NS_ERROR_TOR_ONION_SVC_MISSING_CLIENT_AUTH);
+ break;
+ case 0xF5: // Tor SOCKS5_HS_BAD_CLIENT_AUTH
+ LOGERROR(
+ ("socks5: connect failed: F5,"
+ " Tor onion service wrong client authorization."));
+ c = static_cast<uint32_t>(NS_ERROR_TOR_ONION_SVC_BAD_CLIENT_AUTH);
+ break;
+ case 0xF6: // Tor SOCKS5_HS_BAD_ADDRESS
+ LOGERROR(
+ ("socks5: connect failed: F6,"
+ " Tor onion service bad address."));
+ c = static_cast<uint32_t>(NS_ERROR_TOR_ONION_SVC_BAD_ADDRESS);
+ break;
+ case 0xF7: // Tor SOCKS5_HS_INTRO_TIMEDOUT
+ LOGERROR(
+ ("socks5: connect failed: F7,"
+ " Tor onion service introduction timed out."));
+ c = static_cast<uint32_t>(NS_ERROR_TOR_ONION_SVC_INTRO_TIMEDOUT);
+ break;
+
default:
LOGERROR(("socks5: connect failed."));
break;
diff --git a/toolkit/modules/PopupNotifications.jsm b/toolkit/modules/PopupNotifications.jsm
index d6518723afab..9764cfd496c3 100644
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -410,6 +410,8 @@ PopupNotifications.prototype = {
* will be dismissed instead of removed after running the callback.
* - [optional] disabled (boolean): If this is true, the button
* will be disabled.
+ * - [optional] leaveOpen (boolean): If this is true, the notification
+ * will not be removed after running the callback.
* - [optional] disableHighlight (boolean): If this is true, the button
* will not apply the default highlight style.
* If null, the notification will have a default "OK" action button
@@ -1916,6 +1918,10 @@ PopupNotifications.prototype = {
this._dismiss();
return;
}
+
+ if (action.leaveOpen) {
+ return;
+ }
}
this._remove(notification);
diff --git a/toolkit/modules/RemotePageAccessManager.jsm b/toolkit/modules/RemotePageAccessManager.jsm
index 9a762dc19d76..5125203866b8 100644
--- a/toolkit/modules/RemotePageAccessManager.jsm
+++ b/toolkit/modules/RemotePageAccessManager.jsm
@@ -102,6 +102,7 @@ let RemotePageAccessManager = {
RPMAddToHistogram: ["*"],
RPMGetInnerMostURI: ["*"],
RPMGetHttpResponseHeader: ["*"],
+ RPMGetTorStrings: ["*"],
RPMSendQuery: ["ShouldShowTorConnect"],
},
"about:plugins": {
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js
index 15c15615ad97..57458ba0bf5e 100644
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js
@@ -41,5 +41,6 @@ module.exports = {
RPMGetHttpResponseHeader: false,
RPMTryPingSecureWWWLink: false,
RPMOpenSecureWWWLink: false,
+ RPMGetTorStrings: false,
},
};
diff --git a/xpcom/base/ErrorList.py b/xpcom/base/ErrorList.py
index c22c27be8546..8fbcc7f663df 100755
--- a/xpcom/base/ErrorList.py
+++ b/xpcom/base/ErrorList.py
@@ -89,6 +89,7 @@ modules["ERRORRESULT"] = Mod(43)
# Win32 system error codes, which are not mapped to a specific other value,
# see Bug 1686041.
modules["WIN32"] = Mod(44)
+modules["TOR"] = Mod(45)
# NS_ERROR_MODULE_GENERAL should be used by modules that do not
# care if return code values overlap. Callers of methods that
@@ -1181,6 +1182,27 @@ with modules["ERRORRESULT"]:
errors["NS_ERROR_INTERNAL_ERRORRESULT_RANGEERROR"] = FAILURE(5)
+# =======================================================================
+# 45: Tor-specific error codes.
+# =======================================================================
+with modules["TOR"]:
+ # Tor onion service descriptor can not be found.
+ errors["NS_ERROR_TOR_ONION_SVC_NOT_FOUND"] = FAILURE(1)
+ # Tor onion service descriptor is invalid.
+ errors["NS_ERROR_TOR_ONION_SVC_IS_INVALID"] = FAILURE(2)
+ # Tor onion service introduction failed.
+ errors["NS_ERROR_TOR_ONION_SVC_INTRO_FAILED"] = FAILURE(3)
+ # Tor onion service rendezvous failed.
+ errors["NS_ERROR_TOR_ONION_SVC_REND_FAILED"] = FAILURE(4)
+ # Tor onion service missing client authorization.
+ errors["NS_ERROR_TOR_ONION_SVC_MISSING_CLIENT_AUTH"] = FAILURE(5)
+ # Tor onion service wrong client authorization.
+ errors["NS_ERROR_TOR_ONION_SVC_BAD_CLIENT_AUTH"] = FAILURE(6)
+ # Tor onion service bad address.
+ errors["NS_ERROR_TOR_ONION_SVC_BAD_ADDRESS"] = FAILURE(7)
+ # Tor onion service introduction timed out.
+ errors["NS_ERROR_TOR_ONION_SVC_INTRO_TIMEDOUT"] = FAILURE(8)
+
# =======================================================================
# 51: NS_ERROR_MODULE_GENERAL
# =======================================================================
1
0

[tor-browser/tor-browser-91.5.0esr-11.5-2] Bug 40253: Explicitly allow NoScript in Private Browsing mode.
by richard@torproject.org 01 Feb '22
by richard@torproject.org 01 Feb '22
01 Feb '22
commit 3af2a833492fee98ff88a81e9884bebadffa11cf
Author: Matthew Finkel <sysrqb(a)torproject.org>
Date: Fri Sep 3 14:58:28 2021 +0000
Bug 40253: Explicitly allow NoScript in Private Browsing mode.
---
toolkit/components/extensions/Extension.jsm | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/toolkit/components/extensions/Extension.jsm b/toolkit/components/extensions/Extension.jsm
index 783ec7c3391d..1d72f88b276d 100644
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -2644,6 +2644,15 @@ class Extension extends ExtensionData {
this.permissions.add(PRIVATE_ALLOWED_PERMISSION);
}
+ // Bug 40253: Explicitly allow NoScript in Private Browsing mode.
+ if (this.id === "{73a6fe31-595d-460b-a920-fcc0f8843232}") {
+ ExtensionPermissions.add(this.id, {
+ permissions: [PRIVATE_ALLOWED_PERMISSION],
+ origins: [],
+ });
+ this.permissions.add(PRIVATE_ALLOWED_PERMISSION);
+ }
+
// We only want to update the SVG_CONTEXT_PROPERTIES_PERMISSION during install and
// upgrade/downgrade startups.
if (INSTALL_AND_UPDATE_STARTUP_REASONS.has(this.startupReason)) {
1
0

[tor-browser/tor-browser-91.5.0esr-11.5-2] Bug 40597: Implement TorSettings module
by richard@torproject.org 01 Feb '22
by richard@torproject.org 01 Feb '22
01 Feb '22
commit 59704b9eda625349d7bc85e68d5e118a48d0a7f5
Author: Richard Pospesel <richard(a)torproject.org>
Date: Fri Aug 6 16:39:03 2021 +0200
Bug 40597: Implement TorSettings module
- migrated in-page settings read/write implementation from about:preferences#tor
to the TorSettings module
- TorSettings initially loads settings from the tor daemon, and saves them to
firefox prefs
- TorSettings notifies observers when a setting has changed; currently only
QuickStart notification is implemented for parity with previous preference
notify logic in about:torconnect and about:preferences#tor
- about:preferences#tor, and about:torconnect now read and write settings
thorugh the TorSettings module
- all tor settings live in the torbrowser.settings.* preference branch
- removed unused pref modify permission for about:torconnect content page from
AsyncPrefs.jsm
Bug 40645: Migrate Moat APIs to Moat.jsm module
---
browser/modules/BridgeDB.jsm | 61 ++
browser/modules/Moat.jsm | 730 +++++++++++++++++++++
browser/modules/TorConnect.jsm | 643 ++++++++++++++++++
browser/modules/TorProtocolService.jsm | 484 ++++++++++++++
browser/modules/TorSettings.jsm | 693 +++++++++++++++++++
browser/modules/moz.build | 4 +
.../processsingleton/MainProcessSingleton.jsm | 5 +
7 files changed, 2620 insertions(+)
diff --git a/browser/modules/BridgeDB.jsm b/browser/modules/BridgeDB.jsm
new file mode 100644
index 000000000000..50665710ebf4
--- /dev/null
+++ b/browser/modules/BridgeDB.jsm
@@ -0,0 +1,61 @@
+"use strict";
+
+var EXPORTED_SYMBOLS = ["BridgeDB"];
+
+const { MoatRPC } = ChromeUtils.import("resource:///modules/Moat.jsm");
+
+var BridgeDB = {
+ _moatRPC: null,
+ _challenge: null,
+ _image: null,
+ _bridges: null,
+
+ get currentCaptchaImage() {
+ return this._image;
+ },
+
+ get currentBridges() {
+ return this._bridges;
+ },
+
+ async submitCaptchaGuess(solution) {
+ if (!this._moatRPC) {
+ this._moatRPC = new MoatRPC();
+ await this._moatRPC.init();
+ }
+
+ const response = await this._moatRPC.check(
+ "obfs4",
+ this._challenge,
+ solution,
+ false
+ );
+ this._bridges = response?.bridges;
+ return this._bridges;
+ },
+
+ async requestNewCaptchaImage() {
+ try {
+ if (!this._moatRPC) {
+ this._moatRPC = new MoatRPC();
+ await this._moatRPC.init();
+ }
+
+ const response = await this._moatRPC.fetch(["obfs4"]);
+ this._challenge = response.challenge;
+ this._image =
+ "data:image/jpeg;base64," + encodeURIComponent(response.image);
+ } catch (err) {
+ console.log(`error : ${err}`);
+ }
+ return this._image;
+ },
+
+ close() {
+ this._moatRPC?.uninit();
+ this._moatRPC = null;
+ this._challenge = null;
+ this._image = null;
+ this._bridges = null;
+ },
+};
diff --git a/browser/modules/Moat.jsm b/browser/modules/Moat.jsm
new file mode 100644
index 000000000000..d02075e4412f
--- /dev/null
+++ b/browser/modules/Moat.jsm
@@ -0,0 +1,730 @@
+"use strict";
+
+var EXPORTED_SYMBOLS = ["MoatRPC"];
+
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
+const { Subprocess } = ChromeUtils.import(
+ "resource://gre/modules/Subprocess.jsm"
+);
+
+const { TorLauncherUtil } = ChromeUtils.import(
+ "resource://torlauncher/modules/tl-util.jsm"
+);
+
+const { TorProtocolService } = ChromeUtils.import(
+ "resource:///modules/TorProtocolService.jsm"
+);
+
+const { TorSettings, TorBridgeSource, TorProxyType } = ChromeUtils.import(
+ "resource:///modules/TorSettings.jsm"
+);
+
+const TorLauncherPrefs = Object.freeze({
+ bridgedb_front: "extensions.torlauncher.bridgedb_front",
+ bridgedb_reflector: "extensions.torlauncher.bridgedb_reflector",
+ moat_service: "extensions.torlauncher.moat_service",
+});
+
+// Config keys used to query tor daemon properties
+const TorConfigKeys = Object.freeze({
+ clientTransportPlugin: "ClientTransportPlugin",
+});
+
+//
+// Launches and controls the PT process lifetime
+//
+class MeekTransport {
+ constructor() {
+ this._inited = false;
+ this._meekClientProcess = null;
+ this._meekProxyType = null;
+ this._meekProxyAddress = null;
+ this._meekProxyPort = 0;
+ this._meekProxyUsername = null;
+ this._meekProxyPassword = null;
+ }
+
+ // launches the meekprocess
+ async init() {
+ // ensure we haven't already init'd
+ if (this._inited) {
+ throw new Error("MeekTransport: Already initialized");
+ }
+
+ // cleanup function for killing orphaned pt process
+ let onException = () => {};
+ try {
+ // figure out which pluggable transport to use
+ const supportedTransports = ["meek", "meek_lite"];
+ let transportPlugins = await TorProtocolService.readStringArraySetting(
+ TorConfigKeys.clientTransportPlugin
+ );
+
+ let { meekTransport, meekClientPath, meekClientArgs } = (() => {
+ for (const line of transportPlugins) {
+ let tokens = line.split(" ");
+ if (tokens.length > 2 && tokens[1] == "exec") {
+ let transportArray = tokens[0].split(",").map(aStr => aStr.trim());
+ let transport = transportArray.find(aTransport =>
+ supportedTransports.includes(aTransport)
+ );
+
+ if (transport != undefined) {
+ return {
+ meekTransport: transport,
+ meekClientPath: tokens[2],
+ meekClientArgs: tokens.slice(3),
+ };
+ }
+ }
+ }
+
+ return {
+ meekTransport: null,
+ meekClientPath: null,
+ meekClientArgs: null,
+ };
+ })();
+
+ // Convert meek client path to absolute path if necessary
+ let meekWorkDir = await TorLauncherUtil.getTorFile(
+ "pt-startup-dir",
+ false
+ );
+ let re = TorLauncherUtil.isWindows ? /^[A-Za-z]:\\/ : /^\//;
+ if (!re.test(meekClientPath)) {
+ let meekPath = meekWorkDir.clone();
+ meekPath.appendRelativePath(meekClientPath);
+ meekClientPath = meekPath.path;
+ }
+
+ // Construct the per-connection arguments.
+ let meekClientEscapedArgs = "";
+ const meekReflector = Services.prefs.getStringPref(
+ TorLauncherPrefs.bridgedb_reflector
+ );
+
+ // Escape aValue per section 3.5 of the PT specification:
+ // First the "<Key>=<Value>" formatted arguments MUST be escaped,
+ // such that all backslash, equal sign, and semicolon characters
+ // are escaped with a backslash.
+ let escapeArgValue = aValue => {
+ if (!aValue) {
+ return "";
+ }
+
+ let rv = aValue.replace(/\\/g, "\\\\");
+ rv = rv.replace(/=/g, "\\=");
+ rv = rv.replace(/;/g, "\\;");
+ return rv;
+ };
+
+ if (meekReflector) {
+ meekClientEscapedArgs += "url=";
+ meekClientEscapedArgs += escapeArgValue(meekReflector);
+ }
+ const meekFront = Services.prefs.getStringPref(
+ TorLauncherPrefs.bridgedb_front
+ );
+ if (meekFront) {
+ if (meekClientEscapedArgs.length) {
+ meekClientEscapedArgs += ";";
+ }
+ meekClientEscapedArgs += "front=";
+ meekClientEscapedArgs += escapeArgValue(meekFront);
+ }
+
+ // Setup env and start meek process
+ let ptStateDir = TorLauncherUtil.getTorFile("tordatadir", false);
+ let meekHelperProfileDir = TorLauncherUtil.getTorFile(
+ "pt-profiles-dir",
+ true
+ );
+ ptStateDir.append("pt_state"); // Match what tor uses.
+ meekHelperProfileDir.appendRelativePath("profile.moat-http-helper");
+
+ let envAdditions = {
+ TOR_PT_MANAGED_TRANSPORT_VER: "1",
+ TOR_PT_STATE_LOCATION: ptStateDir.path,
+ TOR_PT_EXIT_ON_STDIN_CLOSE: "1",
+ TOR_PT_CLIENT_TRANSPORTS: meekTransport,
+ TOR_BROWSER_MEEK_PROFILE: meekHelperProfileDir.path,
+ };
+ if (TorSettings.proxy.enabled) {
+ envAdditions.TOR_PT_PROXY = TorSettings.proxy.uri;
+ }
+
+ let opts = {
+ command: meekClientPath,
+ arguments: meekClientArgs,
+ workdir: meekWorkDir.path,
+ environmentAppend: true,
+ environment: envAdditions,
+ stderr: "pipe",
+ };
+
+ // Launch meek client
+ let meekClientProcess = await Subprocess.call(opts);
+ // kill our process if exception is thrown
+ onException = () => {
+ meekClientProcess.kill();
+ };
+
+ // Callback chain for reading stderr
+ let stderrLogger = async () => {
+ if (this._meekClientProcess) {
+ let errString = await this._meekClientProcess.stderr.readString();
+ console.log(`MeekTransport: stderr => ${errString}`);
+ await stderrLogger();
+ }
+ };
+ stderrLogger();
+
+ // Read pt's stdout until terminal (CMETHODS DONE) is reached
+ // returns array of lines for parsing
+ let getInitLines = async (stdout = "") => {
+ let string = await meekClientProcess.stdout.readString();
+ stdout += string;
+
+ // look for the final message
+ const CMETHODS_DONE = "CMETHODS DONE";
+ let endIndex = stdout.lastIndexOf(CMETHODS_DONE);
+ if (endIndex != -1) {
+ endIndex += CMETHODS_DONE.length;
+ return stdout.substr(0, endIndex).split("\n");
+ }
+ return getInitLines(stdout);
+ };
+
+ // read our lines from pt's stdout
+ let meekInitLines = await getInitLines();
+ // tokenize our pt lines
+ let meekInitTokens = meekInitLines.map(line => {
+ let tokens = line.split(" ");
+ return {
+ keyword: tokens[0],
+ args: tokens.slice(1),
+ };
+ });
+
+ let meekProxyType = null;
+ let meekProxyAddr = null;
+ let meekProxyPort = 0;
+
+ // parse our pt tokens
+ for (const { keyword, args } of meekInitTokens) {
+ const argsJoined = args.join(" ");
+ let keywordError = false;
+ switch (keyword) {
+ case "VERSION": {
+ if (args.length != 1 || args[0] !== "1") {
+ keywordError = true;
+ }
+ break;
+ }
+ case "PROXY": {
+ if (args.length != 1 || args[0] !== "DONE") {
+ keywordError = true;
+ }
+ break;
+ }
+ case "CMETHOD": {
+ if (args.length != 3) {
+ keywordError = true;
+ break;
+ }
+ const transport = args[0];
+ const proxyType = args[1];
+ const addrPortString = args[2];
+ const addrPort = addrPortString.split(":");
+
+ if (transport !== meekTransport) {
+ throw new Error(
+ `MeekTransport: Expected ${meekTransport} but found ${transport}`
+ );
+ }
+ if (!["socks4", "socks4a", "socks5"].includes(proxyType)) {
+ throw new Error(
+ `MeekTransport: Invalid proxy type => ${proxyType}`
+ );
+ }
+ if (addrPort.length != 2) {
+ throw new Error(
+ `MeekTransport: Invalid proxy address => ${addrPortString}`
+ );
+ }
+ const addr = addrPort[0];
+ const port = parseInt(addrPort[1]);
+ if (port < 1 || port > 65535) {
+ throw new Error(`MeekTransport: Invalid proxy port => ${port}`);
+ }
+
+ // convert proxy type to strings used by protocol-proxy-servce
+ meekProxyType = proxyType === "socks5" ? "socks" : "socks4";
+ meekProxyAddr = addr;
+ meekProxyPort = port;
+
+ break;
+ }
+ // terminal
+ case "CMETHODS": {
+ if (args.length != 1 || args[0] !== "DONE") {
+ keywordError = true;
+ }
+ break;
+ }
+ // errors (all fall through):
+ case "VERSION-ERROR":
+ case "ENV-ERROR":
+ case "PROXY-ERROR":
+ case "CMETHOD-ERROR":
+ throw new Error(`MeekTransport: ${keyword} => '${argsJoined}'`);
+ }
+ if (keywordError) {
+ throw new Error(
+ `MeekTransport: Invalid ${keyword} keyword args => '${argsJoined}'`
+ );
+ }
+ }
+
+ this._meekClientProcess = meekClientProcess;
+ // register callback to cleanup on process exit
+ this._meekClientProcess.wait().then(exitObj => {
+ this._meekClientProcess = null;
+ this.uninit();
+ });
+
+ this._meekProxyType = meekProxyType;
+ this._meekProxyAddress = meekProxyAddr;
+ this._meekProxyPort = meekProxyPort;
+
+ // socks5
+ if (meekProxyType === "socks") {
+ if (meekClientEscapedArgs.length <= 255) {
+ this._meekProxyUsername = meekClientEscapedArgs;
+ this._meekProxyPassword = "\x00";
+ } else {
+ this._meekProxyUsername = meekClientEscapedArgs.substring(0, 255);
+ this._meekProxyPassword = meekClientEscapedArgs.substring(255);
+ }
+ // socks4
+ } else {
+ this._meekProxyUsername = meekClientEscapedArgs;
+ this._meekProxyPassword = undefined;
+ }
+
+ this._inited = true;
+ } catch (ex) {
+ onException();
+ throw ex;
+ }
+ }
+
+ async uninit() {
+ this._inited = false;
+
+ await this._meekClientProcess?.kill();
+ this._meekClientProcess = null;
+ this._meekProxyType = null;
+ this._meekProxyAddress = null;
+ this._meekProxyPort = 0;
+ this._meekProxyUsername = null;
+ this._meekProxyPassword = null;
+ }
+}
+
+//
+// Callback object with a cached promise for the returned Moat data
+//
+class MoatResponseListener {
+ constructor() {
+ this._response = "";
+ // we need this promise here because await nsIHttpChannel::asyncOpen does
+ // not return only once the request is complete, it seems to return
+ // after it begins, so we have to get the result from this listener object.
+ // This promise is only resolved once onStopRequest is called
+ this._responsePromise = new Promise((resolve, reject) => {
+ this._resolve = resolve;
+ this._reject = reject;
+ });
+ }
+
+ // callers wait on this for final response
+ response() {
+ return this._responsePromise;
+ }
+
+ // noop
+ onStartRequest(request) {}
+
+ // resolve or reject our Promise
+ onStopRequest(request, status) {
+ try {
+ if (!Components.isSuccessCode(status)) {
+ const errorMessage = TorLauncherUtil.getLocalizedStringForError(status);
+ this._reject(new Error(errorMessage));
+ }
+ if (request.responseStatus != 200) {
+ this._reject(new Error(request.responseStatusText));
+ }
+ } catch (err) {
+ this._reject(err);
+ }
+ this._resolve(this._response);
+ }
+
+ // read response data
+ onDataAvailable(request, stream, offset, length) {
+ const scriptableStream = Cc[
+ "@mozilla.org/scriptableinputstream;1"
+ ].createInstance(Ci.nsIScriptableInputStream);
+ scriptableStream.init(stream);
+ this._response += scriptableStream.read(length);
+ }
+}
+
+// constructs the json objects and sends the request over moat
+class MoatRPC {
+ constructor() {
+ this._meekTransport = null;
+ this._inited = false;
+ }
+
+ async init() {
+ if (this._inited) {
+ throw new Error("MoatRPC: Already initialized");
+ }
+
+ let meekTransport = new MeekTransport();
+ await meekTransport.init();
+ this._meekTransport = meekTransport;
+ this._inited = true;
+ }
+
+ async uninit() {
+ await this._meekTransport?.uninit();
+ this._meekTransport = null;
+ this._inited = false;
+ }
+
+ async _makeRequest(procedure, args) {
+ if (!this._inited) {
+ throw new Error("MoatRPC: Not initialized");
+ }
+
+ const proxyType = this._meekTransport._meekProxyType;
+ const proxyAddress = this._meekTransport._meekProxyAddress;
+ const proxyPort = this._meekTransport._meekProxyPort;
+ const proxyUsername = this._meekTransport._meekProxyUsername;
+ const proxyPassword = this._meekTransport._meekProxyPassword;
+
+ const proxyPS = Cc[
+ "@mozilla.org/network/protocol-proxy-service;1"
+ ].getService(Ci.nsIProtocolProxyService);
+ const flags = Ci.nsIProxyInfo.TRANSPARENT_PROXY_RESOLVES_HOST;
+ const noTimeout = 0xffffffff; // UINT32_MAX
+ const proxyInfo = proxyPS.newProxyInfoWithAuth(
+ proxyType,
+ proxyAddress,
+ proxyPort,
+ proxyUsername,
+ proxyPassword,
+ undefined,
+ undefined,
+ flags,
+ noTimeout,
+ undefined
+ );
+
+ const procedureURIString = `${Services.prefs.getStringPref(
+ TorLauncherPrefs.moat_service
+ )}/${procedure}`;
+
+ const procedureURI = Services.io.newURI(procedureURIString);
+ // There does not seem to be a way to directly create an nsILoadInfo from
+ // JavaScript, so we create a throw away non-proxied channel to get one.
+ const secFlags = Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL;
+ const loadInfo = Services.io.newChannelFromURI(
+ procedureURI,
+ undefined,
+ Services.scriptSecurityManager.getSystemPrincipal(),
+ undefined,
+ secFlags,
+ Ci.nsIContentPolicy.TYPE_OTHER
+ ).loadInfo;
+
+ const httpHandler = Services.io
+ .getProtocolHandler("http")
+ .QueryInterface(Ci.nsIHttpProtocolHandler);
+ const ch = httpHandler
+ .newProxiedChannel(procedureURI, proxyInfo, 0, undefined, loadInfo)
+ .QueryInterface(Ci.nsIHttpChannel);
+
+ // remove all headers except for 'Host"
+ const headers = [];
+ ch.visitRequestHeaders({
+ visitHeader: (key, val) => {
+ if (key !== "Host") {
+ headers.push(key);
+ }
+ },
+ });
+ headers.forEach(key => ch.setRequestHeader(key, "", false));
+
+ // Arrange for the POST data to be sent.
+ const argsJson = JSON.stringify(args);
+
+ const inStream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
+ Ci.nsIStringInputStream
+ );
+ inStream.setData(argsJson, argsJson.length);
+ const upChannel = ch.QueryInterface(Ci.nsIUploadChannel);
+ const contentType = "application/vnd.api+json";
+ upChannel.setUploadStream(inStream, contentType, argsJson.length);
+ ch.requestMethod = "POST";
+
+ // Make request
+ const listener = new MoatResponseListener();
+ await ch.asyncOpen(listener, ch);
+
+ // wait for response
+ const responseJSON = await listener.response();
+
+ // parse that JSON
+ return JSON.parse(responseJSON);
+ }
+
+ //
+ // Moat APIs
+ //
+
+ // Receive a CAPTCHA challenge, takes the following parameters:
+ // - transports: array of transport strings available to us eg: ["obfs4", "meek"]
+ //
+ // returns an object with the following fields:
+ // - transport: a transport string the moat server decides it will send you selected
+ // from the list of provided transports
+ // - image: a base64 encoded jpeg with the captcha to complete
+ // - challenge: a nonce/cookie string associated with this request
+ async fetch(transports) {
+
+ if (
+ // ensure this is an array
+ Array.isArray(transports) &&
+ // ensure array has values
+ !!transports.length &&
+ // ensure each value in the array is a string
+ transports.reduce((acc, cur) => acc && typeof cur === "string", true)
+ ) {
+ const args = {
+ data: [
+ {
+ version: "0.1.0",
+ type: "client-transports",
+ supported: transports,
+ },
+ ],
+ };
+ const response = await this._makeRequest("fetch", args);
+ if ("errors" in response) {
+ const code = response.errors[0].code;
+ const detail = response.errors[0].detail;
+ throw new Error(`MoatRPC: ${detail} (${code})`);
+ }
+
+ const transport = response.data[0].transport;
+ const image = response.data[0].image;
+ const challenge = response.data[0].challenge;
+
+ return { transport, image, challenge };
+ }
+ throw new Error("MoatRPC: fetch() expects a non-empty array of strings");
+ }
+
+ // Submit an answer for a CAPTCHA challenge and get back bridges, takes the following
+ // parameters:
+ // - transport: the transport string associated with a previous fetch request
+ // - challenge: the nonce string associated with the fetch request
+ // - solution: solution to the CAPTCHA associated with the fetch request
+ // - qrcode: true|false whether we want to get back a qrcode containing the bridge strings
+ //
+ // returns an object with the following fields:
+ // - bridges: an array of bridge line strings
+ // - qrcode: base64 encoded jpeg of bridges if requested, otherwise null
+ // if the provided solution is incorrect, returns an empty object
+ async check(transport, challenge, solution, qrcode) {
+ const args = {
+ data: [
+ {
+ id: "2",
+ version: "0.1.0",
+ type: "moat-solution",
+ transport,
+ challenge,
+ solution,
+ qrcode: qrcode ? "true" : "false",
+ },
+ ],
+ };
+ const response = await this._makeRequest("check", args);
+ if ("errors" in response) {
+ const code = response.errors[0].code;
+ const detail = response.errors[0].detail;
+ if (code == 419 && detail === "The CAPTCHA solution was incorrect.") {
+ return {};
+ }
+
+ throw new Error(`MoatRPC: ${detail} (${code})`);
+ }
+
+ const bridges = response.data[0].bridges;
+ const qrcodeImg = qrcode ? response.data[0].qrcode : null;
+
+ return { bridges, qrcode: qrcodeImg };
+ }
+
+ // Convert received settings object to format used by TorSettings module
+ // In the event of error, just return null
+ _fixupSettings(settings) {
+ try {
+ let retval = TorSettings.defaultSettings()
+ if ("bridges" in settings) {
+ retval.bridges.enabled = true;
+ switch(settings.bridges.source) {
+ case "builtin":
+ retval.bridges.source = TorBridgeSource.BuiltIn;
+ retval.bridges.builtin_type = settings.bridges.type;
+ // Tor Browser will periodically update the built-in bridge strings list using the
+ // circumvention_builtin() function, so we can ignore the bridge strings we have received here;
+ // BridgeDB only returns a subset of the available built-in bridges through the circumvention_settings()
+ // function which is fine for our 3rd parties, but we're better off ignoring them in Tor Browser, otherwise
+ // we get in a weird situation of needing to update our built-in bridges in a piece-meal fashion which
+ // seems over-complicated/error-prone
+ break;
+ case "bridgedb":
+ retval.bridges.source = TorBridgeSource.BridgeDB;
+ if (settings.bridges.bridge_strings) {
+ retval.bridges.bridge_strings = settings.bridges.bridge_strings;
+ } else {
+ throw new Error("MoatRPC::_fixupSettings(): Received no bridge-strings for BridgeDB bridge source");
+ }
+ break;
+ default:
+ throw new Error(`MoatRPC::_fixupSettings(): Unexpected bridge source '${settings.bridges.source}'`);
+ }
+ }
+ if ("proxy" in settings) {
+ // TODO: populate proxy settings
+ }
+ if ("firewall" in settings) {
+ // TODO: populate firewall settings
+ }
+ return retval;
+ } catch(ex) {
+ console.log(ex.message);
+ return null;
+ }
+ }
+
+ // Converts a list of settings objects received from BridgeDB to a list of settings objects
+ // understood by the TorSettings module
+ // In the event of error, returns and empty list
+ _fixupSettingsList(settingsList) {
+ try {
+ let retval = [];
+ for (let settings of settingsList) {
+ settings = this._fixupSettings(settings);
+ if (settings != null) {
+ retval.push(settings);
+ }
+ }
+ return retval;
+ } catch (ex) {
+ console.log(ex.message);
+ return [];
+ }
+ }
+
+ // Request tor settings for the user optionally based on their location (derived
+ // from their IP), takes the following parameters:
+ // - transports: optional, an array of transports available to the client; if empty (or not
+ // given) returns settings using all working transports known to the server
+ // - country: optional, an ISO 3166-1 alpha-2 country code to request settings for;
+ // if not provided the country is determined by the user's IP address
+ //
+ // returns an array of settings objects in roughly the same format as the _settings
+ // object on the TorSettings module.
+ // - If the server cannot determine the user's country (and no country code is provided),
+ // then null is returned
+ // - If the country has no associated settings, an empty array is returned
+ async circumvention_settings(transports, country) {
+ const args = {
+ transports: transports ? transports : [],
+ country: country,
+ };
+ const response = await this._makeRequest("circumvention/settings", args);
+ if ("errors" in response) {
+ const code = response.errors[0].code;
+ const detail = response.errors[0].detail;
+ if (code == 406) {
+ console.log("MoatRPC::circumvention_settings(): Cannot automatically determine user's country-code");
+ // cannot determine user's country
+ return null;
+ }
+
+ throw new Error(`MoatRPC: ${detail} (${code})`);
+ } else if ("settings" in response) {
+ return this._fixupSettingsList(response.settings);
+ }
+
+ return [];
+ }
+
+ // Request a copy of the censorship circumvention map (as if cirumvention_settings were
+ // queried for all country codes)
+ //
+ // returns a map whose key is an ISO 3166-1 alpha-2 country code and whose
+ // values are arrays of settings objects
+ async circumvention_map() {
+ const args = { };
+ const response = await this._makeRequest("circumvention/map", args);
+ if ("errors" in response) {
+ const code = response.errors[0].code;
+ const detail = response.errors[0].detail;
+ throw new Error(`MoatRPC: ${detail} (${code})`);
+ }
+
+ let map = new Map();
+ for (const [country, config] of Object.entries(response)) {
+ map.set(country, this._fixupSettingsList(config.settings));
+ }
+
+ return map;
+ }
+
+ // Request a copy of the builtin bridges, takes the following parameters:
+ // - transports: optional, an array of transports we would like the latest bridge strings
+ // for; if empty (or not given) returns all of them
+ //
+ // returns a map whose keys are pluggable transport types and whose values are arrays of
+ // bridge strings for that type
+ async circumvention_builtin(transports) {
+ const args = {
+ transports: transports ? transports : [],
+ };
+ const response = await this._makeRequest("circumvention/builtin", args);
+ if ("errors" in response) {
+ const code = response.errors[0].code;
+ const detail = response.errors[0].detail;
+ throw new Error(`MoatRPC: ${detail} (${code})`);
+ }
+
+ let map = new Map();
+ for (const [transport, bridge_strings] of Object.entries(response)) {
+ map.set(transport, bridge_strings);
+ }
+
+ return map;
+ }
+}
diff --git a/browser/modules/TorConnect.jsm b/browser/modules/TorConnect.jsm
new file mode 100644
index 000000000000..c7ab480e2be0
--- /dev/null
+++ b/browser/modules/TorConnect.jsm
@@ -0,0 +1,643 @@
+"use strict";
+
+var EXPORTED_SYMBOLS = ["TorConnect", "TorConnectTopics", "TorConnectState"];
+
+const { Services } = ChromeUtils.import(
+ "resource://gre/modules/Services.jsm"
+);
+
+const { BrowserWindowTracker } = ChromeUtils.import(
+ "resource:///modules/BrowserWindowTracker.jsm"
+);
+
+const { TorProtocolService, TorProcessStatus, TorTopics, TorBootstrapRequest } = ChromeUtils.import(
+ "resource:///modules/TorProtocolService.jsm"
+);
+
+const { TorLauncherUtil } = ChromeUtils.import(
+ "resource://torlauncher/modules/tl-util.jsm"
+);
+
+const { TorSettings, TorSettingsTopics, TorBridgeSource, TorBuiltinBridgeTypes, TorProxyType } = ChromeUtils.import(
+ "resource:///modules/TorSettings.jsm"
+);
+
+const { MoatRPC } = ChromeUtils.import("resource:///modules/Moat.jsm");
+
+/* Browser observer topis */
+const BrowserTopics = Object.freeze({
+ ProfileAfterChange: "profile-after-change",
+});
+
+/* Relevant prefs used by tor-launcher */
+const TorLauncherPrefs = Object.freeze({
+ prompt_at_startup: "extensions.torlauncher.prompt_at_startup",
+});
+
+const TorConnectState = Object.freeze({
+ /* Our initial state */
+ Initial: "Initial",
+ /* In-between initial boot and bootstrapping, users can change tor network settings during this state */
+ Configuring: "Configuring",
+ /* Tor is attempting to bootstrap with settings from censorship-circumvention db */
+ AutoBootstrapping: "AutoBootstrapping",
+ /* Tor is bootstrapping */
+ Bootstrapping: "Bootstrapping",
+ /* Passthrough state back to Configuring */
+ Error: "Error",
+ /* Final state, after successful bootstrap */
+ Bootstrapped: "Bootstrapped",
+ /* If we are using System tor or the legacy Tor-Launcher */
+ Disabled: "Disabled",
+});
+
+/*
+ TorConnect State Transitions
+
+ ┌─────────┐ ┌────────┐
+ │ ▼ ▼ │
+ │ ┌──────────────────────────────────────────────────────────┐ │
+ ┌─┼────── │ Error │ ◀───┐ │
+ │ │ └──────────────────────────────────────────────────────────┘ │ │
+ │ │ ▲ │ │
+ │ │ │ │ │
+ │ │ │ │ │
+ │ │ ┌───────────────────────┐ ┌──────────┐ │ │
+ │ │ ┌──── │ Initial │ ────────────────────▶ │ Disabled │ │ │
+ │ │ │ └───────────────────────┘ └──────────┘ │ │
+ │ │ │ │ │ │
+ │ │ │ │ beginBootstrap() │ │
+ │ │ │ ▼ │ │
+ │ │ │ ┌──────────────────────────────────────────────────────────┐ │ │
+ │ │ │ │ Bootstrapping │ ────┘ │
+ │ │ │ └──────────────────────────────────────────────────────────┘ │
+ │ │ │ │ ▲ │ │
+ │ │ │ │ cancelBootstrap() │ beginBootstrap() └────┐ │
+ │ │ │ ▼ │ │ │
+ │ │ │ ┌──────────────────────────────────────────────────────────┐ │ │
+ │ │ └───▶ │ │ ─┼────┘
+ │ │ │ │ │
+ │ │ │ │ │
+ │ │ │ Configuring │ │
+ │ │ │ │ │
+ │ │ │ │ │
+ └─┼─────▶ │ │ │
+ │ └──────────────────────────────────────────────────────────┘ │
+ │ │ ▲ │
+ │ │ beginAutoBootstrap() │ cancelAutoBootstrap() │
+ │ ▼ │ │
+ │ ┌───────────────────────┐ │ │
+ └────── │ AutoBootstrapping │ ─┘ │
+ └───────────────────────┘ │
+ │ │
+ │ │
+ ▼ │
+ ┌───────────────────────┐ │
+ │ Bootstrapped │ ◀───────────────────────────────────┘
+ └───────────────────────┘
+*/
+
+/* Maps allowed state transitions
+ TorConnectStateTransitions[state] maps to an array of allowed states to transition to
+ This is just an encoding of the above transition diagram that we verify at runtime
+*/
+const TorConnectStateTransitions =
+ Object.freeze(new Map([
+ [TorConnectState.Initial,
+ [TorConnectState.Disabled,
+ TorConnectState.Bootstrapping,
+ TorConnectState.Configuring,
+ TorConnectState.Error]],
+ [TorConnectState.Configuring,
+ [TorConnectState.AutoBootstrapping,
+ TorConnectState.Bootstrapping,
+ TorConnectState.Error]],
+ [TorConnectState.AutoBootstrapping,
+ [TorConnectState.Configuring,
+ TorConnectState.Bootstrapped,
+ TorConnectState.Error]],
+ [TorConnectState.Bootstrapping,
+ [TorConnectState.Configuring,
+ TorConnectState.Bootstrapped,
+ TorConnectState.Error]],
+ [TorConnectState.Error,
+ [TorConnectState.Configuring]],
+ // terminal states
+ [TorConnectState.Bootstrapped, []],
+ [TorConnectState.Disabled, []],
+ ]));
+
+/* Topics Notified by the TorConnect module */
+const TorConnectTopics = Object.freeze({
+ StateChange: "torconnect:state-change",
+ BootstrapProgress: "torconnect:bootstrap-progress",
+ BootstrapComplete: "torconnect:bootstrap-complete",
+ BootstrapError: "torconnect:bootstrap-error",
+});
+
+// The StateCallback is a wrapper around an async function which executes during
+// the lifetime of a TorConnect State. A system is also provided to allow this
+// ongoing function to early-out via a per StateCallback on_transition callback
+// which may be called externally when we need to early-out and move on to another
+// state (for example, from Bootstrapping to Configuring in the event the user
+// cancels a bootstrap attempt)
+class StateCallback {
+
+ constructor(state, callback) {
+ this._state = state;
+ this._callback = callback;
+ this._init();
+ }
+
+ _init() {
+ // this context object is bound to the callback each time transition is
+ // attempted via begin()
+ this._context = {
+ // This callback may be overwritten in the _callback for each state
+ // States may have various pieces of work which need to occur
+ // before they can be exited (eg resource cleanup)
+ // See the _stateCallbacks map for examples
+ on_transition: (nextState) => {},
+
+ // flag used to determine if a StateCallback should early-out
+ // its work
+ _transitioning: false,
+
+ // may be called within the StateCallback to determine if exit is possible
+ get transitioning() {
+ return this._transitioning;
+ }
+ };
+ }
+
+ async begin(...args) {
+ console.log(`TorConnect: Entering ${this._state} state`);
+ this._init();
+ try {
+ // this Promise will block until this StateCallback has completed its work
+ await Promise.resolve(this._callback.call(this._context, ...args));
+ console.log(`TorConnect: Exited ${this._state} state`);
+
+ // handled state transition
+ Services.obs.notifyObservers({state: this._nextState}, TorConnectTopics.StateChange);
+ TorConnect._callback(this._nextState).begin(...this._nextStateArgs);
+ } catch (obj) {
+ TorConnect._changeState(TorConnectState.Error, obj?.message, obj?.details);
+ }
+ }
+
+ transition(nextState, ...args) {
+ this._nextState = nextState;
+ this._nextStateArgs = [...args];
+
+ // calls the on_transition callback to resolve any async work or do per-state cleanup
+ // this call to on_transition should resolve the async work currentlying going on in this.begin()
+ this._context.on_transition(nextState);
+ this._context._transitioning = true;
+ }
+}
+
+const TorConnect = (() => {
+ let retval = {
+
+ _state: TorConnectState.Initial,
+ _bootstrapProgress: 0,
+ _bootstrapStatus: null,
+ _errorMessage: null,
+ _errorDetails: null,
+ _logHasWarningOrError: false,
+ _transitionPromise: null,
+
+ /* These functions represent ongoing work associated with one of our states
+ Some of these functions are mostly empty, apart from defining an
+ on_transition function used to resolve their Promise */
+ _stateCallbacks: Object.freeze(new Map([
+ /* Initial is never transitioned to */
+ [TorConnectState.Initial, new StateCallback(TorConnectState.Initial, async function() {
+ // The initial state doesn't actually do anything, so here is a skeleton for other
+ // states which do perform work
+ await new Promise(async (resolve, reject) => {
+ // This function is provided to signal to the callback that it is complete.
+ // It is called as a result of _changeState and at the very least must
+ // resolve the root Promise object within the StateCallback function
+ // The on_transition callback may also perform necessary cleanup work
+ this.on_transition = (nextState) => {
+ resolve();
+ };
+
+ try {
+ // each state may have a sequence of async work to do
+ let asyncWork = async () => {};
+ await asyncWork();
+
+ // after each block we may check for an opportunity to early-out
+ if (this.transitioning) {
+ return;
+ }
+
+ // repeat the above pattern as necessary
+ } catch(err) {
+ // any thrown exceptions here will trigger a transition to the Error state
+ TorConnect._changeState(TorConnectState.Error, err?.message, err?.details);
+ }
+ });
+ })],
+ /* Configuring */
+ [TorConnectState.Configuring, new StateCallback(TorConnectState.Configuring, async function() {
+ await new Promise(async (resolve, reject) => {
+ this.on_transition = (nextState) => {
+ resolve();
+ };
+ });
+ })],
+ /* Bootstrapping */
+ [TorConnectState.Bootstrapping, new StateCallback(TorConnectState.Bootstrapping, async function() {
+ // wait until bootstrap completes or we get an error
+ await new Promise(async (resolve, reject) => {
+ const tbr = new TorBootstrapRequest();
+ this.on_transition = async (nextState) => {
+ if (nextState === TorConnectState.Configuring) {
+ // stop bootstrap process if user cancelled
+ await tbr.cancel();
+ }
+ resolve();
+ };
+
+ tbr.onbootstrapstatus = (progress, status) => {
+ TorConnect._updateBootstrapStatus(progress, status);
+ };
+ tbr.onbootstrapcomplete = () => {
+ TorConnect._changeState(TorConnectState.Bootstrapped);
+ };
+ tbr.onbootstraperror = (message, details) => {
+ TorConnect._changeState(TorConnectState.Error, message, details);
+ };
+
+ tbr.bootstrap();
+ });
+ })],
+ /* AutoBootstrapping */
+ [TorConnectState.AutoBootstrapping, new StateCallback(TorConnectState.AutoBootstrapping, async function(countryCode) {
+ await new Promise(async (resolve, reject) => {
+ this.on_transition = (nextState) => {
+ resolve();
+ };
+
+ // lookup user's potential censorship circumvention settings from Moat service
+ try {
+ this.mrpc = new MoatRPC();
+ await this.mrpc.init();
+
+ this.settings = await this.mrpc.circumvention_settings([...TorBuiltinBridgeTypes, "vanilla"], countryCode);
+
+ if (this.transitioning) return;
+
+ if (this.settings === null) {
+ // unable to determine country
+ TorConnect._changeState(TorConnectState.Error, "Unable to determine user country", "DETAILS_STRING");
+ return;
+ } else if (this.settings.length === 0) {
+ // no settings available for country
+ TorConnect._changeState(TorConnectState.Error, "No settings available for your location", "DETAILS_STRING");
+ return;
+ }
+ } catch (err) {
+ TorConnect._changeState(TorConnectState.Error, err?.message, err?.details);
+ return;
+ } finally {
+ // important to uninit MoatRPC object or else the pt process will live as long as tor-browser
+ this.mrpc?.uninit();
+ }
+
+ // apply each of our settings and try to bootstrap with each
+ try {
+ this.originalSettings = TorSettings.getSettings();
+
+ let index = 0;
+ for (let currentSetting of this.settings) {
+ // let us early out if user cancels
+ if (this.transitioning) return;
+
+ console.log(`TorConnect: Attempting Bootstrap with configuration ${++index}/${this.settings.length}`);
+
+ TorSettings.setSettings(currentSetting);
+ await TorSettings.applySettings();
+
+ // build out our bootstrap request
+ const tbr = new TorBootstrapRequest();
+ tbr.onbootstrapstatus = (progress, status) => {
+ TorConnect._updateBootstrapStatus(progress, status);
+ };
+ tbr.onbootstraperror = (message, details) => {
+ console.log(`TorConnect: Auto-Bootstrap error => ${message}; ${details}`);
+ };
+
+ // update transition callback for user cancel
+ this.on_transition = async (nextState) => {
+ if (nextState === TorConnectState.Configuring) {
+ await tbr.cancel();
+ }
+ resolve();
+ };
+
+ // begin bootstrap
+ if (await tbr.bootstrap()) {
+ // persist the current settings to preferences
+ TorSettings.saveToPrefs();
+ TorConnect._changeState(TorConnectState.Bootstrapped);
+ return;
+ }
+ }
+ // bootstrapped failed for all potential settings, so reset daemon to use original
+ TorSettings.setSettings(this.originalSettings);
+ await TorSettings.applySettings();
+ TorSettings.saveToPrefs();
+
+ // only explicitly change state here if something else has not transitioned us
+ if (!this.transitioning) {
+ TorConnect._changeState(TorConnectState.Error, "AutoBootstrapping failed", "DETAILS_STRING");
+ }
+ return;
+ } catch (err) {
+ // restore original settings in case of error
+ try {
+ TorSettings.setSettings(this.originalSettings);
+ await TorSettings.applySettings();
+ } catch(err) {
+ console.log(`TorConnect: Failed to restore original settings => ${err}`);
+ }
+ TorConnect._changeState(TorConnectState.Error, err?.message, err?.details);
+ return;
+ }
+ });
+ })],
+ /* Bootstrapped */
+ [TorConnectState.Bootstrapped, new StateCallback(TorConnectState.Bootstrapped, async function() {
+ await new Promise((resolve, reject) => {
+ // on_transition not defined because no way to leave Bootstrapped state
+ // notify observers of bootstrap completion
+ Services.obs.notifyObservers(null, TorConnectTopics.BootstrapComplete);
+ });
+ })],
+ /* Error */
+ [TorConnectState.Error, new StateCallback(TorConnectState.Error, async function(errorMessage, errorDetails) {
+ await new Promise((resolve, reject) => {
+ this.on_transition = async(nextState) => {
+ resolve();
+ };
+
+ TorConnect._errorMessage = errorMessage;
+ TorConnect._errorDetails = errorDetails;
+
+ Services.obs.notifyObservers({message: errorMessage, details: errorDetails}, TorConnectTopics.BootstrapError);
+
+ TorConnect._changeState(TorConnectState.Configuring);
+ });
+ })],
+ /* Disabled */
+ [TorConnectState.Disabled, new StateCallback(TorConnectState.Disabled, async function() {
+ await new Promise((resolve, reject) => {
+ // no-op, on_transition not defined because no way to leave Disabled state
+ });
+ })],
+ ])),
+
+ _callback: function(state) {
+ return this._stateCallbacks.get(state);
+ },
+
+ _changeState: function(newState, ...args) {
+ const prevState = this._state;
+
+ // ensure this is a valid state transition
+ if (!TorConnectStateTransitions.get(prevState)?.includes(newState)) {
+ throw Error(`TorConnect: Attempted invalid state transition from ${prevState} to ${newState}`);
+ }
+
+ console.log(`TorConnect: Try transitioning from ${prevState} to ${newState}`);
+
+ // set our new state first so that state transitions can themselves trigger
+ // a state transition
+ this._state = newState;
+
+ // call our state function and forward any args
+ this._callback(prevState).transition(newState, ...args);
+ },
+
+ _updateBootstrapStatus: function(progress, status) {
+ this._bootstrapProgress= progress;
+ this._bootstrapStatus = status;
+
+ console.log(`TorConnect: Bootstrapping ${this._bootstrapProgress}% complete (${this._bootstrapStatus})`);
+ Services.obs.notifyObservers({
+ progress: TorConnect._bootstrapProgress,
+ status: TorConnect._bootstrapStatus,
+ hasWarnings: TorConnect._logHasWarningOrError
+ }, TorConnectTopics.BootstrapProgress);
+ },
+
+ // init should be called on app-startup in MainProcessingSingleton.jsm
+ init: function() {
+ console.log("TorConnect: init()");
+
+ // delay remaining init until after profile-after-change
+ Services.obs.addObserver(this, BrowserTopics.ProfileAfterChange);
+
+ this._callback(TorConnectState.Initial).begin();
+ },
+
+ observe: async function(subject, topic, data) {
+ console.log(`TorConnect: Observed ${topic}`);
+
+ switch(topic) {
+
+ /* Determine which state to move to from Initial */
+ case BrowserTopics.ProfileAfterChange: {
+ if (TorLauncherUtil.useLegacyLauncher || !TorProtocolService.ownsTorDaemon) {
+ // Disabled
+ this._changeState(TorConnectState.Disabled);
+ } else {
+ let observeTopic = (topic) => {
+ Services.obs.addObserver(this, topic);
+ console.log(`TorConnect: Observing topic '${topic}'`);
+ };
+
+ // register the Tor topics we always care about
+ observeTopic(TorTopics.ProcessExited);
+ observeTopic(TorTopics.LogHasWarnOrErr);
+ observeTopic(TorSettingsTopics.Ready);
+ }
+ Services.obs.removeObserver(this, topic);
+ break;
+ }
+ /* We need to wait until TorSettings have been loaded and applied before we can Quickstart */
+ case TorSettingsTopics.Ready: {
+ if (this.shouldQuickStart) {
+ // Quickstart
+ this._changeState(TorConnectState.Bootstrapping);
+ } else {
+ // Configuring
+ this._changeState(TorConnectState.Configuring);
+ }
+ break;
+ }
+ case TorTopics.LogHasWarnOrErr: {
+ this._logHasWarningOrError = true;
+ break;
+ }
+ default:
+ // ignore
+ break;
+ }
+ },
+
+ /*
+ Various getters
+ */
+
+ get shouldShowTorConnect() {
+ // TorBrowser must control the daemon
+ return (TorProtocolService.ownsTorDaemon &&
+ // and we're not using the legacy launcher
+ !TorLauncherUtil.useLegacyLauncher &&
+ // if we have succesfully bootstraped, then no need to show TorConnect
+ this.state != TorConnectState.Bootstrapped);
+ },
+
+ get shouldQuickStart() {
+ // quickstart must be enabled
+ return TorSettings.quickstart.enabled &&
+ // and the previous bootstrap attempt must have succeeded
+ !Services.prefs.getBoolPref(TorLauncherPrefs.prompt_at_startup, true);
+ },
+
+ get state() {
+ return this._state;
+ },
+
+ get bootstrapProgress() {
+ return this._bootstrapProgress;
+ },
+
+ get bootstrapStatus() {
+ return this._bootstrapStatus;
+ },
+
+ get errorMessage() {
+ return this._errorMessage;
+ },
+
+ get errorDetails() {
+ return this._errorDetails;
+ },
+
+ get logHasWarningOrError() {
+ return this._logHasWarningOrError;
+ },
+
+ /*
+ These functions allow external consumers to tell TorConnect to transition states
+ */
+
+ beginBootstrap: function() {
+ console.log("TorConnect: beginBootstrap()");
+ this._changeState(TorConnectState.Bootstrapping);
+ },
+
+ cancelBootstrap: function() {
+ console.log("TorConnect: cancelBootstrap()");
+ this._changeState(TorConnectState.Configuring);
+ },
+
+ beginAutoBootstrap: function(countryCode) {
+ console.log("TorConnect: beginAutoBootstrap()");
+ this._changeState(TorConnectState.AutoBootstrapping, countryCode);
+ },
+
+ cancelAutoBootstrap: function() {
+ console.log("TorConnect: cancelAutoBootstrap()");
+ this._changeState(TorConnectState.Configuring);
+ },
+
+ /*
+ Further external commands and helper methods
+ */
+ openTorPreferences: function() {
+ const win = BrowserWindowTracker.getTopWindow();
+ win.switchToTabHavingURI("about:preferences#tor", true);
+ },
+
+ openTorConnect: function() {
+ const win = BrowserWindowTracker.getTopWindow();
+ win.switchToTabHavingURI("about:torconnect", true, {ignoreQueryString: true});
+ },
+
+ copyTorLogs: function() {
+ // Copy tor log messages to the system clipboard.
+ const chSvc = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(
+ Ci.nsIClipboardHelper
+ );
+ const countObj = { value: 0 };
+ chSvc.copyString(TorProtocolService.getLog(countObj));
+ const count = countObj.value;
+ return TorLauncherUtil.getFormattedLocalizedString(
+ "copiedNLogMessagesShort",
+ [count],
+ 1
+ );
+ },
+
+ getRedirectURL: function(url) {
+ return `about:torconnect?redirect=${encodeURIComponent(url)}`;
+ },
+
+ // called from browser.js on browser startup, passed in either the user's homepage(s)
+ // or uris passed via command-line; we want to replace them with about:torconnect uris
+ // which redirect after bootstrapping
+ getURIsToLoad: function(uriVariant) {
+ // convert the object we get from browser.js
+ let uriStrings = ((v) => {
+ // an interop array
+ if (v instanceof Ci.nsIArray) {
+ // Transform the nsIArray of nsISupportsString's into a JS Array of
+ // JS strings.
+ return Array.from(
+ v.enumerate(Ci.nsISupportsString),
+ supportStr => supportStr.data
+ );
+ // an interop string
+ } else if (v instanceof Ci.nsISupportsString) {
+ return [v.data];
+ // a js string
+ } else if (typeof v === "string") {
+ return v.split("|");
+ // a js array of js strings
+ } else if (Array.isArray(v) &&
+ v.reduce((allStrings, entry) => {return allStrings && (typeof entry === "string");}, true)) {
+ return v;
+ }
+ // about:tor as safe fallback
+ console.log(`TorConnect: getURIsToLoad() received unknown variant '${JSON.stringify(v)}'`);
+ return ["about:tor"];
+ })(uriVariant);
+
+ // will attempt to convert user-supplied string to a uri, fallback to about:tor if cannot convert
+ // to valid uri object
+ let uriStringToUri = (uriString) => {
+ const fixupFlags = Ci.nsIURIFixup.FIXUP_FLAG_NONE;
+ let uri = Services.uriFixup.getFixupURIInfo(uriString, fixupFlags)
+ .preferredURI;
+ return uri ? uri : Services.io.newURI("about:tor");
+ };
+ let uris = uriStrings.map(uriStringToUri);
+
+ // assume we have a valid uri and generate an about:torconnect redirect uri
+ let redirectUrls = uris.map((uri) => this.getRedirectURL(uri.spec));
+
+ console.log(`TorConnect: Will load after bootstrap => [${uris.map((uri) => {return uri.spec;}).join(", ")}]`);
+ return redirectUrls;
+ },
+ };
+ retval.init();
+ return retval;
+})(); /* TorConnect */
diff --git a/browser/modules/TorProtocolService.jsm b/browser/modules/TorProtocolService.jsm
new file mode 100644
index 000000000000..ac6d643691f6
--- /dev/null
+++ b/browser/modules/TorProtocolService.jsm
@@ -0,0 +1,484 @@
+// Copyright (c) 2021, The Tor Project, Inc.
+
+"use strict";
+
+var EXPORTED_SYMBOLS = ["TorProtocolService", "TorProcessStatus", "TorTopics", "TorBootstrapRequest"];
+
+const { Services } = ChromeUtils.import(
+ "resource://gre/modules/Services.jsm"
+);
+
+const { setTimeout, clearTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
+
+const { TorLauncherUtil } = ChromeUtils.import(
+ "resource://torlauncher/modules/tl-util.jsm"
+);
+
+// see tl-process.js
+const TorProcessStatus = Object.freeze({
+ Unknown: 0,
+ Starting: 1,
+ Running: 2,
+ Exited: 3,
+});
+
+/* tor-launcher observer topics */
+const TorTopics = Object.freeze({
+ BootstrapStatus: "TorBootstrapStatus",
+ BootstrapError: "TorBootstrapError",
+ ProcessExited: "TorProcessExited",
+ LogHasWarnOrErr: "TorLogHasWarnOrErr",
+});
+
+/* Browser observer topis */
+const BrowserTopics = Object.freeze({
+ ProfileAfterChange: "profile-after-change",
+});
+
+var TorProtocolService = {
+ _TorLauncherUtil: function() {
+ let { TorLauncherUtil } = ChromeUtils.import(
+ "resource://torlauncher/modules/tl-util.jsm"
+ );
+ return TorLauncherUtil;
+ }(),
+ _TorLauncherProtocolService: null,
+ _TorProcessService: null,
+
+ // maintain a map of tor settings set by Tor Browser so that we don't
+ // repeatedly set the same key/values over and over
+ // this map contains string keys to primitive or array values
+ _settingsCache: new Map(),
+
+ init() {
+ Services.obs.addObserver(this, BrowserTopics.ProfileAfterChange);
+ },
+
+ observe(subject, topic, data) {
+ if (topic === BrowserTopics.ProfileAfterChange) {
+ // we have to delay init'ing this or else the crypto service inits too early without a profile
+ // which breaks the password manager
+ this._TorLauncherProtocolService = Cc["@torproject.org/torlauncher-protocol-service;1"].getService(
+ Ci.nsISupports
+ ).wrappedJSObject;
+ this._TorProcessService = Cc["@torproject.org/torlauncher-process-service;1"].getService(
+ Ci.nsISupports
+ ).wrappedJSObject,
+
+ Services.obs.removeObserver(this, topic);
+ }
+ },
+
+ _typeof(aValue) {
+ switch (typeof aValue) {
+ case "boolean":
+ return "boolean";
+ case "string":
+ return "string";
+ case "object":
+ if (aValue == null) {
+ return "null";
+ } else if (Array.isArray(aValue)) {
+ return "array";
+ }
+ return "object";
+ }
+ return "unknown";
+ },
+
+ _assertValidSettingKey(aSetting) {
+ // ensure the 'key' is a string
+ if (typeof aSetting != "string") {
+ throw new Error(
+ `Expected setting of type string but received ${typeof aSetting}`
+ );
+ }
+ },
+
+ _assertValidSetting(aSetting, aValue) {
+ this._assertValidSettingKey(aSetting);
+
+ const valueType = this._typeof(aValue);
+ switch (valueType) {
+ case "boolean":
+ case "string":
+ case "null":
+ return;
+ case "array":
+ for (const element of aValue) {
+ if (typeof element != "string") {
+ throw new Error(
+ `Setting '${aSetting}' array contains value of invalid type '${typeof element}'`
+ );
+ }
+ }
+ return;
+ default:
+ throw new Error(
+ `Invalid object type received for setting '${aSetting}'`
+ );
+ }
+ },
+
+ // takes a Map containing tor settings
+ // throws on error
+ async writeSettings(aSettingsObj) {
+ // only write settings that have changed
+ let newSettings = new Map();
+ for (const [setting, value] of aSettingsObj) {
+ let saveSetting = false;
+
+ // make sure we have valid data here
+ this._assertValidSetting(setting, value);
+
+ if (!this._settingsCache.has(setting)) {
+ // no cached setting, so write
+ saveSetting = true;
+ } else {
+ const cachedValue = this._settingsCache.get(setting);
+ if (value != cachedValue) {
+ // compare arrays member-wise
+ if (Array.isArray(value) && Array.isArray(cachedValue)) {
+ if (value.length != cachedValue.length) {
+ saveSetting = true;
+ } else {
+ const arrayLength = value.length;
+ for (let i = 0; i < arrayLength; ++i) {
+ if (value[i] != cachedValue[i]) {
+ saveSetting = true;
+ break;
+ }
+ }
+ }
+ } else {
+ // some other different values
+ saveSetting = true;
+ }
+ }
+ }
+
+ if (saveSetting) {
+ newSettings.set(setting, value);
+ }
+ }
+
+ // only write if new setting to save
+ if (newSettings.size > 0) {
+ // convert settingsObject map to js object for torlauncher-protocol-service
+ let settingsObject = {};
+ for (const [setting, value] of newSettings) {
+ settingsObject[setting] = value;
+ }
+
+ let errorObject = {};
+ if (! await this._TorLauncherProtocolService.TorSetConfWithReply(settingsObject, errorObject)) {
+ throw new Error(errorObject.details);
+ }
+
+ // save settings to cache after successfully writing to Tor
+ for (const [setting, value] of newSettings) {
+ this._settingsCache.set(setting, value);
+ }
+ }
+ },
+
+ async _readSetting(aSetting) {
+ this._assertValidSettingKey(aSetting);
+ let reply = await this._TorLauncherProtocolService.TorGetConf(aSetting);
+ if (this._TorLauncherProtocolService.TorCommandSucceeded(reply)) {
+ return reply.lineArray;
+ }
+ throw new Error(reply.lineArray.join("\n"));
+ },
+
+ async _readBoolSetting(aSetting) {
+ let lineArray = await this._readSetting(aSetting);
+ if (lineArray.length != 1) {
+ throw new Error(
+ `Expected an array with length 1 but received array of length ${
+ lineArray.length
+ }`
+ );
+ }
+
+ let retval = lineArray[0];
+ switch (retval) {
+ case "0":
+ return false;
+ case "1":
+ return true;
+ default:
+ throw new Error(`Expected boolean (1 or 0) but received '${retval}'`);
+ }
+ },
+
+ async _readStringSetting(aSetting) {
+ let lineArray = await this._readSetting(aSetting);
+ if (lineArray.length != 1) {
+ throw new Error(
+ `Expected an array with length 1 but received array of length ${
+ lineArray.length
+ }`
+ );
+ }
+ return lineArray[0];
+ },
+
+ async _readStringArraySetting(aSetting) {
+ let lineArray = await this._readSetting(aSetting);
+ return lineArray;
+ },
+
+ async readBoolSetting(aSetting) {
+ let value = await this._readBoolSetting(aSetting);
+ this._settingsCache.set(aSetting, value);
+ return value;
+ },
+
+ async readStringSetting(aSetting) {
+ let value = await this._readStringSetting(aSetting);
+ this._settingsCache.set(aSetting, value);
+ return value;
+ },
+
+ async readStringArraySetting(aSetting) {
+ let value = await this._readStringArraySetting(aSetting);
+ this._settingsCache.set(aSetting, value);
+ return value;
+ },
+
+ // writes current tor settings to disk
+ async flushSettings() {
+ await this.sendCommand("SAVECONF");
+ },
+
+ getLog(countObj) {
+ countObj = countObj || { value: 0 };
+ let torLog = this._TorLauncherProtocolService.TorGetLog(countObj);
+ return torLog;
+ },
+
+ // true if we launched and control tor, false if using system tor
+ get ownsTorDaemon() {
+ return this._TorLauncherUtil.shouldStartAndOwnTor;
+ },
+
+ // Assumes `ownsTorDaemon` is true
+ isNetworkDisabled() {
+ const reply = TorProtocolService._TorLauncherProtocolService.TorGetConfBool(
+ "DisableNetwork",
+ true
+ );
+ if (TorProtocolService._TorLauncherProtocolService.TorCommandSucceeded(reply)) {
+ return reply.retVal;
+ }
+ return true;
+ },
+
+ async enableNetwork() {
+ let settings = {};
+ settings.DisableNetwork = false;
+ let errorObject = {};
+ if (! await this._TorLauncherProtocolService.TorSetConfWithReply(settings, errorObject)) {
+ throw new Error(errorObject.details);
+ }
+ },
+
+ async sendCommand(cmd) {
+ return await this._TorLauncherProtocolService.TorSendCommand(cmd);
+ },
+
+ retrieveBootstrapStatus() {
+ return this._TorLauncherProtocolService.TorRetrieveBootstrapStatus();
+ },
+
+ _GetSaveSettingsErrorMessage(aDetails) {
+ try {
+ return this._TorLauncherUtil.getSaveSettingsErrorMessage(aDetails);
+ } catch (e) {
+ console.log("GetSaveSettingsErrorMessage error", e);
+ return "Unexpected Error";
+ }
+ },
+
+ async setConfWithReply(settings) {
+ let result = false;
+ const error = {};
+ try {
+ result = await this._TorLauncherProtocolService.TorSetConfWithReply(settings, error);
+ } catch (e) {
+ console.log("TorSetConfWithReply error", e);
+ error.details = this._GetSaveSettingsErrorMessage(e.message);
+ }
+ return { result, error };
+ },
+
+ isBootstrapDone() {
+ return this._TorProcessService.mIsBootstrapDone;
+ },
+
+ clearBootstrapError() {
+ return this._TorProcessService.TorClearBootstrapError();
+ },
+
+ torBootstrapErrorOccurred() {
+ return this._TorProcessService.TorBootstrapErrorOccurred;
+ },
+
+ // Resolves to null if ok, or an error otherwise
+ async connect() {
+ const kTorConfKeyDisableNetwork = "DisableNetwork";
+ const settings = {};
+ settings[kTorConfKeyDisableNetwork] = false;
+ const { result, error } = await this.setConfWithReply(settings);
+ if (!result) {
+ return error;
+ }
+ try {
+ await this.sendCommand("SAVECONF");
+ this.clearBootstrapError();
+ this.retrieveBootstrapStatus();
+ } catch (e) {
+ return error;
+ }
+ return null;
+ },
+
+ torLogHasWarnOrErr() {
+ return this._TorLauncherProtocolService.TorLogHasWarnOrErr;
+ },
+
+ async torStopBootstrap() {
+ // Tell tor to disable use of the network; this should stop the bootstrap
+ // process.
+ const kErrorPrefix = "Setting DisableNetwork=1 failed: ";
+ try {
+ let settings = {};
+ settings.DisableNetwork = true;
+ const { result, error } = await this.setConfWithReply(settings);
+ if (!result) {
+ console.log(
+ `Error stopping bootstrap ${kErrorPrefix} ${error.details}`
+ );
+ }
+ } catch (e) {
+ console.log(`Error stopping bootstrap ${kErrorPrefix} ${e}`);
+ }
+ this.retrieveBootstrapStatus();
+ },
+
+ get torProcessStatus() {
+ if (this._TorProcessService) {
+ return this._TorProcessService.TorProcessStatus;
+ }
+ return TorProcessStatus.Unknown;
+ },
+};
+TorProtocolService.init();
+
+// modeled after XMLHttpRequest
+// nicely encapsulates the observer register/unregister logic
+class TorBootstrapRequest {
+ constructor() {
+ // number of ms to wait before we abandon the bootstrap attempt
+ // a value of 0 implies we never wait
+ this.timeout = 0;
+ // callbacks for bootstrap process status updates
+ this.onbootstrapstatus = (progress, status) => {};
+ this.onbootstrapcomplete = () => {};
+ this.onbootstraperror = (message, details) => {};
+
+ // internal resolve() method for bootstrap
+ this._bootstrapPromiseResolve = null;
+ this._bootstrapPromise = null;
+ this._timeoutID = null;
+ }
+
+ async observe(subject, topic, data) {
+ const obj = subject?.wrappedJSObject;
+ switch(topic) {
+ case TorTopics.BootstrapStatus: {
+ const progress = obj.PROGRESS;
+ const status = TorLauncherUtil.getLocalizedBootstrapStatus(obj, "TAG");
+ if (this.onbootstrapstatus) {
+ this.onbootstrapstatus(progress, status);
+ }
+ if (progress === 100) {
+ if (this.onbootstrapcomplete) {
+ this.onbootstrapcomplete();
+ }
+ this._bootstrapPromiseResolve(true);
+ clearTimeout(this._timeoutID);
+ }
+
+ break;
+ }
+ case TorTopics.BootstrapError: {
+ // first stop our bootstrap timeout before handling the error
+ clearTimeout(this._timeoutID);
+
+ await TorProtocolService.torStopBootstrap();
+
+ const message = obj.message;
+ const details = obj.details;
+ if (this.onbootstraperror) {
+ this.onbootstraperror(message, details);
+ }
+ this._bootstrapPromiseResolve(false);
+ break;
+ }
+ }
+ }
+
+ // resolves 'true' if bootstrap succeeds, false otherwise
+ async bootstrap() {
+ if (this._bootstrapPromise) return this._bootstrapPromise;
+
+ this._bootstrapPromise = new Promise(async (resolve, reject) => {
+ this._bootstrapPromiseResolve = resolve;
+
+ // register ourselves to listen for bootstrap events
+ Services.obs.addObserver(this, TorTopics.BootstrapStatus);
+ Services.obs.addObserver(this, TorTopics.BootstrapError);
+
+ // optionally cancel bootstrap after a given timeout
+ if (this.timeout > 0) {
+ this._timeoutID = setTimeout(async () => {
+ await TorProtocolService.torStopBootstrap();
+ if (this.onbootstraperror) {
+ this.onbootstraperror("Tor Bootstrap process timed out", `Bootstrap attempt abandoned after waiting ${this.timeout} ms`);
+ }
+ this._bootstrapPromiseResolve(false);
+ }, this.timeout);
+ }
+
+ // wait for bootstrapping to begin and maybe handle error
+ let err = await TorProtocolService.connect();
+ if (err) {
+ clearTimeout(this._timeoutID);
+ await TorProtocolService.torStopBootstrap();
+
+ const message = err.message;
+ const details = err.details;
+ if (this.onbootstraperror) {
+ this.onbootstraperror(message, details);
+ }
+ this._bootstrapPromiseResolve(false);
+ }
+ }).finally(() => {
+ // and remove ourselves once bootstrap is resolved
+ Services.obs.removeObserver(this, TorTopics.BootstrapStatus);
+ Services.obs.removeObserver(this, TorTopics.BootstrapError);
+ });
+
+ return this._bootstrapPromise;
+ }
+
+ async cancel() {
+ clearTimeout(this._timeoutID);
+
+ await TorProtocolService.torStopBootstrap();
+
+ this._bootstrapPromiseResolve(false);
+ }
+};
diff --git a/browser/modules/TorSettings.jsm b/browser/modules/TorSettings.jsm
new file mode 100644
index 000000000000..1b5b564e1e62
--- /dev/null
+++ b/browser/modules/TorSettings.jsm
@@ -0,0 +1,693 @@
+"use strict";
+
+var EXPORTED_SYMBOLS = ["TorSettings", "TorSettingsTopics", "TorSettingsData", "TorBridgeSource", "TorBuiltinBridgeTypes", "TorProxyType"];
+
+const { Services } = ChromeUtils.import(
+ "resource://gre/modules/Services.jsm"
+);
+
+const { TorProtocolService, TorProcessStatus } = ChromeUtils.import(
+ "resource:///modules/TorProtocolService.jsm"
+);
+
+/* Browser observer topics */
+const BrowserTopics = Object.freeze({
+ ProfileAfterChange: "profile-after-change",
+});
+
+/* tor-launcher observer topics */
+const TorTopics = Object.freeze({
+ ProcessIsReady: "TorProcessIsReady",
+});
+
+/* TorSettings observer topics */
+const TorSettingsTopics = Object.freeze({
+ Ready: "torsettings:ready",
+ SettingChanged: "torsettings:setting-changed",
+});
+
+/* TorSettings observer data (for SettingChanged topic) */
+const TorSettingsData = Object.freeze({
+ QuickStartEnabled : "torsettings:quickstart_enabled",
+});
+
+/* Prefs used to store settings in TorBrowser prefs */
+const TorSettingsPrefs = Object.freeze({
+ /* bool: are we pulling tor settings from the preferences */
+ enabled: 'torbrowser.settings.enabled',
+ quickstart : {
+ /* bool: does tor connect automatically on launch */
+ enabled: 'torbrowser.settings.quickstart.enabled',
+ },
+ bridges : {
+ /* bool: does tor use bridges */
+ enabled : 'torbrowser.settings.bridges.enabled',
+ /* int: -1=invalid|0=builtin|1=bridge_db|2=user_provided */
+ source : 'torbrowser.settings.bridges.source',
+ /* string: obfs4|meek_azure|snowflake|etc */
+ builtin_type : 'torbrowser.settings.bridges.builtin_type',
+ /* preference branch: each child branch should be a bridge string */
+ bridge_strings : 'torbrowser.settings.bridges.bridge_strings',
+ },
+ proxy : {
+ /* bool: does tor use a proxy */
+ enabled : 'torbrowser.settings.proxy.enabled',
+ /* -1=invalid|0=socks4,1=socks5,2=https */
+ type: 'torbrowser.settings.proxy.type',
+ /* string: proxy server address */
+ address: 'torbrowser.settings.proxy.address',
+ /* int: [1,65535], proxy port */
+ port: 'torbrowser.settings.proxy.port',
+ /* string: username */
+ username: 'torbrowser.settings.proxy.username',
+ /* string: password */
+ password: 'torbrowser.settings.proxy.password',
+ },
+ firewall : {
+ /* bool: does tor have a port allow list */
+ enabled: 'torbrowser.settings.firewall.enabled',
+ /* string: comma-delimitted list of port numbers */
+ allowed_ports: 'torbrowser.settings.firewall.allowed_ports',
+ },
+});
+
+/* Legacy tor-launcher prefs and pref branches*/
+const TorLauncherPrefs = Object.freeze({
+ quickstart: "extensions.torlauncher.quickstart",
+ default_bridge_type: "extensions.torlauncher.default_bridge_type",
+ default_bridge: "extensions.torlauncher.default_bridge.",
+ default_bridge_recommended_type: "extensions.torlauncher.default_bridge_recommended_type",
+ bridgedb_bridge: "extensions.torlauncher.bridgedb_bridge.",
+});
+
+/* Config Keys used to configure tor daemon */
+const TorConfigKeys = Object.freeze({
+ useBridges: "UseBridges",
+ bridgeList: "Bridge",
+ socks4Proxy: "Socks4Proxy",
+ socks5Proxy: "Socks5Proxy",
+ socks5ProxyUsername: "Socks5ProxyUsername",
+ socks5ProxyPassword: "Socks5ProxyPassword",
+ httpsProxy: "HTTPSProxy",
+ httpsProxyAuthenticator: "HTTPSProxyAuthenticator",
+ reachableAddresses: "ReachableAddresses",
+ clientTransportPlugin: "ClientTransportPlugin",
+});
+
+const TorBridgeSource = Object.freeze({
+ Invalid: -1,
+ BuiltIn: 0,
+ BridgeDB: 1,
+ UserProvided: 2,
+});
+
+const TorProxyType = Object.freeze({
+ Invalid: -1,
+ Socks4: 0,
+ Socks5: 1,
+ HTTPS: 2,
+});
+
+
+const TorBuiltinBridgeTypes = Object.freeze(
+ (() => {
+ let bridgeListBranch = Services.prefs.getBranch(TorLauncherPrefs.default_bridge);
+ let bridgePrefs = bridgeListBranch.getChildList("");
+
+ // an unordered set for shoving bridge types into
+ let bridgeTypes = new Set();
+ // look for keys ending in ".N" and treat string before that as the bridge type
+ const pattern = /\.[0-9]+$/;
+ for (const key of bridgePrefs) {
+ const offset = key.search(pattern);
+ if (offset != -1) {
+ const bt = key.substring(0, offset);
+ bridgeTypes.add(bt);
+ }
+ }
+
+ // recommended bridge type goes first in the list
+ let recommendedBridgeType = Services.prefs.getCharPref(TorLauncherPrefs.default_bridge_recommended_type, null);
+
+ let retval = [];
+ if (recommendedBridgeType && bridgeTypes.has(recommendedBridgeType)) {
+ retval.push(recommendedBridgeType);
+ }
+
+ for (const bridgeType of bridgeTypes.values()) {
+ if (bridgeType != recommendedBridgeType) {
+ retval.push(bridgeType);
+ }
+ }
+ return retval;
+ })()
+);
+
+/* Parsing Methods */
+
+// expects a string representation of an integer from 1 to 65535
+let parsePort = function(aPort) {
+ // ensure port string is a valid positive integer
+ const validIntRegex = /^[0-9]+$/;
+ if (!validIntRegex.test(aPort)) {
+ return 0;
+ }
+
+ // ensure port value is on valid range
+ let port = Number.parseInt(aPort);
+ if (port < 1 || port > 65535) {
+ return 0;
+ }
+
+ return port;
+};
+// expects a string in the format: "ADDRESS:PORT"
+let parseAddrPort = function(aAddrColonPort) {
+ let tokens = aAddrColonPort.split(":");
+ if (tokens.length != 2) {
+ return ["", 0];
+ }
+ let address = tokens[0];
+ let port = parsePort(tokens[1]);
+ return [address, port];
+};
+
+// expects a string in the format: "USERNAME:PASSWORD"
+// split on the first colon and any subsequent go into password
+let parseUsernamePassword = function(aUsernameColonPassword) {
+ let colonIndex = aUsernameColonPassword.indexOf(":");
+ if (colonIndex < 0) {
+ return ["", ""];
+ }
+
+ let username = aUsernameColonPassword.substring(0, colonIndex);
+ let password = aUsernameColonPassword.substring(colonIndex + 1);
+
+ return [username, password];
+};
+
+// expects a string in the format: ADDRESS:PORT,ADDRESS:PORT,...
+// returns array of ports (as ints)
+let parseAddrPortList = function(aAddrPortList) {
+ let addrPorts = aAddrPortList.split(",");
+ // parse ADDRESS:PORT string and only keep the port (second element in returned array)
+ let retval = addrPorts.map(addrPort => parseAddrPort(addrPort)[1]);
+ return retval;
+};
+
+// expects a '/n' or '/r/n' delimited bridge string, which we split and trim
+// each bridge string can also optionally have 'bridge' at the beginning ie:
+// bridge $(type) $(address):$(port) $(certificate)
+// we strip out the 'bridge' prefix here
+let parseBridgeStrings = function(aBridgeStrings) {
+
+ // replace carriage returns ('\r') with new lines ('\n')
+ aBridgeStrings = aBridgeStrings.replace(/\r/g, "\n");
+ // then replace contiguous new lines ('\n') with a single one
+ aBridgeStrings = aBridgeStrings.replace(/[\n]+/g, "\n");
+
+ // split on the newline and for each bridge string: trim, remove starting 'bridge' string
+ // finally discard entries that are empty strings; empty strings could occur if we receive
+ // a new line containing only whitespace
+ let splitStrings = aBridgeStrings.split("\n");
+ return splitStrings.map(val => val.trim().replace(/^bridge\s+/i, ""))
+ .filter(bridgeString => bridgeString != "");
+};
+
+// expecting a ',' delimited list of ints with possible white space between
+// returns an array of ints
+let parsePortList = function(aPortListString) {
+ let splitStrings = aPortListString.split(",");
+ // parse and remove duplicates
+ let portSet = new Set(splitStrings.map(val => parsePort(val.trim())));
+ // parsePort returns 0 for failed parses, so remove 0 from list
+ portSet.delete(0);
+ return Array.from(portSet);
+};
+
+let getBuiltinBridgeStrings = function(builtinType) {
+ let bridgeBranch = Services.prefs.getBranch(TorLauncherPrefs.default_bridge);
+ let bridgeBranchPrefs = bridgeBranch.getChildList("");
+ let retval = [];
+
+ // regex matches against strings ending in ".N" where N is a positive integer
+ let pattern = /\.[0-9]+$/;
+ for (const key of bridgeBranchPrefs) {
+ // verify the location of the match is the correct offset required for aBridgeType
+ // to fit, and that the string begins with aBridgeType
+ if (key.search(pattern) == builtinType.length &&
+ key.startsWith(builtinType)) {
+ let bridgeStr = bridgeBranch.getCharPref(key);
+ retval.push(bridgeStr);
+ }
+ }
+
+ // shuffle so that Tor Browser users don't all try the built-in bridges in the same order
+ arrayShuffle(retval);
+
+ return retval;
+};
+
+/* Array methods */
+
+let arrayShuffle = function(array) {
+ // fisher-yates shuffle
+ for (let i = array.length - 1; i > 0; --i) {
+ // number n such that 0.0 <= n < 1.0
+ const n = Math.random();
+ // integer j such that 0 <= j <= i
+ const j = Math.floor(n * (i + 1));
+
+ // swap values at indices i and j
+ const tmp = array[i];
+ array[i] = array[j];
+ array[j] = tmp;
+ }
+}
+
+let arrayCopy = function(array) {
+ return [].concat(array);
+}
+
+/* TorSettings module */
+
+const TorSettings = (() => {
+ let self = {
+ _settings: null,
+
+ // tor daemon related settings
+ defaultSettings: function() {
+ let settings = {
+ quickstart: {
+ enabled: false
+ },
+ bridges : {
+ enabled: false,
+ source: TorBridgeSource.Invalid,
+ builtin_type: null,
+ bridge_strings: [],
+ },
+ proxy: {
+ enabled: false,
+ type: TorProxyType.Invalid,
+ address: null,
+ port: 0,
+ username: null,
+ password: null,
+ },
+ firewall: {
+ enabled: false,
+ allowed_ports: [],
+ },
+ };
+ return settings;
+ },
+
+ /* load or init our settings, and register observers */
+ init: function() {
+ if (TorProtocolService.ownsTorDaemon) {
+ // if the settings branch exists, load settings from prefs
+ if (Services.prefs.getBoolPref(TorSettingsPrefs.enabled, false)) {
+ this.loadFromPrefs();
+ } else {
+ // otherwise load defaults
+ this._settings = this.defaultSettings();
+ }
+ Services.obs.addObserver(this, BrowserTopics.ProfileAfterChange);
+ Services.obs.addObserver(this, TorTopics.ProcessIsReady);
+ }
+ },
+
+ /* wait for relevant life-cycle events to apply saved settings */
+ observe: async function(subject, topic, data) {
+ console.log(`TorSettings: Observed ${topic}`);
+
+ // once the tor daemon is ready, we need to apply our settings
+ let handleProcessReady = async () => {
+ // push down settings to tor
+ await this.applySettings();
+ console.log("TorSettings: Ready");
+ Services.obs.notifyObservers(null, TorSettingsTopics.Ready);
+ };
+
+ switch (topic) {
+ case BrowserTopics.ProfileAfterChange: {
+ Services.obs.removeObserver(this, BrowserTopics.ProfileAfterChange);
+ if (TorProtocolService.torProcessStatus == TorProcessStatus.Running) {
+ await handleProcessReady();
+ }
+ }
+ break;
+ case TorTopics.ProcessIsReady: {
+ Services.obs.removeObserver(this, TorTopics.ProcessIsReady);
+ await handleProcessReady();
+ }
+ break;
+ }
+ },
+
+ // load our settings from prefs
+ loadFromPrefs: function() {
+ console.log("TorSettings: loadFromPrefs()");
+
+ let settings = this.defaultSettings();
+
+ /* Quickstart */
+ settings.quickstart.enabled = Services.prefs.getBoolPref(TorSettingsPrefs.quickstart.enabled);
+ /* Bridges */
+ settings.bridges.enabled = Services.prefs.getBoolPref(TorSettingsPrefs.bridges.enabled);
+ if (settings.bridges.enabled) {
+ settings.bridges.source = Services.prefs.getIntPref(TorSettingsPrefs.bridges.source);
+ // builtin bridge (obfs4, meek, snowlfake, etc)
+ if (settings.bridges.source == TorBridgeSource.BuiltIn) {
+ let builtinType = Services.prefs.getStringPref(TorSettingsPrefs.bridges.builtin_type);
+ settings.bridges.builtin_type = builtinType;
+ // always dynamically load builtin bridges rather than loading the cached versions
+ // if the user upgrades and the builtin bridges have changed, we want to ensure the user
+ // can still bootstrap using the provided bridges
+ let bridgeStrings = getBuiltinBridgeStrings(builtinType);
+ if (bridgeStrings.length > 0) {
+ settings.bridges.bridge_strings = bridgeStrings;
+ } else {
+ // in this case the user is using a builtin bridge that is no longer supported,
+ // reset to settings to default values
+ settings.bridges.enabled = false;
+ settings.bridges.source = TorBridgeSource.Invalid;
+ settings.bridges.builtin_type = null;
+ }
+ } else {
+ settings.bridges.bridge_strings = [];
+ let bridgeBranchPrefs = Services.prefs.getBranch(TorSettingsPrefs.bridges.bridge_strings).getChildList("");
+ bridgeBranchPrefs.forEach(pref => {
+ let bridgeString = Services.prefs.getStringPref(`${TorSettingsPrefs.bridges.bridge_strings}${pref}`);
+ settings.bridges.bridge_strings.push(bridgeString);
+ });
+ }
+ } else {
+ settings.bridges.source = TorBridgeSource.Invalid;
+ settings.bridges.builtin_type = null;
+ settings.bridges.bridge_strings = [];
+ }
+ /* Proxy */
+ settings.proxy.enabled = Services.prefs.getBoolPref(TorSettingsPrefs.proxy.enabled);
+ if (settings.proxy.enabled) {
+ settings.proxy.type = Services.prefs.getIntPref(TorSettingsPrefs.proxy.type);
+ settings.proxy.address = Services.prefs.getStringPref(TorSettingsPrefs.proxy.address);
+ settings.proxy.port = Services.prefs.getIntPref(TorSettingsPrefs.proxy.port);
+ settings.proxy.username = Services.prefs.getStringPref(TorSettingsPrefs.proxy.username);
+ settings.proxy.password = Services.prefs.getStringPref(TorSettingsPrefs.proxy.password);
+ } else {
+ settings.proxy.type = TorProxyType.Invalid;
+ settings.proxy.address = null;
+ settings.proxy.port = 0;
+ settings.proxy.username = null;
+ settings.proxy.password = null;
+ }
+
+ /* Firewall */
+ settings.firewall.enabled = Services.prefs.getBoolPref(TorSettingsPrefs.firewall.enabled);
+ if(settings.firewall.enabled) {
+ let portList = Services.prefs.getStringPref(TorSettingsPrefs.firewall.allowed_ports);
+ settings.firewall.allowed_ports = parsePortList(portList);
+ } else {
+ settings.firewall.allowed_ports = 0;
+ }
+
+ this._settings = settings;
+
+ return this;
+ },
+
+ // save our settings to prefs
+ saveToPrefs: function() {
+ console.log("TorSettings: saveToPrefs()");
+
+ let settings = this._settings;
+
+ /* Quickstart */
+ Services.prefs.setBoolPref(TorSettingsPrefs.quickstart.enabled, settings.quickstart.enabled);
+ /* Bridges */
+ Services.prefs.setBoolPref(TorSettingsPrefs.bridges.enabled, settings.bridges.enabled);
+ if (settings.bridges.enabled) {
+ Services.prefs.setIntPref(TorSettingsPrefs.bridges.source, settings.bridges.source);
+ if (settings.bridges.source === TorBridgeSource.BuiltIn) {
+ Services.prefs.setStringPref(TorSettingsPrefs.bridges.builtin_type, settings.bridges.builtin_type);
+ } else {
+ Services.prefs.clearUserPref(TorSettingsPrefs.bridges.builtin_type);
+ }
+ // erase existing bridge strings
+ let bridgeBranchPrefs = Services.prefs.getBranch(TorSettingsPrefs.bridges.bridge_strings).getChildList("");
+ bridgeBranchPrefs.forEach(pref => {
+ Services.prefs.clearUserPref(`${TorSettingsPrefs.bridges.bridge_strings}${pref}`);
+ });
+ // write new ones
+ settings.bridges.bridge_strings.forEach((string, index) => {
+ Services.prefs.setStringPref(`${TorSettingsPrefs.bridges.bridge_strings}.${index}`, string);
+ });
+ } else {
+ Services.prefs.clearUserPref(TorSettingsPrefs.bridges.source);
+ Services.prefs.clearUserPref(TorSettingsPrefs.bridges.builtin_type);
+ let bridgeBranchPrefs = Services.prefs.getBranch(TorSettingsPrefs.bridges.bridge_strings).getChildList("");
+ bridgeBranchPrefs.forEach(pref => {
+ Services.prefs.clearUserPref(`${TorSettingsPrefs.bridges.bridge_strings}${pref}`);
+ });
+ }
+ /* Proxy */
+ Services.prefs.setBoolPref(TorSettingsPrefs.proxy.enabled, settings.proxy.enabled);
+ if (settings.proxy.enabled) {
+ Services.prefs.setIntPref(TorSettingsPrefs.proxy.type, settings.proxy.type);
+ Services.prefs.setStringPref(TorSettingsPrefs.proxy.address, settings.proxy.address);
+ Services.prefs.setIntPref(TorSettingsPrefs.proxy.port, settings.proxy.port);
+ Services.prefs.setStringPref(TorSettingsPrefs.proxy.username, settings.proxy.username);
+ Services.prefs.setStringPref(TorSettingsPrefs.proxy.password, settings.proxy.password);
+ } else {
+ Services.prefs.clearUserPref(TorSettingsPrefs.proxy.type);
+ Services.prefs.clearUserPref(TorSettingsPrefs.proxy.address);
+ Services.prefs.clearUserPref(TorSettingsPrefs.proxy.port);
+ Services.prefs.clearUserPref(TorSettingsPrefs.proxy.username);
+ Services.prefs.clearUserPref(TorSettingsPrefs.proxy.password);
+ }
+ /* Firewall */
+ Services.prefs.setBoolPref(TorSettingsPrefs.firewall.enabled, settings.firewall.enabled);
+ if (settings.firewall.enabled) {
+ Services.prefs.setStringPref(TorSettingsPrefs.firewall.allowed_ports, settings.firewall.allowed_ports.join(","));
+ } else {
+ Services.prefs.clearUserPref(TorSettingsPrefs.firewall.allowed_ports);
+ }
+
+ // all tor settings now stored in prefs :)
+ Services.prefs.setBoolPref(TorSettingsPrefs.enabled, true);
+
+ return this;
+ },
+
+ // push our settings down to the tor daemon
+ applySettings: async function() {
+ console.log("TorSettings: applySettings()");
+ let settings = this._settings;
+ let settingsMap = new Map();
+
+ /* Bridges */
+ settingsMap.set(TorConfigKeys.useBridges, settings.bridges.enabled);
+ if (settings.bridges.enabled) {
+ settingsMap.set(TorConfigKeys.bridgeList, settings.bridges.bridge_strings);
+ } else {
+ // shuffle bridge list
+ settingsMap.set(TorConfigKeys.bridgeList, null);
+ }
+
+ /* Proxy */
+ settingsMap.set(TorConfigKeys.socks4Proxy, null);
+ settingsMap.set(TorConfigKeys.socks5Proxy, null);
+ settingsMap.set(TorConfigKeys.socks5ProxyUsername, null);
+ settingsMap.set(TorConfigKeys.socks5ProxyPassword, null);
+ settingsMap.set(TorConfigKeys.httpsProxy, null);
+ settingsMap.set(TorConfigKeys.httpsProxyAuthenticator, null);
+ if (settings.proxy.enabled) {
+ let address = settings.proxy.address;
+ let port = settings.proxy.port;
+ let username = settings.proxy.username;
+ let password = settings.proxy.password;
+
+ switch (settings.proxy.type) {
+ case TorProxyType.Socks4:
+ settingsMap.set(TorConfigKeys.socks4Proxy, `${address}:${port}`);
+ break;
+ case TorProxyType.Socks5:
+ settingsMap.set(TorConfigKeys.socks5Proxy, `${address}:${port}`);
+ settingsMap.set(TorConfigKeys.socks5ProxyUsername, username);
+ settingsMap.set(TorConfigKeys.socks5ProxyPassword, password);
+ break;
+ case TorProxyType.HTTPS:
+ settingsMap.set(TorConfigKeys.httpsProxy, `${address}:${port}`);
+ settingsMap.set(TorConfigKeys.httpsProxyAuthenticator, `${username}:${password}`);
+ break;
+ }
+ }
+
+ /* Firewall */
+ if (settings.firewall.enabled) {
+ let reachableAddresses = settings.firewall.allowed_ports.map(port => `*:${port}`).join(",");
+ settingsMap.set(TorConfigKeys.reachableAddresses, reachableAddresses);
+ } else {
+ settingsMap.set(TorConfigKeys.reachableAddresses, null);
+ }
+
+ /* Push to Tor */
+ await TorProtocolService.writeSettings(settingsMap);
+
+ return this;
+ },
+
+ // set all of our settings at once from a settings object
+ setSettings: function(settings) {
+ console.log("TorSettings: setSettings()");
+ let backup = this.getSettings();
+
+ try {
+ if (settings.bridges.enabled) {
+ this._settings.bridges.enabled = true;
+ this._settings.bridges.source = settings.bridges.source;
+ switch(settings.bridges.source) {
+ case TorBridgeSource.BridgeDB:
+ case TorBridgeSource.UserProvided:
+ this._settings.bridges.bridge_strings = settings.bridges.bridge_strings
+ break;
+ case TorBridgeSource.BuiltIn: {
+ this._settings.bridges.builtin_type = settings.bridges.builtin_type;
+ let bridgeStrings = getBuiltinBridgeStrings(settings.bridges.builtin_type);
+ if (bridgeStrings.length > 0) {
+ this._settings.bridges.bridge_strings = bridgeStrings;
+ } else {
+ throw new Error(`No available builtin bridges of type ${settings.bridges.builtin_type}`);
+ }
+ break;
+ }
+ default:
+ throw new Error(`Bridge source '${settings.source}' is not a valid source`);
+ }
+ } else {
+ this.bridges.enabled = false;
+ }
+
+ // TODO: proxy and firewall
+ } catch(ex) {
+ this._settings = backup;
+ console.log(`TorSettings: setSettings failed => ${ex.message}`);
+ }
+
+ console.log("TorSettings: setSettings result");
+ console.log(this._settings);
+ },
+
+ // get a copy of all our settings
+ getSettings: function() {
+ console.log("TorSettings: getSettings()");
+ // TODO: replace with structuredClone someday (post esr94): https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
+ return JSON.parse(JSON.stringify(this._settings));
+ },
+
+ /* Getters and Setters */
+
+ // Quickstart
+ get quickstart() {
+ return {
+ get enabled() { return self._settings.quickstart.enabled; },
+ set enabled(val) {
+ if (val != self._settings.quickstart.enabled)
+ {
+ self._settings.quickstart.enabled = val;
+ Services.obs.notifyObservers({value: val}, TorSettingsTopics.SettingChanged, TorSettingsData.QuickStartEnabled);
+ }
+ },
+ };
+ },
+
+ // Bridges
+ get bridges() {
+ return {
+ get enabled() { return self._settings.bridges.enabled; },
+ set enabled(val) {
+ self._settings.bridges.enabled = val;
+ // reset bridge settings
+ self._settings.bridges.source = TorBridgeSource.Invalid;
+ self._settings.bridges.builtin_type = null;
+ self._settings.bridges.bridge_strings = [];
+ },
+ get source() { return self._settings.bridges.source; },
+ set source(val) { self._settings.bridges.source = val; },
+ get builtin_type() { return self._settings.bridges.builtin_type; },
+ set builtin_type(val) {
+ let bridgeStrings = getBuiltinBridgeStrings(val);
+ if (bridgeStrings.length > 0) {
+ self._settings.bridges.builtin_type = val;
+ self._settings.bridges.bridge_strings = bridgeStrings;
+ }
+ },
+ get bridge_strings() { return arrayCopy(self._settings.bridges.bridge_strings); },
+ set bridge_strings(val) {
+ self._settings.bridges.bridge_strings = parseBridgeStrings(val);
+ },
+ };
+ },
+
+ // Proxy
+ get proxy() {
+ return {
+ get enabled() { return self._settings.proxy.enabled; },
+ set enabled(val) {
+ self._settings.proxy.enabled = val;
+ // reset proxy settings
+ self._settings.proxy.type = TorProxyType.Invalid;
+ self._settings.proxy.address = null;
+ self._settings.proxy.port = 0;
+ self._settings.proxy.username = null;
+ self._settings.proxy.password = null;
+ },
+ get type() { return self._settings.proxy.type; },
+ set type(val) { self._settings.proxy.type = val; },
+ get address() { return self._settings.proxy.address; },
+ set address(val) { self._settings.proxy.address = val; },
+ get port() { return arrayCopy(self._settings.proxy.port); },
+ set port(val) { self._settings.proxy.port = parsePort(val); },
+ get username() { return self._settings.proxy.username; },
+ set username(val) { self._settings.proxy.username = val; },
+ get password() { return self._settings.proxy.password; },
+ set password(val) { self._settings.proxy.password = val; },
+ get uri() {
+ switch (this.type) {
+ case TorProxyType.Socks4:
+ return `socks4a://${this.address}:${this.port}`;
+ case TorProxyType.Socks5:
+ if (this.username) {
+ return `socks5://${this.username}:${this.password}@${this.address}:${this.port}`;
+ }
+ return `socks5://${this.address}:${this.port}`;
+ case TorProxyType.HTTPS:
+ if (this._proxyUsername) {
+ return `http://${this.username}:${this.password}@${this.address}:${this.port}`;
+ }
+ return `http://${this.address}:${this.port}`;
+ }
+ return null;
+ },
+ };
+ },
+
+ // Firewall
+ get firewall() {
+ return {
+ get enabled() { return self._settings.firewall.enabled; },
+ set enabled(val) {
+ self._settings.firewall.enabled = val;
+ // reset firewall settings
+ self._settings.firewall.allowed_ports = [];
+ },
+ get allowed_ports() { return self._settings.firewall.allowed_ports; },
+ set allowed_ports(val) { self._settings.firewall.allowed_ports = parsePortList(val); },
+ };
+ },
+ };
+ self.init();
+ return self;
+})();
diff --git a/browser/modules/moz.build b/browser/modules/moz.build
index b069f1b641f7..646784690c9a 100644
--- a/browser/modules/moz.build
+++ b/browser/modules/moz.build
@@ -128,6 +128,7 @@ EXTRA_JS_MODULES += [
"AboutNewTab.jsm",
"AppUpdater.jsm",
"AsyncTabSwitcher.jsm",
+ "BridgeDB.jsm",
"BrowserUIUtils.jsm",
"BrowserUsageTelemetry.jsm",
"BrowserWindowTracker.jsm",
@@ -138,6 +139,7 @@ EXTRA_JS_MODULES += [
"FaviconLoader.jsm",
"HomePage.jsm",
"LaterRun.jsm",
+ 'Moat.jsm',
"NewTabPagePreloading.jsm",
"OpenInTabsUtils.jsm",
"PageActions.jsm",
@@ -152,6 +154,8 @@ EXTRA_JS_MODULES += [
"TabsList.jsm",
"TabUnloader.jsm",
"ThemeVariableMap.jsm",
+ "TorProtocolService.jsm",
+ "TorSettings.jsm",
"TransientPrefs.jsm",
"webrtcUI.jsm",
"ZoomUI.jsm",
diff --git a/toolkit/components/processsingleton/MainProcessSingleton.jsm b/toolkit/components/processsingleton/MainProcessSingleton.jsm
index ecdbf2a01d99..7bde782e54ce 100644
--- a/toolkit/components/processsingleton/MainProcessSingleton.jsm
+++ b/toolkit/components/processsingleton/MainProcessSingleton.jsm
@@ -24,6 +24,11 @@ MainProcessSingleton.prototype = {
null
);
+ ChromeUtils.import(
+ "resource:///modules/TorSettings.jsm",
+ null
+ );
+
Services.ppmm.loadProcessScript(
"chrome://global/content/process-content.js",
true
1
0

[tor-browser/tor-browser-91.5.0esr-11.5-2] Omnibox: Add DDG, Startpage, Disconnect, Youtube, Twitter; remove Amazon, eBay, bing
by richard@torproject.org 01 Feb '22
by richard@torproject.org 01 Feb '22
01 Feb '22
commit 508978428ddd7342b11a1682452f053e8ceff8b0
Author: Mike Perry <mikeperry-git(a)torproject.org>
Date: Fri May 5 03:41:57 2017 -0700
Omnibox: Add DDG, Startpage, Disconnect, Youtube, Twitter; remove Amazon, eBay, bing
eBay and Amazon don't treat Tor users very well. Accounts often get locked and
payments reversed.
Also:
Bug 16322: Update DuckDuckGo search engine
We are replacing the clearnet URL with an onion service one (thanks to a
patch by a cypherpunk) and are removing the duplicated DDG search
engine. Duplicating DDG happend due to bug 1061736 where Mozilla
included DDG itself into Firefox. Interestingly, this caused breaking
the DDG search if JavaScript is disabled as the Mozilla engine, which
gets loaded earlier, does not use the html version of the search page.
Moreover, the Mozilla engine tracked where the users were searching from
by adding a respective parameter to the search query. We got rid of that
feature as well.
Also:
This fixes bug 20809: the DuckDuckGo team has changed its server-side
code in a way that lets users with JavaScript enabled use the default
landing page while those without JavaScript available get redirected
directly to the non-JS page. We adapt the search engine URLs
accordingly.
Also fixes bug 29798 by making sure we only specify the Google search
engine we actually ship an .xml file for.
Also regression tests.
squash! Omnibox: Add DDG, Startpage, Disconnect, Youtube, Twitter; remove Amazon, eBay, bing
Bug 40494: Update Startpage search provider
squash! Omnibox: Add DDG, Startpage, Disconnect, Youtube, Twitter; remove Amazon, eBay, bing
Bug 40438: Add Blockchair as a search engine
Bug 33342: Avoid disconnect search addon error after removal.
We removed the addon in #32767, but it was still being loaded
from addonStartup.json.lz4 and throwing an error on startup
because its resource: location is not available anymore.
---
.../search/extensions/blockchair-onion/favicon.png | Bin 0 -> 3116 bytes
.../extensions/blockchair-onion/manifest.json | 26 ++++++++++++++
.../search/extensions/blockchair/favicon.png | Bin 0 -> 2898 bytes
.../search/extensions/blockchair/manifest.json | 26 ++++++++++++++
.../search/extensions/ddg-onion/favicon.ico | Bin 0 -> 973 bytes
.../search/extensions/ddg-onion/manifest.json | 26 ++++++++++++++
.../components/search/extensions/ddg/favicon.ico | Bin 5430 -> 0 bytes
.../components/search/extensions/ddg/favicon.png | Bin 0 -> 1150 bytes
.../components/search/extensions/ddg/manifest.json | 38 ++-------------------
.../extensions/google/_locales/b-1-d/messages.json | 23 -------------
.../extensions/google/_locales/b-1-e/messages.json | 23 -------------
.../extensions/google/_locales/b-d/messages.json | 23 -------------
.../extensions/google/_locales/b-e/messages.json | 23 -------------
.../extensions/google/_locales/en/messages.json | 24 -------------
.../search/extensions/google/manifest.json | 17 +++++----
.../search/extensions/startpage/favicon.png | Bin 0 -> 1150 bytes
.../search/extensions/startpage/manifest.json | 26 ++++++++++++++
.../search/extensions/twitter/favicon.ico | Bin 0 -> 1650 bytes
.../search/extensions/twitter/manifest.json | 26 ++++++++++++++
.../extensions/wikipedia/_locales/NN/messages.json | 20 -----------
.../extensions/wikipedia/_locales/NO/messages.json | 20 -----------
.../extensions/wikipedia/_locales/af/messages.json | 20 -----------
.../extensions/wikipedia/_locales/an/messages.json | 20 -----------
.../extensions/wikipedia/_locales/ar/messages.json | 20 -----------
.../wikipedia/_locales/ast/messages.json | 20 -----------
.../extensions/wikipedia/_locales/az/messages.json | 20 -----------
.../wikipedia/_locales/be-tarask/messages.json | 20 -----------
.../extensions/wikipedia/_locales/be/messages.json | 20 -----------
.../extensions/wikipedia/_locales/bg/messages.json | 20 -----------
.../extensions/wikipedia/_locales/bn/messages.json | 20 -----------
.../extensions/wikipedia/_locales/br/messages.json | 20 -----------
.../extensions/wikipedia/_locales/bs/messages.json | 20 -----------
.../extensions/wikipedia/_locales/ca/messages.json | 20 -----------
.../extensions/wikipedia/_locales/cy/messages.json | 20 -----------
.../extensions/wikipedia/_locales/cz/messages.json | 20 -----------
.../extensions/wikipedia/_locales/da/messages.json | 20 -----------
.../extensions/wikipedia/_locales/de/messages.json | 20 -----------
.../wikipedia/_locales/dsb/messages.json | 20 -----------
.../extensions/wikipedia/_locales/el/messages.json | 20 -----------
.../extensions/wikipedia/_locales/en/messages.json | 20 -----------
.../extensions/wikipedia/_locales/eo/messages.json | 20 -----------
.../extensions/wikipedia/_locales/es/messages.json | 20 -----------
.../extensions/wikipedia/_locales/et/messages.json | 20 -----------
.../extensions/wikipedia/_locales/eu/messages.json | 20 -----------
.../extensions/wikipedia/_locales/fa/messages.json | 20 -----------
.../extensions/wikipedia/_locales/fi/messages.json | 20 -----------
.../extensions/wikipedia/_locales/fr/messages.json | 20 -----------
.../wikipedia/_locales/fy-NL/messages.json | 20 -----------
.../wikipedia/_locales/ga-IE/messages.json | 20 -----------
.../extensions/wikipedia/_locales/gd/messages.json | 20 -----------
.../extensions/wikipedia/_locales/gl/messages.json | 20 -----------
.../extensions/wikipedia/_locales/gn/messages.json | 20 -----------
.../extensions/wikipedia/_locales/gu/messages.json | 20 -----------
.../extensions/wikipedia/_locales/he/messages.json | 20 -----------
.../extensions/wikipedia/_locales/hi/messages.json | 20 -----------
.../extensions/wikipedia/_locales/hr/messages.json | 20 -----------
.../wikipedia/_locales/hsb/messages.json | 20 -----------
.../extensions/wikipedia/_locales/hu/messages.json | 20 -----------
.../extensions/wikipedia/_locales/hy/messages.json | 20 -----------
.../extensions/wikipedia/_locales/ia/messages.json | 20 -----------
.../extensions/wikipedia/_locales/id/messages.json | 20 -----------
.../extensions/wikipedia/_locales/is/messages.json | 20 -----------
.../extensions/wikipedia/_locales/it/messages.json | 20 -----------
.../extensions/wikipedia/_locales/ja/messages.json | 20 -----------
.../extensions/wikipedia/_locales/ka/messages.json | 20 -----------
.../wikipedia/_locales/kab/messages.json | 20 -----------
.../extensions/wikipedia/_locales/kk/messages.json | 20 -----------
.../extensions/wikipedia/_locales/km/messages.json | 20 -----------
.../extensions/wikipedia/_locales/kn/messages.json | 20 -----------
.../extensions/wikipedia/_locales/kr/messages.json | 20 -----------
.../wikipedia/_locales/lij/messages.json | 20 -----------
.../extensions/wikipedia/_locales/lo/messages.json | 20 -----------
.../extensions/wikipedia/_locales/lt/messages.json | 20 -----------
.../wikipedia/_locales/ltg/messages.json | 20 -----------
.../extensions/wikipedia/_locales/lv/messages.json | 20 -----------
.../extensions/wikipedia/_locales/mk/messages.json | 20 -----------
.../extensions/wikipedia/_locales/mr/messages.json | 20 -----------
.../extensions/wikipedia/_locales/ms/messages.json | 20 -----------
.../extensions/wikipedia/_locales/my/messages.json | 20 -----------
.../extensions/wikipedia/_locales/ne/messages.json | 20 -----------
.../extensions/wikipedia/_locales/nl/messages.json | 20 -----------
.../extensions/wikipedia/_locales/oc/messages.json | 20 -----------
.../extensions/wikipedia/_locales/pa/messages.json | 20 -----------
.../extensions/wikipedia/_locales/pl/messages.json | 20 -----------
.../extensions/wikipedia/_locales/pt/messages.json | 20 -----------
.../extensions/wikipedia/_locales/rm/messages.json | 20 -----------
.../extensions/wikipedia/_locales/ro/messages.json | 20 -----------
.../extensions/wikipedia/_locales/ru/messages.json | 20 -----------
.../extensions/wikipedia/_locales/si/messages.json | 20 -----------
.../extensions/wikipedia/_locales/sk/messages.json | 20 -----------
.../extensions/wikipedia/_locales/sl/messages.json | 20 -----------
.../extensions/wikipedia/_locales/sq/messages.json | 20 -----------
.../extensions/wikipedia/_locales/sr/messages.json | 20 -----------
.../wikipedia/_locales/sv-SE/messages.json | 20 -----------
.../extensions/wikipedia/_locales/ta/messages.json | 20 -----------
.../extensions/wikipedia/_locales/te/messages.json | 20 -----------
.../extensions/wikipedia/_locales/th/messages.json | 20 -----------
.../extensions/wikipedia/_locales/tl/messages.json | 20 -----------
.../extensions/wikipedia/_locales/tr/messages.json | 20 -----------
.../extensions/wikipedia/_locales/uk/messages.json | 20 -----------
.../extensions/wikipedia/_locales/ur/messages.json | 20 -----------
.../extensions/wikipedia/_locales/uz/messages.json | 20 -----------
.../extensions/wikipedia/_locales/vi/messages.json | 20 -----------
.../extensions/wikipedia/_locales/wo/messages.json | 20 -----------
.../wikipedia/_locales/zh-CN/messages.json | 20 -----------
.../wikipedia/_locales/zh-TW/messages.json | 20 -----------
.../search/extensions/wikipedia/manifest.json | 15 ++++----
.../components/search/extensions/yahoo/favicon.ico | Bin 0 -> 5430 bytes
.../search/extensions/yahoo/manifest.json | 28 +++++++++++++++
.../search/extensions/youtube/favicon.ico | Bin 0 -> 1150 bytes
.../search/extensions/youtube/manifest.json | 26 ++++++++++++++
tbb-tests/browser_tor_omnibox.js | 20 +++++++++++
toolkit/components/search/SearchService.jsm | 30 +++++++---------
.../mozapps/extensions/internal/XPIProvider.jsm | 6 ++++
114 files changed, 241 insertions(+), 1925 deletions(-)
diff --git a/browser/components/search/extensions/blockchair-onion/favicon.png b/browser/components/search/extensions/blockchair-onion/favicon.png
new file mode 100644
index 000000000000..92d832ded172
Binary files /dev/null and b/browser/components/search/extensions/blockchair-onion/favicon.png differ
diff --git a/browser/components/search/extensions/blockchair-onion/manifest.json b/browser/components/search/extensions/blockchair-onion/manifest.json
new file mode 100644
index 000000000000..e7d15ee50247
--- /dev/null
+++ b/browser/components/search/extensions/blockchair-onion/manifest.json
@@ -0,0 +1,26 @@
+{
+ "name": "BlockchairOnion",
+ "description": "Blockchair Onion",
+ "manifest_version": 2,
+ "version": "1.0",
+ "applications": {
+ "gecko": {
+ "id": "blockchair-onion(a)search.mozilla.org"
+ }
+ },
+ "hidden": true,
+ "icons": {
+ "16": "favicon.png"
+ },
+ "web_accessible_resources": [
+ "favicon.png"
+ ],
+ "chrome_settings_overrides": {
+ "search_provider": {
+ "name": "BlockchairOnion",
+ "search_url": "http://blkchairbknpn73cfjhevhla7rkp4ed5gg2knctvv7it4lioy22defid.onion/search",
+ "search_form": "http://blkchairbknpn73cfjhevhla7rkp4ed5gg2knctvv7it4lioy22defid.onion/searc…",
+ "search_url_post_params": "q={searchTerms}"
+ }
+ }
+}
diff --git a/browser/components/search/extensions/blockchair/favicon.png b/browser/components/search/extensions/blockchair/favicon.png
new file mode 100644
index 000000000000..f4869e87e008
Binary files /dev/null and b/browser/components/search/extensions/blockchair/favicon.png differ
diff --git a/browser/components/search/extensions/blockchair/manifest.json b/browser/components/search/extensions/blockchair/manifest.json
new file mode 100644
index 000000000000..0f16b9049cf2
--- /dev/null
+++ b/browser/components/search/extensions/blockchair/manifest.json
@@ -0,0 +1,26 @@
+{
+ "name": "Blockchair",
+ "description": "Blockchair",
+ "manifest_version": 2,
+ "version": "1.0",
+ "applications": {
+ "gecko": {
+ "id": "blockchair(a)search.mozilla.org"
+ }
+ },
+ "hidden": true,
+ "icons": {
+ "16": "favicon.png"
+ },
+ "web_accessible_resources": [
+ "favicon.png"
+ ],
+ "chrome_settings_overrides": {
+ "search_provider": {
+ "name": "Blockchair",
+ "search_url": "https://blockchair.com/search",
+ "search_form": "https://blockchair.com/search/?q={searchTerms}",
+ "search_url_get_params": "q={searchTerms}"
+ }
+ }
+}
diff --git a/browser/components/search/extensions/ddg-onion/favicon.ico b/browser/components/search/extensions/ddg-onion/favicon.ico
new file mode 100644
index 000000000000..13c325f6585f
Binary files /dev/null and b/browser/components/search/extensions/ddg-onion/favicon.ico differ
diff --git a/browser/components/search/extensions/ddg-onion/manifest.json b/browser/components/search/extensions/ddg-onion/manifest.json
new file mode 100644
index 000000000000..49f3c116106b
--- /dev/null
+++ b/browser/components/search/extensions/ddg-onion/manifest.json
@@ -0,0 +1,26 @@
+{
+ "name": "DuckDuckGoOnion",
+ "description": "Duck Duck Go Onion",
+ "manifest_version": 2,
+ "version": "1.0",
+ "applications": {
+ "gecko": {
+ "id": "ddg-onion(a)search.mozilla.org"
+ }
+ },
+ "hidden": true,
+ "icons": {
+ "16": "favicon.ico"
+ },
+ "web_accessible_resources": [
+ "favicon.ico"
+ ],
+ "chrome_settings_overrides": {
+ "search_provider": {
+ "name": "DuckDuckGoOnion",
+ "search_url": "https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion",
+ "search_form": "https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/?q={…",
+ "search_url_get_params": "q={searchTerms}"
+ }
+ }
+}
diff --git a/browser/components/search/extensions/ddg/favicon.ico b/browser/components/search/extensions/ddg/favicon.ico
deleted file mode 100644
index 560000b03e2c..000000000000
Binary files a/browser/components/search/extensions/ddg/favicon.ico and /dev/null differ
diff --git a/browser/components/search/extensions/ddg/favicon.png b/browser/components/search/extensions/ddg/favicon.png
new file mode 100644
index 000000000000..c853b95b89ef
Binary files /dev/null and b/browser/components/search/extensions/ddg/favicon.png differ
diff --git a/browser/components/search/extensions/ddg/manifest.json b/browser/components/search/extensions/ddg/manifest.json
index 782b860a679f..4a3b0ad20fe9 100644
--- a/browser/components/search/extensions/ddg/manifest.json
+++ b/browser/components/search/extensions/ddg/manifest.json
@@ -10,50 +10,18 @@
},
"hidden": true,
"icons": {
- "16": "favicon.ico"
+ "16": "favicon.png"
},
"web_accessible_resources": [
- "favicon.ico"
+ "favicon.png"
],
"chrome_settings_overrides": {
"search_provider": {
"keyword": ["@duckduckgo", "@ddg"],
"name": "DuckDuckGo",
- "search_url": "https://duckduckgo.com/",
+ "search_url": "https://duckduckgo.com",
"search_form": "https://duckduckgo.com/?q={searchTerms}",
"search_url_get_params": "q={searchTerms}",
- "params": [
- {
- "name": "t",
- "condition": "purpose",
- "purpose": "contextmenu",
- "value": "ffcm"
- },
- {
- "name": "t",
- "condition": "purpose",
- "purpose": "keyword",
- "value": "ffab"
- },
- {
- "name": "t",
- "condition": "purpose",
- "purpose": "searchbar",
- "value": "ffsb"
- },
- {
- "name": "t",
- "condition": "purpose",
- "purpose": "homepage",
- "value": "ffhp"
- },
- {
- "name": "t",
- "condition": "purpose",
- "purpose": "newtab",
- "value": "ffnt"
- }
- ],
"suggest_url": "https://ac.duckduckgo.com/ac/",
"suggest_url_get_params": "q={searchTerms}&type=list"
}
diff --git a/browser/components/search/extensions/google/_locales/b-1-d/messages.json b/browser/components/search/extensions/google/_locales/b-1-d/messages.json
deleted file mode 100644
index 1b9d05307d64..000000000000
--- a/browser/components/search/extensions/google/_locales/b-1-d/messages.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "extensionName": {
- "message": "Google"
- },
- "extensionDescription": {
- "message": "Google Search"
- },
- "searchUrl": {
- "message": "https://www.google.com/search"
- },
- "searchForm": {
- "message": "https://www.google.com/search?client=firefox-b-1-d&q={searchTerms}"
- },
- "suggestUrl": {
- "message": "https://www.google.com/complete/search?client=firefox&q={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "client=firefox-b-1-d&q={searchTerms}"
- },
- "channelPref": {
- "message": "google_channel_us"
- }
-}
diff --git a/browser/components/search/extensions/google/_locales/b-1-e/messages.json b/browser/components/search/extensions/google/_locales/b-1-e/messages.json
deleted file mode 100644
index b470cd844331..000000000000
--- a/browser/components/search/extensions/google/_locales/b-1-e/messages.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "extensionName": {
- "message": "Google"
- },
- "extensionDescription": {
- "message": "Google Search"
- },
- "searchUrl": {
- "message": "https://www.google.com/search"
- },
- "searchForm": {
- "message": "https://www.google.com/search?client=firefox-b-1-e&q={searchTerms}"
- },
- "suggestUrl": {
- "message": "https://www.google.com/complete/search?client=firefox&q={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "client=firefox-b-1-e&q={searchTerms}"
- },
- "channelPref": {
- "message": "google_channel_us"
- }
-}
diff --git a/browser/components/search/extensions/google/_locales/b-d/messages.json b/browser/components/search/extensions/google/_locales/b-d/messages.json
deleted file mode 100644
index a6423089d9f9..000000000000
--- a/browser/components/search/extensions/google/_locales/b-d/messages.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "extensionName": {
- "message": "Google"
- },
- "extensionDescription": {
- "message": "Google Search"
- },
- "searchUrl": {
- "message": "https://www.google.com/search"
- },
- "searchForm": {
- "message": "https://www.google.com/search?client=firefox-b-d&q={searchTerms}"
- },
- "suggestUrl": {
- "message": "https://www.google.com/complete/search?client=firefox&q={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "client=firefox-b-d&q={searchTerms}"
- },
- "channelPref": {
- "message": "google_channel_row"
- }
-}
diff --git a/browser/components/search/extensions/google/_locales/b-e/messages.json b/browser/components/search/extensions/google/_locales/b-e/messages.json
deleted file mode 100644
index 70939ee00074..000000000000
--- a/browser/components/search/extensions/google/_locales/b-e/messages.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "extensionName": {
- "message": "Google"
- },
- "extensionDescription": {
- "message": "Google Search"
- },
- "searchUrl": {
- "message": "https://www.google.com/search"
- },
- "searchForm": {
- "message": "https://www.google.com/search?client=firefox-b-e&q={searchTerms}"
- },
- "suggestUrl": {
- "message": "https://www.google.com/complete/search?client=firefox&q={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "client=firefox-b-e&q={searchTerms}"
- },
- "channelPref": {
- "message": "google_channel_row"
- }
-}
diff --git a/browser/components/search/extensions/google/_locales/en/messages.json b/browser/components/search/extensions/google/_locales/en/messages.json
deleted file mode 100644
index aeca0ef128b3..000000000000
--- a/browser/components/search/extensions/google/_locales/en/messages.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "extensionName": {
- "message": "Google"
- },
- "extensionDescription": {
- "message": "Google Search"
- },
- "searchUrl": {
- "message": "https://www.google.com/search"
- },
- "searchForm": {
- "message": "https://www.google.com/search?client=firefox-b-d&q={searchTerms}"
- },
- "suggestUrl": {
- "message": "https://www.google.com/complete/search?client=firefox&q={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "client=firefox-b-d&q={searchTerms}"
- },
- "channelPref": {
- "message": "google_channel_row"
- }
-
-}
diff --git a/browser/components/search/extensions/google/manifest.json b/browser/components/search/extensions/google/manifest.json
index d62049705ae2..965940517ba4 100644
--- a/browser/components/search/extensions/google/manifest.json
+++ b/browser/components/search/extensions/google/manifest.json
@@ -1,6 +1,6 @@
{
- "name": "__MSG_extensionName__",
- "description": "__MSG_extensionDescription__",
+ "name": "Google",
+ "description": "Google Search",
"manifest_version": 2,
"version": "1.1",
"applications": {
@@ -9,7 +9,6 @@
}
},
"hidden": true,
- "default_locale": "en",
"icons": {
"16": "favicon.ico"
},
@@ -19,18 +18,18 @@
"chrome_settings_overrides": {
"search_provider": {
"keyword": "@google",
- "name": "__MSG_extensionName__",
- "search_url": "__MSG_searchUrl__",
- "search_form": "__MSG_searchForm__",
- "suggest_url": "__MSG_suggestUrl__",
+ "name": "Google",
+ "search_url": "https://www.google.com/search",
+ "search_form": "https://www.google.com/search?client=firefox-b-d&q={searchTerms}",
+ "suggest_url": "https://www.google.com/complete/search?client=firefox&q={searchTerms}",
"params": [
{
"name": "channel",
"condition": "pref",
- "pref": "__MSG_channelPref__"
+ "pref": "google_channel_row"
}
],
- "search_url_get_params": "__MSG_searchUrlGetParams__"
+ "search_url_get_params": "client=firefox-b-d&q={searchTerms}"
}
}
}
diff --git a/browser/components/search/extensions/startpage/favicon.png b/browser/components/search/extensions/startpage/favicon.png
new file mode 100644
index 000000000000..44b94a986fd2
Binary files /dev/null and b/browser/components/search/extensions/startpage/favicon.png differ
diff --git a/browser/components/search/extensions/startpage/manifest.json b/browser/components/search/extensions/startpage/manifest.json
new file mode 100644
index 000000000000..18041d3a2f83
--- /dev/null
+++ b/browser/components/search/extensions/startpage/manifest.json
@@ -0,0 +1,26 @@
+{
+ "name": "Startpage",
+ "description": "Start Page",
+ "manifest_version": 2,
+ "version": "1.0",
+ "applications": {
+ "gecko": {
+ "id": "startpage(a)search.mozilla.org"
+ }
+ },
+ "hidden": true,
+ "icons": {
+ "16": "favicon.png"
+ },
+ "web_accessible_resources": [
+ "favicon.png"
+ ],
+ "chrome_settings_overrides": {
+ "search_provider": {
+ "name": "Startpage",
+ "search_url": "https://startpage.com/sp/search",
+ "search_form": "https://startpage.com/sp/search/",
+ "search_url_post_params": "q={searchTerms}&segment=startpage.tor"
+ }
+ }
+}
diff --git a/browser/components/search/extensions/twitter/favicon.ico b/browser/components/search/extensions/twitter/favicon.ico
new file mode 100644
index 000000000000..e5aaff437912
Binary files /dev/null and b/browser/components/search/extensions/twitter/favicon.ico differ
diff --git a/browser/components/search/extensions/twitter/manifest.json b/browser/components/search/extensions/twitter/manifest.json
new file mode 100644
index 000000000000..59714e0e1045
--- /dev/null
+++ b/browser/components/search/extensions/twitter/manifest.json
@@ -0,0 +1,26 @@
+{
+ "name": "Twitter",
+ "description": "Realtime Twitter Search",
+ "manifest_version": 2,
+ "version": "1.0",
+ "applications": {
+ "gecko": {
+ "id": "twitter(a)search.mozilla.org"
+ }
+ },
+ "hidden": true,
+ "icons": {
+ "16": "favicon.ico"
+ },
+ "web_accessible_resources": [
+ "favicon.ico"
+ ],
+ "chrome_settings_overrides": {
+ "search_provider": {
+ "name": "Twitter",
+ "search_url": "https://twitter.com/search",
+ "search_form": "https://twitter.com/search?q={searchTerms}&partner=Firefox&source=desktop-s…",
+ "search_url_get_params": "q={searchTerms}&partner=Firefox&source=desktop-search"
+ }
+ }
+}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/NN/messages.json b/browser/components/search/extensions/wikipedia/_locales/NN/messages.json
deleted file mode 100644
index e4ee66bc780d..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/NN/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (nn)"
- },
- "extensionDescription": {
- "message": "Wikipedia, det frie oppslagsverket"
- },
- "searchUrl": {
- "message": "https://nn.wikipedia.org/wiki/Spesial:Søk"
- },
- "searchForm": {
- "message": "https://nn.wikipedia.org/wiki/Spesial:Søk?search={searchTerms}&sourceid=Moz…"
- },
- "suggestUrl": {
- "message": "https://nn.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/NO/messages.json b/browser/components/search/extensions/wikipedia/_locales/NO/messages.json
deleted file mode 100644
index ec016ac7337e..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/NO/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (no)"
- },
- "extensionDescription": {
- "message": "Wikipedia, den frie encyklopedi"
- },
- "searchUrl": {
- "message": "https://no.wikipedia.org/wiki/Spesial:Søk"
- },
- "searchForm": {
- "message": "https://no.wikipedia.org/wiki/Spesial:Søk?search={searchTerms}&sourceid=Moz…"
- },
- "suggestUrl": {
- "message": "https://no.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/af/messages.json b/browser/components/search/extensions/wikipedia/_locales/af/messages.json
deleted file mode 100644
index 8cf9de8ac9b3..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/af/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (af)"
- },
- "extensionDescription": {
- "message": "Wikipedia, die vrye ensiklopedie"
- },
- "searchUrl": {
- "message": "https://af.wikipedia.org/wiki/Spesiaal:Soek"
- },
- "searchForm": {
- "message": "https://af.wikipedia.org/wiki/Spesiaal:Soek?search={searchTerms}&sourceid=M…"
- },
- "suggestUrl": {
- "message": "https://af.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/an/messages.json b/browser/components/search/extensions/wikipedia/_locales/an/messages.json
deleted file mode 100644
index e8cce665c96e..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/an/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Biquipedia (an)"
- },
- "extensionDescription": {
- "message": "A enciclopedia Libre"
- },
- "searchUrl": {
- "message": "https://an.wikipedia.org/wiki/Especial:Mirar"
- },
- "searchForm": {
- "message": "https://an.wikipedia.org/wiki/Especial:Mirar?search={searchTerms}&sourceid=…"
- },
- "suggestUrl": {
- "message": "https://an.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ar/messages.json b/browser/components/search/extensions/wikipedia/_locales/ar/messages.json
deleted file mode 100644
index de90b2a2055e..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ar/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "ويكيبيديا (ar)"
- },
- "extensionDescription": {
- "message": "ويكيبيديا (ar)"
- },
- "searchUrl": {
- "message": "https://ar.wikipedia.org/wiki/خاص:بحث"
- },
- "searchForm": {
- "message": "https://ar.wikipedia.org/wiki/خاص:بحث?search={searchTerms}&sourceid=Mozilla…"
- },
- "suggestUrl": {
- "message": "https://ar.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ast/messages.json b/browser/components/search/extensions/wikipedia/_locales/ast/messages.json
deleted file mode 100644
index a127ba07f29b..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ast/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (ast)"
- },
- "extensionDescription": {
- "message": "La enciclopedia llibre"
- },
- "searchUrl": {
- "message": "https://ast.wikipedia.org/wiki/Especial:Gueta"
- },
- "searchForm": {
- "message": "https://ast.wikipedia.org/wiki/Especial:Gueta?search={searchTerms}&sourceid…"
- },
- "suggestUrl": {
- "message": "https://ast.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/az/messages.json b/browser/components/search/extensions/wikipedia/_locales/az/messages.json
deleted file mode 100644
index f551a717e6d3..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/az/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Vikipediya (az)"
- },
- "extensionDescription": {
- "message": "Vikipediya, açıq ensiklopediya"
- },
- "searchUrl": {
- "message": "https://az.wikipedia.org/wiki/Xüsusi:Axtar"
- },
- "searchForm": {
- "message": "https://az.wikipedia.org/wiki/Xüsusi:Axtar?search={searchTerms}&sourceid=Mo…"
- },
- "suggestUrl": {
- "message": "https://az.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/be-tarask/messages.json b/browser/components/search/extensions/wikipedia/_locales/be-tarask/messages.json
deleted file mode 100644
index aecfecf2fb19..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/be-tarask/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Вікіпэдыя (be-tarask)"
- },
- "extensionDescription": {
- "message": "Вікіпэдыя, вольная энцыкляпэдыя"
- },
- "searchUrl": {
- "message": "https://be-tarask.wikipedia.org/wiki/Спэцыяльныя:Пошук"
- },
- "searchForm": {
- "message": "https://be-tarask.wikipedia.org/wiki/Спэцыяльныя:Пошук?search={searchTerms}…"
- },
- "suggestUrl": {
- "message": "https://be-tarask.wikipedia.org/w/api.php?action=opensearch&search={searchT…"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/be/messages.json b/browser/components/search/extensions/wikipedia/_locales/be/messages.json
deleted file mode 100644
index 6aa763451e67..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/be/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Вікіпедыя (be)"
- },
- "extensionDescription": {
- "message": "Вікіпедыя, свабодная энцыклапедыя"
- },
- "searchUrl": {
- "message": "https://be.wikipedia.org/wiki/Адмысловае:Search"
- },
- "searchForm": {
- "message": "https://be.wikipedia.org/wiki/Адмысловае:Search?search={searchTerms}&source…"
- },
- "suggestUrl": {
- "message": "https://be.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/bg/messages.json b/browser/components/search/extensions/wikipedia/_locales/bg/messages.json
deleted file mode 100644
index 896a85d66b87..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/bg/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Уикипедия (bg)"
- },
- "extensionDescription": {
- "message": "Уикипедия, свободната енциклоподия"
- },
- "searchUrl": {
- "message": "https://bg.wikipedia.org/wiki/Специални:Търсене"
- },
- "searchForm": {
- "message": "https://bg.wikipedia.org/wiki/Специални:Търсене?search={searchTerms}&source…"
- },
- "suggestUrl": {
- "message": "https://bg.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/bn/messages.json b/browser/components/search/extensions/wikipedia/_locales/bn/messages.json
deleted file mode 100644
index fe9887ed1938..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/bn/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "উইকিপিডিয়া (bn)"
- },
- "extensionDescription": {
- "message": "উইকিপিডিয়া, মুক্ত বিশ্বকোষ"
- },
- "searchUrl": {
- "message": "https://bn.wikipedia.org/wiki/বিশেষ:Search"
- },
- "searchForm": {
- "message": "https://bn.wikipedia.org/wiki/বিশেষ:Search?search={searchTerms}&sourceid=Mo…"
- },
- "suggestUrl": {
- "message": "https://bn.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/br/messages.json b/browser/components/search/extensions/wikipedia/_locales/br/messages.json
deleted file mode 100644
index 33869ce8e752..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/br/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (br)"
- },
- "extensionDescription": {
- "message": "Wikipedia, an holloueziadur digor"
- },
- "searchUrl": {
- "message": "https://br.wikipedia.org/wiki/Dibar:Klask"
- },
- "searchForm": {
- "message": "https://br.wikipedia.org/wiki/Dibar:Klask?search={searchTerms}&sourceid=Moz…"
- },
- "suggestUrl": {
- "message": "https://br.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/bs/messages.json b/browser/components/search/extensions/wikipedia/_locales/bs/messages.json
deleted file mode 100644
index 746150e3d8e8..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/bs/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (bs)"
- },
- "extensionDescription": {
- "message": "Slobodna enciklopedija"
- },
- "searchUrl": {
- "message": "https://bs.wikipedia.org/wiki/Posebno:Pretraga"
- },
- "searchForm": {
- "message": "https://bs.wikipedia.org/wiki/Posebno:Pretraga?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://bs.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ca/messages.json b/browser/components/search/extensions/wikipedia/_locales/ca/messages.json
deleted file mode 100644
index 151ec1a71ba5..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ca/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Viquipèdia (ca)"
- },
- "extensionDescription": {
- "message": "L'enciclopèdia lliure"
- },
- "searchUrl": {
- "message": "https://ca.wikipedia.org/wiki/Especial:Cerca"
- },
- "searchForm": {
- "message": "https://ca.wikipedia.org/wiki/Especial:Cerca?search={searchTerms}&sourceid=…"
- },
- "suggestUrl": {
- "message": "https://ca.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/cy/messages.json b/browser/components/search/extensions/wikipedia/_locales/cy/messages.json
deleted file mode 100644
index cfed7c73be34..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/cy/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wicipedia (cy)"
- },
- "extensionDescription": {
- "message": "Wicipedia, Y Gwyddioniadur Rhydd"
- },
- "searchUrl": {
- "message": "https://cy.wikipedia.org/wiki/Arbennig:Search"
- },
- "searchForm": {
- "message": "https://cy.wikipedia.org/wiki/Arbennig:Search?search={searchTerms}&sourceid…"
- },
- "suggestUrl": {
- "message": "https://cy.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/cz/messages.json b/browser/components/search/extensions/wikipedia/_locales/cz/messages.json
deleted file mode 100644
index 12f7eb22d711..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/cz/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedie (cs)"
- },
- "extensionDescription": {
- "message": "Wikipedia, svobodná encyclopedie"
- },
- "searchUrl": {
- "message": "https://cs.wikipedia.org/wiki/Speciální:Hledání"
- },
- "searchForm": {
- "message": "https://cs.wikipedia.org/wiki/Speciální:Hledání?search={searchTerms}&source…"
- },
- "suggestUrl": {
- "message": "https://cs.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/da/messages.json b/browser/components/search/extensions/wikipedia/_locales/da/messages.json
deleted file mode 100644
index 801d5a5183cc..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/da/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (da)"
- },
- "extensionDescription": {
- "message": "Wikipedia, den frie encyklopædi"
- },
- "searchUrl": {
- "message": "https://da.wikipedia.org/wiki/Speciel:Søgning"
- },
- "searchForm": {
- "message": "https://da.wikipedia.org/wiki/Speciel:Søgning?search={searchTerms}&sourceid…"
- },
- "suggestUrl": {
- "message": "https://da.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/de/messages.json b/browser/components/search/extensions/wikipedia/_locales/de/messages.json
deleted file mode 100644
index 0e6bbe8905ca..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/de/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (de)"
- },
- "extensionDescription": {
- "message": "Wikipedia, die freie Enzyklopädie"
- },
- "searchUrl": {
- "message": "https://de.wikipedia.org/wiki/Spezial:Suche"
- },
- "searchForm": {
- "message": "https://de.wikipedia.org/wiki/Spezial:Suche?search={searchTerms}&sourceid=M…"
- },
- "suggestUrl": {
- "message": "https://de.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/dsb/messages.json b/browser/components/search/extensions/wikipedia/_locales/dsb/messages.json
deleted file mode 100644
index ffca44b5f7fb..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/dsb/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedija (dsb)"
- },
- "extensionDescription": {
- "message": "Wikipedija, lichotna encyklopedija"
- },
- "searchUrl": {
- "message": "https://dsb.wikipedia.org/wiki/Specialne:Pytaś"
- },
- "searchForm": {
- "message": "https://dsb.wikipedia.org/wiki/Specialne:Pytaś?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://dsb.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/el/messages.json b/browser/components/search/extensions/wikipedia/_locales/el/messages.json
deleted file mode 100644
index 95b48f3d9ca7..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/el/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (el)"
- },
- "extensionDescription": {
- "message": "Βικιπαίδεια, η ελεύθερη εγκυκλοπαίδεια"
- },
- "searchUrl": {
- "message": "https://el.wikipedia.org/wiki/Ειδικό:Αναζήτηση"
- },
- "searchForm": {
- "message": "https://el.wikipedia.org/wiki/Ειδικό:Αναζήτηση?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://el.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/en/messages.json b/browser/components/search/extensions/wikipedia/_locales/en/messages.json
deleted file mode 100644
index 0de3c9a8071a..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/en/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (en)"
- },
- "extensionDescription": {
- "message": "Wikipedia, the Free Encyclopedia"
- },
- "searchUrl": {
- "message": "https://en.wikipedia.org/wiki/Special:Search"
- },
- "searchForm": {
- "message": "https://en.wikipedia.org/wiki/Special:Search?search={searchTerms}&sourceid=…"
- },
- "suggestUrl": {
- "message": "https://en.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/eo/messages.json b/browser/components/search/extensions/wikipedia/_locales/eo/messages.json
deleted file mode 100644
index 10aa88dd11ba..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/eo/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Vikipedio (eo)"
- },
- "extensionDescription": {
- "message": "Vikipedio, la libera enciklopedio"
- },
- "searchUrl": {
- "message": "https://eo.wikipedia.org/wiki/Specialaĵo:Serĉi"
- },
- "searchForm": {
- "message": "https://eo.wikipedia.org/wiki/Specialaĵo:Serĉi?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://eo.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/es/messages.json b/browser/components/search/extensions/wikipedia/_locales/es/messages.json
deleted file mode 100644
index 09ec1f757657..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/es/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (es)"
- },
- "extensionDescription": {
- "message": "Wikipedia, la enciclopedia libre"
- },
- "searchUrl": {
- "message": "https://es.wikipedia.org/wiki/Especial:Buscar"
- },
- "searchForm": {
- "message": "https://es.wikipedia.org/wiki/Especial:Buscar?search={searchTerms}&sourceid…"
- },
- "suggestUrl": {
- "message": "https://es.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/et/messages.json b/browser/components/search/extensions/wikipedia/_locales/et/messages.json
deleted file mode 100644
index 91363fbb392b..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/et/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Vikipeedia (et)"
- },
- "extensionDescription": {
- "message": "Vikipeedia, vaba entsüklopeedia"
- },
- "searchUrl": {
- "message": "https://et.wikipedia.org/wiki/Eri:Otsimine"
- },
- "searchForm": {
- "message": "https://et.wikipedia.org/wiki/Eri:Otsimine?search={searchTerms}&sourceid=Mo…"
- },
- "suggestUrl": {
- "message": "https://et.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/eu/messages.json b/browser/components/search/extensions/wikipedia/_locales/eu/messages.json
deleted file mode 100644
index 1bd7027dec54..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/eu/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (eu)"
- },
- "extensionDescription": {
- "message": "Wikipedia, entziklopedia askea"
- },
- "searchUrl": {
- "message": "https://eu.wikipedia.org/wiki/Berezi:Bilatu"
- },
- "searchForm": {
- "message": "https://eu.wikipedia.org/wiki/Berezi:Bilatu?search={searchTerms}&sourceid=M…"
- },
- "suggestUrl": {
- "message": "https://eu.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/fa/messages.json b/browser/components/search/extensions/wikipedia/_locales/fa/messages.json
deleted file mode 100644
index 9fdc964a1e0b..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/fa/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "ویکیپدیا (fa)"
- },
- "extensionDescription": {
- "message": "ویکیپدیا، دانشنامهٔ آزاد"
- },
- "searchUrl": {
- "message": "https://fa.wikipedia.org/wiki/ویژه:جستجو"
- },
- "searchForm": {
- "message": "https://fa.wikipedia.org/wiki/ویژه:جستجو?search={searchTerms}&sourceid=Mozi…"
- },
- "suggestUrl": {
- "message": "https://fa.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/fi/messages.json b/browser/components/search/extensions/wikipedia/_locales/fi/messages.json
deleted file mode 100644
index 17a9cbe22c42..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/fi/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (fi)"
- },
- "extensionDescription": {
- "message": "Wikipedia (fi), vapaa tietosanakirja"
- },
- "searchUrl": {
- "message": "https://fi.wikipedia.org/wiki/Toiminnot:Haku"
- },
- "searchForm": {
- "message": "https://fi.wikipedia.org/wiki/Toiminnot:Haku?search={searchTerms}&sourceid=…"
- },
- "suggestUrl": {
- "message": "https://fi.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/fr/messages.json b/browser/components/search/extensions/wikipedia/_locales/fr/messages.json
deleted file mode 100644
index 33dcbe9dc502..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/fr/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipédia (fr)"
- },
- "extensionDescription": {
- "message": "Wikipédia, l'encyclopédie libre"
- },
- "searchUrl": {
- "message": "https://fr.wikipedia.org/wiki/Spécial:Recherche"
- },
- "searchForm": {
- "message": "https://fr.wikipedia.org/wiki/Spécial:Recherche?search={searchTerms}&source…"
- },
- "suggestUrl": {
- "message": "https://fr.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/fy-NL/messages.json b/browser/components/search/extensions/wikipedia/_locales/fy-NL/messages.json
deleted file mode 100644
index f350162fbbaf..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/fy-NL/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedy (fy)"
- },
- "extensionDescription": {
- "message": "De fergese ensyklopedy"
- },
- "searchUrl": {
- "message": "https://fy.wikipedia.org/wiki/Wiki:Sykje"
- },
- "searchForm": {
- "message": "https://fy.wikipedia.org/wiki/Wiki:Sykje?search={searchTerms}&sourceid=Mozi…"
- },
- "suggestUrl": {
- "message": "https://fy.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ga-IE/messages.json b/browser/components/search/extensions/wikipedia/_locales/ga-IE/messages.json
deleted file mode 100644
index 994ea723c6da..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ga-IE/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Vicipéid (ga)"
- },
- "extensionDescription": {
- "message": "Vicipéid, an Chiclipéid Shaor"
- },
- "searchUrl": {
- "message": "https://ga.wikipedia.org/wiki/Speisialta:Search"
- },
- "searchForm": {
- "message": "https://ga.wikipedia.org/wiki/Speisialta:Search?search={searchTerms}&source…"
- },
- "suggestUrl": {
- "message": "https://ga.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/gd/messages.json b/browser/components/search/extensions/wikipedia/_locales/gd/messages.json
deleted file mode 100644
index f16f16fb4a02..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/gd/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Uicipeid (gd)"
- },
- "extensionDescription": {
- "message": "Wikipedia, An leabhar mòr-eòlais"
- },
- "searchUrl": {
- "message": "https://gd.wikipedia.org/wiki/Sònraichte:Search"
- },
- "searchForm": {
- "message": "https://gd.wikipedia.org/wiki/Sònraichte:Search?search={searchTerms}&source…"
- },
- "suggestUrl": {
- "message": "https://gd.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/gl/messages.json b/browser/components/search/extensions/wikipedia/_locales/gl/messages.json
deleted file mode 100644
index 88880bffc3d9..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/gl/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (gl)"
- },
- "extensionDescription": {
- "message": "Wikipedia, a enciclopedia libre"
- },
- "searchUrl": {
- "message": "https://gl.wikipedia.org/wiki/Especial:Procurar"
- },
- "searchForm": {
- "message": "https://gl.wikipedia.org/wiki/Especial:Procurar?search={searchTerms}&source…"
- },
- "suggestUrl": {
- "message": "https://gl.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/gn/messages.json b/browser/components/search/extensions/wikipedia/_locales/gn/messages.json
deleted file mode 100644
index 5efc5ed74a95..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/gn/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Vikipetã (gn)"
- },
- "extensionDescription": {
- "message": "Vikipetã, opaite tembikuaa hekosãsóva renda"
- },
- "searchUrl": {
- "message": "https://gn.wikipedia.org/wiki/Mba'echĩchĩ:Buscar"
- },
- "searchForm": {
- "message": "https://gn.wikipedia.org/wiki/Mba'echĩchĩ:Buscar?search={searchTerms}&sourceid=Mozilla-search"
- },
- "suggestUrl": {
- "message": "https://gn.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/gu/messages.json b/browser/components/search/extensions/wikipedia/_locales/gu/messages.json
deleted file mode 100644
index 3d2f68826fc5..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/gu/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "વિકિપીડિયા (gu)"
- },
- "extensionDescription": {
- "message": "વીકીપીડિયા, મુક્ત એનસાયક્લોપીડિયા"
- },
- "searchUrl": {
- "message": "https://gu.wikipedia.org/wiki/વિશેષ:શોધ"
- },
- "searchForm": {
- "message": "https://gu.wikipedia.org/wiki/વિશેષ:શોધ?search={searchTerms}&sourceid=Mozil…"
- },
- "suggestUrl": {
- "message": "https://gu.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/he/messages.json b/browser/components/search/extensions/wikipedia/_locales/he/messages.json
deleted file mode 100644
index 1f8471e980f0..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/he/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "ויקיפדיה"
- },
- "extensionDescription": {
- "message": "ויקיפדיה"
- },
- "searchUrl": {
- "message": "https://he.wikipedia.org/wiki/מיוחד:חיפוש"
- },
- "searchForm": {
- "message": "https://he.wikipedia.org/wiki/מיוחד:חיפוש?search={searchTerms}&sourceid=Moz…"
- },
- "suggestUrl": {
- "message": "https://he.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/hi/messages.json b/browser/components/search/extensions/wikipedia/_locales/hi/messages.json
deleted file mode 100644
index f3b7d14eafa0..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/hi/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "विकिपीडिया (hi)"
- },
- "extensionDescription": {
- "message": "विकिपीडिया (हिन्दी)"
- },
- "searchUrl": {
- "message": "https://hi.wikipedia.org/wiki/विशेष:खोज"
- },
- "searchForm": {
- "message": "https://hi.wikipedia.org/wiki/विशेष:खोज?search={searchTerms}&sourceid=Mozil…"
- },
- "suggestUrl": {
- "message": "https://hi.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/hr/messages.json b/browser/components/search/extensions/wikipedia/_locales/hr/messages.json
deleted file mode 100644
index 18a6177efcca..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/hr/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedija (hr)"
- },
- "extensionDescription": {
- "message": "Wikipedija, slobodna enciklopedija"
- },
- "searchUrl": {
- "message": "https://hr.wikipedia.org/wiki/Posebno:Traži"
- },
- "searchForm": {
- "message": "https://hr.wikipedia.org/wiki/Posebno:Traži?search={searchTerms}&sourceid=M…"
- },
- "suggestUrl": {
- "message": "https://hr.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/hsb/messages.json b/browser/components/search/extensions/wikipedia/_locales/hsb/messages.json
deleted file mode 100644
index d4e62836e6e9..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/hsb/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedija (hsb)"
- },
- "extensionDescription": {
- "message": "Wikipedija, swobodna encyklopedija"
- },
- "searchUrl": {
- "message": "https://hsb.wikipedia.org/wiki/Specialnje:Pytać"
- },
- "searchForm": {
- "message": "https://hsb.wikipedia.org/wiki/Specialnje:Pytać?search={searchTerms}&source…"
- },
- "suggestUrl": {
- "message": "https://hsb.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/hu/messages.json b/browser/components/search/extensions/wikipedia/_locales/hu/messages.json
deleted file mode 100644
index 68300c48a6f3..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/hu/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipédia (hu)"
- },
- "extensionDescription": {
- "message": "Wikipedia, a szabad enciklopédia"
- },
- "searchUrl": {
- "message": "https://hu.wikipedia.org/wiki/Speciális:Keresés"
- },
- "searchForm": {
- "message": "https://hu.wikipedia.org/wiki/Speciális:Keresés?search={searchTerms}&source…"
- },
- "suggestUrl": {
- "message": "https://hu.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/hy/messages.json b/browser/components/search/extensions/wikipedia/_locales/hy/messages.json
deleted file mode 100644
index 56c2ae2c641b..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/hy/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (hy)"
- },
- "extensionDescription": {
- "message": "Վիքիփեդիա՝ ազատ հանրագիտարան"
- },
- "searchUrl": {
- "message": "https://hy.wikipedia.org/wiki/Սպասարկող:Որոնել"
- },
- "searchForm": {
- "message": "https://hy.wikipedia.org/wiki/Սպասարկող:Որոնել?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://hy.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ia/messages.json b/browser/components/search/extensions/wikipedia/_locales/ia/messages.json
deleted file mode 100644
index 6d997ae8fc81..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ia/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (ia)"
- },
- "extensionDescription": {
- "message": "Wikipedia, le encyclopedia libere"
- },
- "searchUrl": {
- "message": "https://ia.wikipedia.org/wiki/Special:Recerca"
- },
- "searchForm": {
- "message": "https://ia.wikipedia.org/wiki/Special:Recerca?search={searchTerms}&sourceid…"
- },
- "suggestUrl": {
- "message": "https://ia.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/id/messages.json b/browser/components/search/extensions/wikipedia/_locales/id/messages.json
deleted file mode 100644
index 1d35e71b956d..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/id/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (id)"
- },
- "extensionDescription": {
- "message": "Wikipedia, ensiklopedia bebas"
- },
- "searchUrl": {
- "message": "https://id.wikipedia.org/wiki/Istimewa:Pencarian"
- },
- "searchForm": {
- "message": "https://id.wikipedia.org/wiki/Istimewa:Pencarian?search={searchTerms}&sourc…"
- },
- "suggestUrl": {
- "message": "https://id.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/is/messages.json b/browser/components/search/extensions/wikipedia/_locales/is/messages.json
deleted file mode 100644
index f722d88187de..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/is/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (is)"
- },
- "extensionDescription": {
- "message": "Wikipedia, the free encyclopedia"
- },
- "searchUrl": {
- "message": "https://is.wikipedia.org/wiki/Kerfissíða:Leit"
- },
- "searchForm": {
- "message": "https://is.wikipedia.org/wiki/Kerfissíða:Leit?search={searchTerms}&sourceid…"
- },
- "suggestUrl": {
- "message": "https://is.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/it/messages.json b/browser/components/search/extensions/wikipedia/_locales/it/messages.json
deleted file mode 100644
index 2ca645740f87..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/it/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (it)"
- },
- "extensionDescription": {
- "message": "Wikipedia, l'enciclopedia libera"
- },
- "searchUrl": {
- "message": "https://it.wikipedia.org/wiki/Speciale:Ricerca"
- },
- "searchForm": {
- "message": "https://it.wikipedia.org/wiki/Speciale:Ricerca?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://it.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ja/messages.json b/browser/components/search/extensions/wikipedia/_locales/ja/messages.json
deleted file mode 100644
index 7215e68768f0..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ja/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (ja)"
- },
- "extensionDescription": {
- "message": "Wikipedia - フリー百科事典"
- },
- "searchUrl": {
- "message": "https://ja.wikipedia.org/wiki/特別:検索"
- },
- "searchForm": {
- "message": "https://ja.wikipedia.org/wiki/特別:検索?search={searchTerms}&sourceid=Mozilla-s…"
- },
- "suggestUrl": {
- "message": "https://ja.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ka/messages.json b/browser/components/search/extensions/wikipedia/_locales/ka/messages.json
deleted file mode 100644
index c460a093e5e4..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ka/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "ვიკიპედია (ka)"
- },
- "extensionDescription": {
- "message": "ვიკიპედია, თავისუფალი ენციკლოპედია"
- },
- "searchUrl": {
- "message": "https://ka.wikipedia.org/wiki/სპეციალური:ძიება"
- },
- "searchForm": {
- "message": "https://ka.wikipedia.org/wiki/სპეციალური:ძიება?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://ka.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/kab/messages.json b/browser/components/search/extensions/wikipedia/_locales/kab/messages.json
deleted file mode 100644
index 3cf743b616fe..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/kab/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (kab)"
- },
- "extensionDescription": {
- "message": "Wikipedia, tasanayt tilellit"
- },
- "searchUrl": {
- "message": "https://kab.wikipedia.org/wiki/Uslig:Search"
- },
- "searchForm": {
- "message": "https://kab.wikipedia.org/wiki/Uslig:Search?search={searchTerms}&sourceid=M…"
- },
- "suggestUrl": {
- "message": "https://kab.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/kk/messages.json b/browser/components/search/extensions/wikipedia/_locales/kk/messages.json
deleted file mode 100644
index 0844cca0d7e1..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/kk/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Уикипедия (kk)"
- },
- "extensionDescription": {
- "message": "Уикипедия (kk)"
- },
- "searchUrl": {
- "message": "https://kk.wikipedia.org/wiki/Арнайы:Іздеу"
- },
- "searchForm": {
- "message": "https://kk.wikipedia.org/wiki/Арнайы:Іздеу?search={searchTerms}&sourceid=Mo…"
- },
- "suggestUrl": {
- "message": "https://kk.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/km/messages.json b/browser/components/search/extensions/wikipedia/_locales/km/messages.json
deleted file mode 100644
index 0f0a0880e188..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/km/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "វីគីភីឌា (km)"
- },
- "extensionDescription": {
- "message": "វីគីភីឌា សព្វវចនាធិប្បាយសេរី"
- },
- "searchUrl": {
- "message": "https://km.wikipedia.org/wiki/ពិសេស:ស្វែងរក"
- },
- "searchForm": {
- "message": "https://km.wikipedia.org/wiki/ពិសេស:ស្វែងរក?search={searchTerms}&sourceid=M…"
- },
- "suggestUrl": {
- "message": "https://km.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/kn/messages.json b/browser/components/search/extensions/wikipedia/_locales/kn/messages.json
deleted file mode 100644
index 379ef20085a3..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/kn/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (kn)"
- },
- "extensionDescription": {
- "message": "Wikipedia, the free encyclopedia"
- },
- "searchUrl": {
- "message": "https://kn.wikipedia.org/wiki/ವಿಶೇಷ:Search"
- },
- "searchForm": {
- "message": "https://kn.wikipedia.org/wiki/ವಿಶೇಷ:Search?search={searchTerms}&sourceid=Mo…"
- },
- "suggestUrl": {
- "message": "https://kn.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/kr/messages.json b/browser/components/search/extensions/wikipedia/_locales/kr/messages.json
deleted file mode 100644
index 54296cac62bd..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/kr/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "위키백과 (ko)"
- },
- "extensionDescription": {
- "message": "Wikipedia, the free encyclopedia"
- },
- "searchUrl": {
- "message": "https://ko.wikipedia.org/wiki/특수기능:찾기"
- },
- "searchForm": {
- "message": "https://ko.wikipedia.org/wiki/특수기능:찾기?search={searchTerms}&sourceid=Mozilla…"
- },
- "suggestUrl": {
- "message": "https://ko.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/lij/messages.json b/browser/components/search/extensions/wikipedia/_locales/lij/messages.json
deleted file mode 100644
index cb90db5e4099..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/lij/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (lij)"
- },
- "extensionDescription": {
- "message": "Wikipedia, l'enciclopedia libera"
- },
- "searchUrl": {
- "message": "https://lij.wikipedia.org/wiki/Speçiale:Riçerca"
- },
- "searchForm": {
- "message": "https://lij.wikipedia.org/wiki/Speçiale:Riçerca?search={searchTerms}&source…"
- },
- "suggestUrl": {
- "message": "https://lij.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/lo/messages.json b/browser/components/search/extensions/wikipedia/_locales/lo/messages.json
deleted file mode 100644
index 712746ec6316..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/lo/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "ວິກິພີເດຍ (lo)"
- },
- "extensionDescription": {
- "message": "ວິກິພີເດຍ, ສາລານຸກົມເສລີ"
- },
- "searchUrl": {
- "message": "https://lo.wikipedia.org/wiki/ພິເສດ:ຊອກຫາ"
- },
- "searchForm": {
- "message": "https://lo.wikipedia.org/wiki/ພິເສດ:ຊອກຫາ?search={searchTerms}&sourceid=Moz…"
- },
- "suggestUrl": {
- "message": "https://lo.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/lt/messages.json b/browser/components/search/extensions/wikipedia/_locales/lt/messages.json
deleted file mode 100644
index c061bcc5224c..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/lt/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (lt)"
- },
- "extensionDescription": {
- "message": "Vikipedija, laisvoji enciklopedija"
- },
- "searchUrl": {
- "message": "https://lt.wikipedia.org/wiki/Specialus:Paieška"
- },
- "searchForm": {
- "message": "https://lt.wikipedia.org/wiki/Specialus:Paieška?search={searchTerms}&source…"
- },
- "suggestUrl": {
- "message": "https://lt.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ltg/messages.json b/browser/components/search/extensions/wikipedia/_locales/ltg/messages.json
deleted file mode 100644
index 0e02810ef3bf..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ltg/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Vikipedeja (ltg)"
- },
- "extensionDescription": {
- "message": "Vikipēdija, breivuo eņciklopedeja"
- },
- "searchUrl": {
- "message": "https://ltg.wikipedia.org/wiki/Seviškuo:Search"
- },
- "searchForm": {
- "message": "https://ltg.wikipedia.org/wiki/Seviškuo:Search?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://ltg.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/lv/messages.json b/browser/components/search/extensions/wikipedia/_locales/lv/messages.json
deleted file mode 100644
index f73814b8574f..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/lv/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Vikipēdija"
- },
- "extensionDescription": {
- "message": "Vikipēdija, brīvā enciklopēdija"
- },
- "searchUrl": {
- "message": "https://lv.wikipedia.org/wiki/Special:Search"
- },
- "searchForm": {
- "message": "https://lv.wikipedia.org/wiki/Special:Search?search={searchTerms}&sourceid=…"
- },
- "suggestUrl": {
- "message": "https://lv.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/mk/messages.json b/browser/components/search/extensions/wikipedia/_locales/mk/messages.json
deleted file mode 100644
index de7e06e1ac4a..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/mk/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Википедија (mk)"
- },
- "extensionDescription": {
- "message": "Википедија, слободната енциклопедија"
- },
- "searchUrl": {
- "message": "https://mk.wikipedia.org/wiki/Специјална:Барај"
- },
- "searchForm": {
- "message": "https://mk.wikipedia.org/wiki/Специјална:Барај?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://mk.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/mr/messages.json b/browser/components/search/extensions/wikipedia/_locales/mr/messages.json
deleted file mode 100644
index bd46dd83700c..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/mr/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "विकिपीडिया (mr)"
- },
- "extensionDescription": {
- "message": "विकिपीडिया, मोफत माहितीकोष"
- },
- "searchUrl": {
- "message": "https://mr.wikipedia.org/wiki/विशेष:शोधा"
- },
- "searchForm": {
- "message": "https://mr.wikipedia.org/wiki/विशेष:शोधा?search={searchTerms}&sourceid=Mozi…"
- },
- "suggestUrl": {
- "message": "https://mr.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ms/messages.json b/browser/components/search/extensions/wikipedia/_locales/ms/messages.json
deleted file mode 100644
index c817e82c7821..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ms/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (ms)"
- },
- "extensionDescription": {
- "message": "Wikipedia, ensiklopedia bebas"
- },
- "searchUrl": {
- "message": "https://ms.wikipedia.org/wiki/Khas:Gelintar"
- },
- "searchForm": {
- "message": "https://ms.wikipedia.org/wiki/Khas:Gelintar?search={searchTerms}&sourceid=M…"
- },
- "suggestUrl": {
- "message": "https://ms.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/my/messages.json b/browser/components/search/extensions/wikipedia/_locales/my/messages.json
deleted file mode 100644
index 62342d1b90ae..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/my/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (my)"
- },
- "extensionDescription": {
- "message": "အခမဲ့လွတ်လပ်စွယ်စုံကျမ်း"
- },
- "searchUrl": {
- "message": "https://my.wikipedia.org/wiki/Special:Search"
- },
- "searchForm": {
- "message": "https://my.wikipedia.org/wiki/Special:Search?search={searchTerms}&sourceid=…"
- },
- "suggestUrl": {
- "message": "https://my.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ne/messages.json b/browser/components/search/extensions/wikipedia/_locales/ne/messages.json
deleted file mode 100644
index eb22344341e4..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ne/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "विकिपीडिया (ne)"
- },
- "extensionDescription": {
- "message": "विकिपिडिया एक स्वतन्त्र विश्वकोष"
- },
- "searchUrl": {
- "message": "https://ne.wikipedia.org/wiki/विशेष:Search"
- },
- "searchForm": {
- "message": "https://ne.wikipedia.org/wiki/विशेष:Search?search={searchTerms}&sourceid=Mo…"
- },
- "suggestUrl": {
- "message": "https://ne.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/nl/messages.json b/browser/components/search/extensions/wikipedia/_locales/nl/messages.json
deleted file mode 100644
index c2a810c2ae30..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/nl/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (nl)"
- },
- "extensionDescription": {
- "message": "De vrije encyclopedie"
- },
- "searchUrl": {
- "message": "https://nl.wikipedia.org/wiki/Speciaal:Zoeken"
- },
- "searchForm": {
- "message": "https://nl.wikipedia.org/wiki/Speciaal:Zoeken?search={searchTerms}&sourceid…"
- },
- "suggestUrl": {
- "message": "https://nl.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/oc/messages.json b/browser/components/search/extensions/wikipedia/_locales/oc/messages.json
deleted file mode 100644
index 3cadc3d68f07..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/oc/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipèdia (oc)"
- },
- "extensionDescription": {
- "message": "Wikipèdia, l'enciclopèdia liura"
- },
- "searchUrl": {
- "message": "https://oc.wikipedia.org/wiki/Especial:Recèrca"
- },
- "searchForm": {
- "message": "https://oc.wikipedia.org/wiki/Especial:Recèrca?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://oc.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/pa/messages.json b/browser/components/search/extensions/wikipedia/_locales/pa/messages.json
deleted file mode 100644
index dff38c2146fd..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/pa/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (pa)"
- },
- "extensionDescription": {
- "message": "ਵਿਕਿਪੀਡਿਆ, ਮੁਫ਼ਤ/ਮੁਕਤ ਸ਼ਬਦਕੋਸ਼"
- },
- "searchUrl": {
- "message": "https://pa.wikipedia.org/wiki/ਖ਼ਾਸ:ਖੋਜੋ"
- },
- "searchForm": {
- "message": "https://pa.wikipedia.org/wiki/ਖ਼ਾਸ:ਖੋਜੋ?search={searchTerms}&sourceid=Mozil…"
- },
- "suggestUrl": {
- "message": "https://pa.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/pl/messages.json b/browser/components/search/extensions/wikipedia/_locales/pl/messages.json
deleted file mode 100644
index 315aa0d9cbe1..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/pl/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (pl)"
- },
- "extensionDescription": {
- "message": "Wikipedia, wolna encyklopedia"
- },
- "searchUrl": {
- "message": "https://pl.wikipedia.org/wiki/Specjalna:Szukaj"
- },
- "searchForm": {
- "message": "https://pl.wikipedia.org/wiki/Specjalna:Szukaj?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://pl.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/pt/messages.json b/browser/components/search/extensions/wikipedia/_locales/pt/messages.json
deleted file mode 100644
index 4beaa97acc88..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/pt/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (pt)"
- },
- "extensionDescription": {
- "message": "Wikipédia, a enciclopédia livre"
- },
- "searchUrl": {
- "message": "https://pt.wikipedia.org/wiki/Especial:Pesquisar"
- },
- "searchForm": {
- "message": "https://pt.wikipedia.org/wiki/Especial:Pesquisar?search={searchTerms}&sourc…"
- },
- "suggestUrl": {
- "message": "https://pt.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/rm/messages.json b/browser/components/search/extensions/wikipedia/_locales/rm/messages.json
deleted file mode 100644
index 8258d5e43451..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/rm/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (rm)"
- },
- "extensionDescription": {
- "message": "Vichipedia, l'enciclopedia libra"
- },
- "searchUrl": {
- "message": "https://rm.wikipedia.org/wiki/Spezial:Search"
- },
- "searchForm": {
- "message": "https://rm.wikipedia.org/wiki/Spezial:Search?search={searchTerms}&sourceid=…"
- },
- "suggestUrl": {
- "message": "https://rm.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ro/messages.json b/browser/components/search/extensions/wikipedia/_locales/ro/messages.json
deleted file mode 100644
index 48865fd547e4..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ro/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (ro)"
- },
- "extensionDescription": {
- "message": "Wikipedia, enciclopedia liberă"
- },
- "searchUrl": {
- "message": "https://ro.wikipedia.org/wiki/Special:Căutare"
- },
- "searchForm": {
- "message": "https://ro.wikipedia.org/wiki/Special:Căutare?search={searchTerms}&sourceid…"
- },
- "suggestUrl": {
- "message": "https://ro.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ru/messages.json b/browser/components/search/extensions/wikipedia/_locales/ru/messages.json
deleted file mode 100644
index 569467691d7c..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ru/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Википедия (ru)"
- },
- "extensionDescription": {
- "message": "Википедия, свободная энциклопедия"
- },
- "searchUrl": {
- "message": "https://ru.wikipedia.org/wiki/Служебная:Поиск"
- },
- "searchForm": {
- "message": "https://ru.wikipedia.org/wiki/Служебная:Поиск?search={searchTerms}&sourceid…"
- },
- "suggestUrl": {
- "message": "https://ru.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/si/messages.json b/browser/components/search/extensions/wikipedia/_locales/si/messages.json
deleted file mode 100644
index 0406ae728d71..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/si/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (si)"
- },
- "extensionDescription": {
- "message": "Wikipedia, the free encyclopedia"
- },
- "searchUrl": {
- "message": "https://si.wikipedia.org/wiki/විශේෂ:ගවේෂණය"
- },
- "searchForm": {
- "message": "https://si.wikipedia.org/wiki/විශේෂ:ගවේෂණය?search={searchTerms}&sourceid=Mo…"
- },
- "suggestUrl": {
- "message": "https://si.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/sk/messages.json b/browser/components/search/extensions/wikipedia/_locales/sk/messages.json
deleted file mode 100644
index 5c2f75f8b031..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/sk/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipédia (sk)"
- },
- "extensionDescription": {
- "message": "Wikipédia, slobodná a otvorená encyklopédia"
- },
- "searchUrl": {
- "message": "https://sk.wikipedia.org/wiki/Špeciálne:Hľadanie"
- },
- "searchForm": {
- "message": "https://sk.wikipedia.org/wiki/Špeciálne:Hľadanie?search={searchTerms}&sourc…"
- },
- "suggestUrl": {
- "message": "https://sk.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/sl/messages.json b/browser/components/search/extensions/wikipedia/_locales/sl/messages.json
deleted file mode 100644
index 7385a2203474..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/sl/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedija (sl)"
- },
- "extensionDescription": {
- "message": "Wikipedija, prosta enciklopedija"
- },
- "searchUrl": {
- "message": "https://sl.wikipedia.org/wiki/Posebno:Iskanje"
- },
- "searchForm": {
- "message": "https://sl.wikipedia.org/wiki/Posebno:Iskanje?search={searchTerms}&sourceid…"
- },
- "suggestUrl": {
- "message": "https://sl.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/sq/messages.json b/browser/components/search/extensions/wikipedia/_locales/sq/messages.json
deleted file mode 100644
index 68361d8ab294..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/sq/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (sq)"
- },
- "extensionDescription": {
- "message": "Wikipedia, enciklopedia e lirë"
- },
- "searchUrl": {
- "message": "https://sq.wikipedia.org/wiki/Speciale:Kërkim"
- },
- "searchForm": {
- "message": "https://sq.wikipedia.org/wiki/Speciale:Kërkim?search={searchTerms}&sourceid…"
- },
- "suggestUrl": {
- "message": "https://sq.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/sr/messages.json b/browser/components/search/extensions/wikipedia/_locales/sr/messages.json
deleted file mode 100644
index 50ebc0a197a1..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/sr/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Википедија (sr)"
- },
- "extensionDescription": {
- "message": "Претрага Википедије на српском језику"
- },
- "searchUrl": {
- "message": "https://sr.wikipedia.org/wiki/Посебно:Претражи"
- },
- "searchForm": {
- "message": "https://sr.wikipedia.org/wiki/Посебно:Претражи?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://sr.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/sv-SE/messages.json b/browser/components/search/extensions/wikipedia/_locales/sv-SE/messages.json
deleted file mode 100644
index 1edc3db80d98..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/sv-SE/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (sv)"
- },
- "extensionDescription": {
- "message": "Wikipedia, den fria encyklopedin"
- },
- "searchUrl": {
- "message": "https://sv.wikipedia.org/wiki/Special:Sök"
- },
- "searchForm": {
- "message": "https://sv.wikipedia.org/wiki/Special:Sök?search={searchTerms}&sourceid=Moz…"
- },
- "suggestUrl": {
- "message": "https://sv.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ta/messages.json b/browser/components/search/extensions/wikipedia/_locales/ta/messages.json
deleted file mode 100644
index 54397603b028..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ta/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "விக்கிப்பீடியா (ta)"
- },
- "extensionDescription": {
- "message": "விக்கிப்பீடியா (ta)"
- },
- "searchUrl": {
- "message": "https://ta.wikipedia.org/wiki/சிறப்பு:Search"
- },
- "searchForm": {
- "message": "https://ta.wikipedia.org/wiki/சிறப்பு:Search?search={searchTerms}&sourceid=…"
- },
- "suggestUrl": {
- "message": "https://ta.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/te/messages.json b/browser/components/search/extensions/wikipedia/_locales/te/messages.json
deleted file mode 100644
index c474be12a76f..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/te/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "వికీపీడియా (te)"
- },
- "extensionDescription": {
- "message": "వికీపీడియా (te)"
- },
- "searchUrl": {
- "message": "https://te.wikipedia.org/wiki/ప్రత్యేక:అన్వేషణ"
- },
- "searchForm": {
- "message": "https://te.wikipedia.org/wiki/ప్రత్యేక:అన్వేషణ?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://te.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/th/messages.json b/browser/components/search/extensions/wikipedia/_locales/th/messages.json
deleted file mode 100644
index 3d6aeb07ca2c..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/th/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "วิกิพีเดีย"
- },
- "extensionDescription": {
- "message": "วิกิพีเดีย สารานุกรมเสรี"
- },
- "searchUrl": {
- "message": "https://th.wikipedia.org/wiki/พิเศษ:ค้นหา"
- },
- "searchForm": {
- "message": "https://th.wikipedia.org/wiki/พิเศษ:ค้นหา?search={searchTerms}&sourceid=Moz…"
- },
- "suggestUrl": {
- "message": "https://th.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/tl/messages.json b/browser/components/search/extensions/wikipedia/_locales/tl/messages.json
deleted file mode 100644
index d55b03131f97..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/tl/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (tl)"
- },
- "extensionDescription": {
- "message": "Wikipedia, ang malayang ensiklopedya"
- },
- "searchUrl": {
- "message": "https://tl.wikipedia.org/wiki/Natatangi:Maghanap"
- },
- "searchForm": {
- "message": "https://tl.wikipedia.org/wiki/Natatangi:Maghanap?search={searchTerms}&sourc…"
- },
- "suggestUrl": {
- "message": "https://tl.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/tr/messages.json b/browser/components/search/extensions/wikipedia/_locales/tr/messages.json
deleted file mode 100644
index 878b28ab68b2..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/tr/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (tr)"
- },
- "extensionDescription": {
- "message": "Vikipedi, özgür ansiklopedi"
- },
- "searchUrl": {
- "message": "https://tr.wikipedia.org/wiki/Özel:Ara"
- },
- "searchForm": {
- "message": "https://tr.wikipedia.org/wiki/Özel:Ara?search={searchTerms}&sourceid=Mozill…"
- },
- "suggestUrl": {
- "message": "https://tr.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/uk/messages.json b/browser/components/search/extensions/wikipedia/_locales/uk/messages.json
deleted file mode 100644
index 2749b86304bf..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/uk/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Вікіпедія (uk)"
- },
- "extensionDescription": {
- "message": "Вікіпедія, вільна енциклопедія"
- },
- "searchUrl": {
- "message": "https://uk.wikipedia.org/wiki/Спеціальна:Пошук"
- },
- "searchForm": {
- "message": "https://uk.wikipedia.org/wiki/Спеціальна:Пошук?search={searchTerms}&sourcei…"
- },
- "suggestUrl": {
- "message": "https://uk.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/ur/messages.json b/browser/components/search/extensions/wikipedia/_locales/ur/messages.json
deleted file mode 100644
index dcc87e0c853c..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/ur/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "ویکیپیڈیا (ur)"
- },
- "extensionDescription": {
- "message": "ویکیپیڈیا آزاد دائرۃ المعارف"
- },
- "searchUrl": {
- "message": "https://ur.wikipedia.org/wiki/خاص:تلاش"
- },
- "searchForm": {
- "message": "https://ur.wikipedia.org/wiki/خاص:تلاش?search={searchTerms}&sourceid=Mozill…"
- },
- "suggestUrl": {
- "message": "https://ur.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/uz/messages.json b/browser/components/search/extensions/wikipedia/_locales/uz/messages.json
deleted file mode 100644
index 89a8f2a89bca..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/uz/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Vikipediya (uz)"
- },
- "extensionDescription": {
- "message": "Vikipediya, ochiq ensiklopediya"
- },
- "searchUrl": {
- "message": "https://uz.wikipedia.org/wiki/Maxsus:Search"
- },
- "searchForm": {
- "message": "https://uz.wikipedia.org/wiki/Maxsus:Search?search={searchTerms}&sourceid=M…"
- },
- "suggestUrl": {
- "message": "https://uz.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/vi/messages.json b/browser/components/search/extensions/wikipedia/_locales/vi/messages.json
deleted file mode 100644
index c0844e4feb14..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/vi/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (vi)"
- },
- "extensionDescription": {
- "message": "Wikipedia, bách khoa toàn thư mở"
- },
- "searchUrl": {
- "message": "https://vi.wikipedia.org/wiki/Đặc_biệt:Tìm_kiếm"
- },
- "searchForm": {
- "message": "https://vi.wikipedia.org/wiki/Đặc_biệt:Tìm_kiếm?search={searchTerms}&source…"
- },
- "suggestUrl": {
- "message": "https://vi.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/wo/messages.json b/browser/components/search/extensions/wikipedia/_locales/wo/messages.json
deleted file mode 100644
index 7efde3b1d0f4..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/wo/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (wo)"
- },
- "extensionDescription": {
- "message": "Wikipedia, Jimbulang bu Ubbeeku bi"
- },
- "searchUrl": {
- "message": "https://wo.wikipedia.org/wiki/Jagleel:Ceet"
- },
- "searchForm": {
- "message": "https://wo.wikipedia.org/wiki/Jagleel:Ceet?search={searchTerms}&sourceid=Mo…"
- },
- "suggestUrl": {
- "message": "https://wo.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/zh-CN/messages.json b/browser/components/search/extensions/wikipedia/_locales/zh-CN/messages.json
deleted file mode 100644
index 29047565a243..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/zh-CN/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "维基百科"
- },
- "extensionDescription": {
- "message": "维基百科,自由的百科全书"
- },
- "searchUrl": {
- "message": "https://zh.wikipedia.org/wiki/Special:搜索"
- },
- "searchForm": {
- "message": "https://zh.wikipedia.org/wiki/Special:搜索?search={searchTerms}&sourceid=Mozi…"
- },
- "suggestUrl": {
- "message": "https://zh.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/_locales/zh-TW/messages.json b/browser/components/search/extensions/wikipedia/_locales/zh-TW/messages.json
deleted file mode 100644
index a0e8d880ea26..000000000000
--- a/browser/components/search/extensions/wikipedia/_locales/zh-TW/messages.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "extensionName": {
- "message": "Wikipedia (zh)"
- },
- "extensionDescription": {
- "message": "維基百科,自由的百科全書"
- },
- "searchUrl": {
- "message": "https://zh.wikipedia.org/wiki/Special:搜索"
- },
- "searchForm": {
- "message": "https://zh.wikipedia.org/wiki/Special:搜索?search={searchTerms}&sourceid=Mozi…"
- },
- "suggestUrl": {
- "message": "https://zh.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
- },
- "searchUrlGetParams": {
- "message": "search={searchTerms}&sourceid=Mozilla-search&variant=zh-tw"
- }
-}
\ No newline at end of file
diff --git a/browser/components/search/extensions/wikipedia/manifest.json b/browser/components/search/extensions/wikipedia/manifest.json
index cd95d3aa9e1c..0af3b2a1c211 100644
--- a/browser/components/search/extensions/wikipedia/manifest.json
+++ b/browser/components/search/extensions/wikipedia/manifest.json
@@ -1,6 +1,6 @@
{
- "name": "__MSG_extensionName__",
- "description": "__MSG_extensionDescription__",
+ "name": "Wikipedia (en)",
+ "description": "Wikipedia, the Free Encyclopedia",
"manifest_version": 2,
"version": "1.1",
"applications": {
@@ -9,7 +9,6 @@
}
},
"hidden": true,
- "default_locale": "en",
"icons": {
"16": "favicon.ico"
},
@@ -19,11 +18,11 @@
"chrome_settings_overrides": {
"search_provider": {
"keyword": "@wikipedia",
- "name": "__MSG_extensionName__",
- "search_url": "__MSG_searchUrl__",
- "search_form": "__MSG_searchForm__",
- "suggest_url": "__MSG_suggestUrl__",
- "search_url_get_params": "__MSG_searchUrlGetParams__"
+ "name": "Wikipedia (en)",
+ "search_url": "https://en.wikipedia.org/wiki/Special:Search",
+ "search_form": "https://en.wikipedia.org/wiki/Special:Search?search={searchTerms}&sourceid=…",
+ "suggest_url": "https://en.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}",
+ "search_url_get_params": "search={searchTerms}&sourceid=Mozilla-search"
}
}
}
diff --git a/browser/components/search/extensions/yahoo/favicon.ico b/browser/components/search/extensions/yahoo/favicon.ico
new file mode 100644
index 000000000000..9bd1d9f7c008
Binary files /dev/null and b/browser/components/search/extensions/yahoo/favicon.ico differ
diff --git a/browser/components/search/extensions/yahoo/manifest.json b/browser/components/search/extensions/yahoo/manifest.json
new file mode 100644
index 000000000000..e1f04a373c2e
--- /dev/null
+++ b/browser/components/search/extensions/yahoo/manifest.json
@@ -0,0 +1,28 @@
+{
+ "name": "Yahoo",
+ "description": "Yahoo Search",
+ "manifest_version": 2,
+ "version": "1.0",
+ "applications": {
+ "gecko": {
+ "id": "yahoo(a)search.mozilla.org"
+ }
+ },
+ "hidden": true,
+ "icons": {
+ "16": "favicon.ico"
+ },
+ "web_accessible_resources": [
+ "favicon.ico"
+ ],
+ "chrome_settings_overrides": {
+ "search_provider": {
+ "name": "Yahoo",
+ "search_url": "https://search.yahoo.com/yhs/search",
+ "search_form": "https://search.yahoo.com/yhs/search?p={searchTerms}&ei=UTF-8&hspart=mozilla",
+ "search_url_get_params": "p={searchTerms}&ei=UTF-8&hspart=mozilla",
+ "suggest_url": "https://search.yahoo.com/sugg/ff",
+ "suggest_url_get_params": "output=fxjson&appid=ffd&command={searchTerms}"
+ }
+ }
+}
diff --git a/browser/components/search/extensions/youtube/favicon.ico b/browser/components/search/extensions/youtube/favicon.ico
new file mode 100644
index 000000000000..977887dbbb84
Binary files /dev/null and b/browser/components/search/extensions/youtube/favicon.ico differ
diff --git a/browser/components/search/extensions/youtube/manifest.json b/browser/components/search/extensions/youtube/manifest.json
new file mode 100644
index 000000000000..6fbf8745bac2
--- /dev/null
+++ b/browser/components/search/extensions/youtube/manifest.json
@@ -0,0 +1,26 @@
+{
+ "name": "YouTube",
+ "description": "YouTube - Videos",
+ "manifest_version": 2,
+ "version": "1.0",
+ "applications": {
+ "gecko": {
+ "id": "youtube(a)search.mozilla.org"
+ }
+ },
+ "hidden": true,
+ "icons": {
+ "16": "favicon.ico"
+ },
+ "web_accessible_resources": [
+ "favicon.ico"
+ ],
+ "chrome_settings_overrides": {
+ "search_provider": {
+ "name": "YouTube",
+ "search_url": "https://www.youtube.com/results?search_query={searchTerms}&search=Search",
+ "search_form": "https://www.youtube.com/index",
+ "suggest_url": "https://suggestqueries.google.com/complete/search?output=firefox&ds=yt&q={s…"
+ }
+ }
+}
\ No newline at end of file
diff --git a/tbb-tests/browser_tor_omnibox.js b/tbb-tests/browser_tor_omnibox.js
new file mode 100644
index 000000000000..3bb90f51a305
--- /dev/null
+++ b/tbb-tests/browser_tor_omnibox.js
@@ -0,0 +1,20 @@
+// # Test Tor Omnibox
+// Check what search engines are installed in the search box.
+
+add_task(async function() {
+ // Grab engine IDs.
+ let browserSearchService = Components.classes["@mozilla.org/browser/search-service;1"]
+ .getService(Components.interfaces.nsISearchService),
+ engineIDs = (await browserSearchService.getEngines()).map(e => e.identifier);
+
+ // Check that we have the correct engines installed, in the right order.
+ is(engineIDs[0], "ddg", "Default search engine is duckduckgo");
+ is(engineIDs[1], "youtube", "Secondary search engine is youtube");
+ is(engineIDs[2], "google", "Google is third search engine");
+ is(engineIDs[3], "blockchair", "Blockchair is fourth search engine");
+ is(engineIDs[4], "ddg-onion", "Duck Duck Go Onion is fifth search engine");
+ is(engineIDs[5], "startpage", "Startpage is sixth search engine");
+ is(engineIDs[6], "twitter", "Twitter is sixth search engine");
+ is(engineIDs[7], "wikipedia", "Wikipedia is seventh search engine");
+ is(engineIDs[8], "yahoo", "Yahoo is eighth search engine");
+});
diff --git a/toolkit/components/search/SearchService.jsm b/toolkit/components/search/SearchService.jsm
index 58c3eaec2c3e..80142536e8a9 100644
--- a/toolkit/components/search/SearchService.jsm
+++ b/toolkit/components/search/SearchService.jsm
@@ -19,7 +19,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
Region: "resource://gre/modules/Region.jsm",
RemoteSettings: "resource://services-settings/remote-settings.js",
SearchEngine: "resource://gre/modules/SearchEngine.jsm",
- SearchEngineSelector: "resource://gre/modules/SearchEngineSelector.jsm",
SearchSettings: "resource://gre/modules/SearchSettings.jsm",
SearchStaticData: "resource://gre/modules/SearchStaticData.jsm",
SearchUtils: "resource://gre/modules/SearchUtils.jsm",
@@ -248,11 +247,6 @@ SearchService.prototype = {
Services.obs.addObserver(this, Region.REGION_TOPIC);
try {
- // Create the search engine selector.
- this._engineSelector = new SearchEngineSelector(
- this._handleConfigurationUpdated.bind(this)
- );
-
// See if we have a settings file so we don't have to parse a bunch of XML.
let settings = await this._settings.get();
@@ -1055,16 +1049,18 @@ SearchService.prototype = {
? "esr"
: AppConstants.MOZ_UPDATE_CHANNEL;
- let {
- engines,
- privateDefault,
- } = await this._engineSelector.fetchEngineConfiguration({
- locale,
- region,
- channel,
- experiment: gExperiment,
- distroID: SearchUtils.distroID,
- });
+ const engines = [
+ { webExtension: { id: "ddg(a)search.mozilla.org" }, orderHint: 100 },
+ { webExtension: { id: "youtube(a)search.mozilla.org" }, orderHint: 90 },
+ { webExtension: { id: "google(a)search.mozilla.org" }, orderHint: 80 },
+ { webExtension: { id: "blockchair(a)search.mozilla.org" }, orderHint: 70 },
+ { webExtension: { id: "ddg-onion(a)search.mozilla.org" }, orderHint: 60 },
+ { webExtension: { id: "blockchair-onion(a)search.mozilla.org" }, orderHint: 50 },
+ { webExtension: { id: "startpage(a)search.mozilla.org" }, orderHint: 40 },
+ { webExtension: { id: "twitter(a)search.mozilla.org" }, orderHint: 30 },
+ { webExtension: { id: "wikipedia(a)search.mozilla.org" }, orderHint: 20 },
+ { webExtension: { id: "yahoo(a)search.mozilla.org" }, orderHint: 10 },
+ ];
for (let e of engines) {
if (!e.webExtension) {
@@ -1073,7 +1069,7 @@ SearchService.prototype = {
e.webExtension.locale = e.webExtension?.locale ?? SearchUtils.DEFAULT_TAG;
}
- return { engines, privateDefault };
+ return { engines, privateDefault: undefined };
},
_setDefaultAndOrdersFromSelector(engines, privateDefault) {
diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
index fd1e3f75935d..dea49a8e9f79 100644
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -959,6 +959,12 @@ var BuiltInLocation = new (class _BuiltInLocation extends XPIStateLocation {
isLinkedAddon(/* aId */) {
return false;
}
+
+ restore(saved) {
+ super.restore(saved);
+ // Bug 33342: avoid restoring disconnect addon from addonStartup.json.lz4.
+ this.removeAddon("disconnect(a)search.mozilla.org");
+ }
})();
/**
1
0

[tor-browser/tor-browser-91.5.0esr-11.5-2] Bug 4234: Use the Firefox Update Process for Tor Browser.
by richard@torproject.org 01 Feb '22
by richard@torproject.org 01 Feb '22
01 Feb '22
commit 8f98035c77e69b69c3396cabce15e90bb7f96d18
Author: Kathy Brade <brade(a)pearlcrescent.com>
Date: Fri Jan 13 11:40:24 2017 -0500
Bug 4234: Use the Firefox Update Process for Tor Browser.
The following files are never updated:
TorBrowser/Data/Browser/profiles.ini
TorBrowser/Data/Browser/profile.default/bookmarks.html
TorBrowser/Data/Tor/torrc
Mac OS: Store update metadata under TorBrowser/UpdateInfo.
Removed the %OS_VERSION% component from the update URL (13047) and
added support for minSupportedOSVersion, an attribute of the
<update> element that may be used to trigger Firefox's
"unsupported platform" behavior.
Hide the "What's new" links (set app.releaseNotesURL value to about:blank).
Windows: disable "runas" code path in updater (15201).
Windows: avoid writing to the registry (16236).
Also includes fixes for tickets 13047, 13301, 13356, 13594, 15406,
16014, 16909, 24476, and 25909.
Also fix Bug 26049: reduce the delay before the update prompt is displayed.
Instead of Firefox's 2 days, we use 1 hour (after which time the update
doorhanger will be displayed).
Also fix bug 27221: purge the startup cache if the Tor Browser
version changed (even if the Firefox version and build ID did
not change), e.g., after a minor Tor Browser update.
Also fix 32616: Disable GetSecureOutputDirectoryPath() functionality.
Bug 26048: potentially confusing "restart to update" message
Within the update doorhanger, remove the misleading message that mentions
that windows will be restored after an update is applied, and replace the
"Restart and Restore" button label with an existing
"Restart to update Tor Browser" string.
Bug 28885: notify users that update is downloading
Add a "Downloading Tor Browser update" item which appears in the
hamburger (app) menu while the update service is downloading a MAR
file. Before this change, the browser did not indicate to the user
that an update was in progress, which is especially confusing in
Tor Browser because downloads often take some time. If the user
clicks on the new menu item, the about dialog is opened to allow
the user to see download progress.
As part of this fix, the update service was changed to always show
update-related messages in the hamburger menu, even if the update
was started in the foreground via the about dialog or via the
"Check for Tor Browser Update" toolbar menu item. This change is
consistent with the Tor Browser goal of making sure users are
informed about the update process.
Removed #28885 parts of this patch which have been uplifted to Firefox.
---
browser/app/Makefile.in | 2 +
browser/app/profile/000-tor-browser.js | 16 +-
browser/app/profile/firefox.js | 10 +-
browser/base/content/aboutDialog-appUpdater.js | 2 +-
browser/base/content/aboutDialog.js | 12 +-
browser/components/BrowserContentHandler.jsm | 39 ++-
.../customizableui/content/panelUI.inc.xhtml | 2 +-
browser/confvars.sh | 35 +--
browser/installer/package-manifest.in | 2 +
build/application.ini.in | 2 +-
build/moz.configure/init.configure | 3 +-
config/createprecomplete.py | 18 +-
.../client/aboutdebugging/src/actions/runtimes.js | 5 +
toolkit/modules/UpdateUtils.jsm | 22 +-
toolkit/mozapps/extensions/AddonManager.jsm | 24 ++
toolkit/mozapps/extensions/test/browser/head.js | 1 +
.../extensions/test/xpcshell/head_addons.js | 1 +
toolkit/mozapps/update/UpdateService.jsm | 125 +++++++-
toolkit/mozapps/update/UpdateServiceStub.jsm | 4 +
toolkit/mozapps/update/common/updatehelper.cpp | 8 +
toolkit/mozapps/update/moz.build | 5 +-
toolkit/mozapps/update/updater/launchchild_osx.mm | 2 +
toolkit/mozapps/update/updater/moz.build | 2 +-
toolkit/mozapps/update/updater/updater.cpp | 339 ++++++++++++++++++---
toolkit/xre/MacLaunchHelper.h | 2 +
toolkit/xre/MacLaunchHelper.mm | 2 +
toolkit/xre/nsAppRunner.cpp | 22 +-
toolkit/xre/nsUpdateDriver.cpp | 109 ++++++-
toolkit/xre/nsXREDirProvider.cpp | 42 ++-
tools/update-packaging/common.sh | 64 ++--
tools/update-packaging/make_full_update.sh | 25 ++
tools/update-packaging/make_incremental_update.sh | 71 ++++-
32 files changed, 874 insertions(+), 144 deletions(-)
diff --git a/browser/app/Makefile.in b/browser/app/Makefile.in
index 8dd3a9a65661..3a5550c96c15 100644
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -97,10 +97,12 @@ tools repackage:: $(DIST)/bin/$(MOZ_APP_NAME) $(objdir)/macbuild/Contents/MacOS-
rsync -aL $(DIST)/bin/$(MOZ_APP_NAME) '$(dist_dest)/Contents/MacOS'
cp -RL $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/firefox.icns '$(dist_dest)/Contents/Resources/firefox.icns'
cp -RL $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/document.icns '$(dist_dest)/Contents/Resources/document.icns'
+ifndef TOR_BROWSER_UPDATE
$(MKDIR) -p '$(dist_dest)/Contents/Library/LaunchServices'
ifdef MOZ_UPDATER
mv -f '$(dist_dest)/Contents/MacOS/updater.app/Contents/MacOS/org.mozilla.updater' '$(dist_dest)/Contents/Library/LaunchServices'
ln -s ../../../../Library/LaunchServices/org.mozilla.updater '$(dist_dest)/Contents/MacOS/updater.app/Contents/MacOS/org.mozilla.updater'
+endif
endif
printf APPLTORB > '$(dist_dest)/Contents/PkgInfo'
endif
diff --git a/browser/app/profile/000-tor-browser.js b/browser/app/profile/000-tor-browser.js
index aac1da85e24e..e42b9efc1b79 100644
--- a/browser/app/profile/000-tor-browser.js
+++ b/browser/app/profile/000-tor-browser.js
@@ -7,7 +7,6 @@
// Disable initial homepage notifications
pref("browser.search.update", false);
pref("browser.rights.3.shown", true);
-pref("browser.startup.homepage_override.mstone", "ignore");
pref("startup.homepage_welcome_url", "");
pref("startup.homepage_welcome_url.additional", "");
@@ -23,9 +22,17 @@ pref("startup.homepage_override_url", "https://blog.torproject.org/category/appl
// Try to nag a bit more about updates: Pop up a restart dialog an hour after the initial dialog
pref("app.update.promptWaitTime", 3600);
-
-#ifdef XP_WIN
-// For now, disable staged updates on Windows (see #18292).
+pref("app.update.notifyDuringDownload", true);
+pref("app.update.url.manual", "https://www.torproject.org/download/languages/");
+pref("app.update.url.details", "https://www.torproject.org/download/");
+pref("app.update.badgeWaitTime", 0);
+pref("app.releaseNotesURL", "about:blank");
+
+#ifndef XP_MACOSX
+// Disable staged updates on platforms other than macOS.
+// Staged updates do not work on Windows due to #18292.
+// Also, on Windows and Linux any changes that are made to the browser profile
+// or Tor data after an update is staged will be lost.
pref("app.update.staging.enabled", false);
#endif
@@ -85,6 +92,7 @@ pref("datareporting.policy.dataSubmissionEnabled", false);
// Make sure Unified Telemetry is really disabled, see: #18738.
pref("toolkit.telemetry.unified", false);
pref("toolkit.telemetry.enabled", false);
+pref("toolkit.telemetry.updatePing.enabled", false); // Make sure updater telemetry is disabled; see #25909.
#ifdef XP_WIN
// Defense-in-depth: ensure that the Windows default browser agent will
// not ping Mozilla if it is somehow present (we omit it at build time).
diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
index 3f90fcad3602..944a68bcd67a 100644
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -130,14 +130,8 @@ pref("app.update.elevation.promptMaxAttempts", 2);
pref("app.update.notifyDuringDownload", false);
// If set to true, the Update Service will automatically download updates if the
-// user can apply updates. This pref is no longer used on Windows, except as the
-// default value to migrate to the new location that this data is now stored
-// (which is in a file in the update directory). Because of this, this pref
-// should no longer be used directly. Instead, getAppUpdateAutoEnabled and
-// getAppUpdateAutoEnabled from UpdateUtils.jsm should be used.
-#ifndef XP_WIN
- pref("app.update.auto", true);
-#endif
+// user can apply updates.
+pref("app.update.auto", true);
// If set to true, the Update Service will apply updates in the background
// when it finishes downloading them.
diff --git a/browser/base/content/aboutDialog-appUpdater.js b/browser/base/content/aboutDialog-appUpdater.js
index 6d7e9a5e5b7e..b5d5a5d38628 100644
--- a/browser/base/content/aboutDialog-appUpdater.js
+++ b/browser/base/content/aboutDialog-appUpdater.js
@@ -165,7 +165,7 @@ appUpdater.prototype = {
if (aChildID == "downloadAndInstall") {
let updateVersion = gAppUpdater.update.displayVersion;
// Include the build ID if this is an "a#" (nightly or aurora) build
- if (/a\d+$/.test(updateVersion)) {
+ if (!AppConstants.TOR_BROWSER_UPDATE && /a\d+$/.test(updateVersion)) {
let buildID = gAppUpdater.update.buildID;
let year = buildID.slice(0, 4);
let month = buildID.slice(4, 6);
diff --git a/browser/base/content/aboutDialog.js b/browser/base/content/aboutDialog.js
index 37a0ebc4f4a4..4e8a9195e6a8 100644
--- a/browser/base/content/aboutDialog.js
+++ b/browser/base/content/aboutDialog.js
@@ -56,15 +56,13 @@ async function init(aEvent) {
bits: Services.appinfo.is64Bit ? 64 : 32,
};
+ // Adjust version text to show the Tor Browser version
+ versionAttributes.version = AppConstants.TOR_BROWSER_VERSION +
+ " (based on Mozilla Firefox " +
+ AppConstants.MOZ_APP_VERSION_DISPLAY + ")";
+
let version = Services.appinfo.version;
if (/a\d+$/.test(version)) {
- versionId = "aboutDialog-version-nightly";
- let buildID = Services.appinfo.appBuildID;
- let year = buildID.slice(0, 4);
- let month = buildID.slice(4, 6);
- let day = buildID.slice(6, 8);
- versionAttributes.isodate = `${year}-${month}-${day}`;
-
document.getElementById("experimental").hidden = false;
document.getElementById("communityDesc").hidden = true;
}
diff --git a/browser/components/BrowserContentHandler.jsm b/browser/components/BrowserContentHandler.jsm
index 97417d86cd7f..d8e24e641447 100644
--- a/browser/components/BrowserContentHandler.jsm
+++ b/browser/components/BrowserContentHandler.jsm
@@ -44,6 +44,8 @@ XPCOMUtils.defineLazyGetter(this, "gSystemPrincipal", () =>
);
XPCOMUtils.defineLazyGlobalGetters(this, [URL]);
+const kTBSavedVersionPref = "browser.startup.homepage_override.torbrowser.version";
+
// One-time startup homepage override configurations
const ONCE_DOMAINS = ["mozilla.org", "firefox.com"];
const ONCE_PREF = "browser.startup.homepage_override.once";
@@ -102,7 +104,8 @@ const OVERRIDE_NEW_BUILD_ID = 3;
* Returns:
* OVERRIDE_NEW_PROFILE if this is the first run with a new profile.
* OVERRIDE_NEW_MSTONE if this is the first run with a build with a different
- * Gecko milestone (i.e. right after an upgrade).
+ * Gecko milestone or Tor Browser version (i.e. right
+ * after an upgrade).
* OVERRIDE_NEW_BUILD_ID if this is the first run with a new build ID of the
* same Gecko milestone (i.e. after a nightly upgrade).
* OVERRIDE_NONE otherwise.
@@ -119,6 +122,11 @@ function needHomepageOverride(prefb) {
var mstone = Services.appinfo.platformVersion;
+ var savedTBVersion = null;
+ try {
+ savedTBVersion = prefb.getCharPref(kTBSavedVersionPref);
+ } catch (e) {}
+
var savedBuildID = prefb.getCharPref(
"browser.startup.homepage_override.buildID",
""
@@ -140,7 +148,22 @@ function needHomepageOverride(prefb) {
prefb.setCharPref("browser.startup.homepage_override.mstone", mstone);
prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
- return savedmstone ? OVERRIDE_NEW_MSTONE : OVERRIDE_NEW_PROFILE;
+ prefb.setCharPref(kTBSavedVersionPref, AppConstants.TOR_BROWSER_VERSION);
+
+ // After an upgrade from an older release of Tor Browser (<= 5.5a1), the
+ // savedmstone will be undefined because those releases included the
+ // value "ignore" for the browser.startup.homepage_override.mstone pref.
+ // To correctly detect an upgrade vs. a new profile, we check for the
+ // presence of the "app.update.postupdate" pref.
+ let updated = prefb.prefHasUserValue("app.update.postupdate");
+ return (savedmstone || updated) ? OVERRIDE_NEW_MSTONE
+ : OVERRIDE_NEW_PROFILE;
+ }
+
+ if (AppConstants.TOR_BROWSER_VERSION != savedTBVersion) {
+ prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
+ prefb.setCharPref(kTBSavedVersionPref, AppConstants.TOR_BROWSER_VERSION);
+ return OVERRIDE_NEW_MSTONE;
}
if (buildID != savedBuildID) {
@@ -624,6 +647,13 @@ nsBrowserContentHandler.prototype = {
"browser.startup.homepage_override.buildID",
"unknown"
);
+
+ // We do the same for the Tor Browser version.
+ let old_tbversion = null;
+ try {
+ old_tbversion = prefb.getCharPref(kTBSavedVersionPref);
+ } catch (e) {}
+
override = needHomepageOverride(prefb);
if (override != OVERRIDE_NONE) {
switch (override) {
@@ -650,9 +680,10 @@ nsBrowserContentHandler.prototype = {
"startup.homepage_override_url"
);
let update = UpdateManager.readyUpdate;
+ let old_version = old_tbversion ? old_tbversion: old_mstone;
if (
update &&
- Services.vc.compare(update.appVersion, old_mstone) > 0
+ Services.vc.compare(update.appVersion, old_version) > 0
) {
overridePage = getPostUpdateOverridePage(update, overridePage);
// Send the update ping to signal that the update was successful.
@@ -660,6 +691,8 @@ nsBrowserContentHandler.prototype = {
}
overridePage = overridePage.replace("%OLD_VERSION%", old_mstone);
+ overridePage = overridePage.replace("%OLD_TOR_BROWSER_VERSION%",
+ old_tbversion);
break;
case OVERRIDE_NEW_BUILD_ID:
if (UpdateManager.readyUpdate) {
diff --git a/browser/components/customizableui/content/panelUI.inc.xhtml b/browser/components/customizableui/content/panelUI.inc.xhtml
index dca3ae14a6ff..e71acbf4ae65 100644
--- a/browser/components/customizableui/content/panelUI.inc.xhtml
+++ b/browser/components/customizableui/content/panelUI.inc.xhtml
@@ -153,7 +153,7 @@
hasicon="true"
hidden="true">
<popupnotificationcontent id="update-restart-notification-content" orient="vertical">
- <description id="update-restart-description" data-lazy-l10n-id="appmenu-update-restart-message2"></description>
+ <description id="update-restart-description"> </description>
</popupnotificationcontent>
</popupnotification>
diff --git a/browser/confvars.sh b/browser/confvars.sh
index 92871c9516f9..040a27e9b92d 100755
--- a/browser/confvars.sh
+++ b/browser/confvars.sh
@@ -6,26 +6,6 @@
MOZ_APP_VENDOR=Mozilla
MOZ_UPDATER=1
-if test "$OS_ARCH" = "WINNT"; then
- if ! test "$HAVE_64BIT_BUILD"; then
- if test "$MOZ_UPDATE_CHANNEL" = "nightly" -o \
- "$MOZ_UPDATE_CHANNEL" = "nightly-try" -o \
- "$MOZ_UPDATE_CHANNEL" = "aurora" -o \
- "$MOZ_UPDATE_CHANNEL" = "beta" -o \
- "$MOZ_UPDATE_CHANNEL" = "release"; then
- if ! test "$MOZ_DEBUG"; then
- if ! test "$USE_STUB_INSTALLER"; then
- # Expect USE_STUB_INSTALLER from taskcluster for downstream task consistency
- echo "ERROR: STUB installer expected to be enabled but"
- echo "ERROR: USE_STUB_INSTALLER is not specified in the environment"
- exit 1
- fi
- MOZ_STUB_INSTALLER=1
- fi
- fi
- fi
-fi
-
BROWSER_CHROME_URL=chrome://browser/content/browser.xhtml
# MOZ_APP_DISPLAYNAME will be set by branding/configure.sh
@@ -38,6 +18,21 @@ MOZ_BRANDING_DIRECTORY=browser/branding/unofficial
MOZ_OFFICIAL_BRANDING_DIRECTORY=browser/branding/official
MOZ_APP_ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
+# ACCEPTED_MAR_CHANNEL_IDS should usually be the same as the value MAR_CHANNEL_ID.
+# If more than one ID is needed, then you should use a comma separated list
+# of values.
+# The MAR_CHANNEL_ID must not contain the following 3 characters: ",\t "
+if test "$MOZ_UPDATE_CHANNEL" = "alpha"; then
+ ACCEPTED_MAR_CHANNEL_IDS=torbrowser-torproject-alpha
+ MAR_CHANNEL_ID=torbrowser-torproject-alpha
+elif test "$MOZ_UPDATE_CHANNEL" = "nightly"; then
+ ACCEPTED_MAR_CHANNEL_IDS=torbrowser-torproject-nightly
+ MAR_CHANNEL_ID=torbrowser-torproject-nightly
+else
+ ACCEPTED_MAR_CHANNEL_IDS=torbrowser-torproject-release
+ MAR_CHANNEL_ID=torbrowser-torproject-release
+fi
+
MOZ_PROFILE_MIGRATOR=1
# Include the DevTools client, not just the server (which is the default)
diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in
index d46707ca8720..8009a4d83ec5 100644
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -36,8 +36,10 @@
; Mac bundle stuff
@APPNAME@/Contents/Info.plist
#ifdef MOZ_UPDATER
+#ifndef TOR_BROWSER_UPDATE
@APPNAME@/Contents/Library/LaunchServices
#endif
+#endif
@APPNAME@/Contents/PkgInfo
@RESPATH@/firefox.icns
@RESPATH@/document.icns
diff --git a/build/application.ini.in b/build/application.ini.in
index 6df13230a45b..9a0b162d447d 100644
--- a/build/application.ini.in
+++ b/build/application.ini.in
@@ -52,5 +52,5 @@ ServerURL=@MOZ_CRASHREPORTER_URL@/submit?id=@MOZ_APP_ID@&version=@MOZ_APP_VERSIO
#if MOZ_UPDATER
[AppUpdate]
-URL=https://@MOZ_APPUPDATE_HOST@/update/6/%PRODUCT%/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%SYSTEM_CAPABILITIES%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/update.xml
+URL=https://aus1.torproject.org/torbrowser/update_3/%CHANNEL%/%BUILD_TARGET%/%VERSION%/%LOCALE%
#endif
diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure
index 3a164c655871..0c2c00faa593 100644
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -1177,7 +1177,6 @@ def version_path(path):
# set RELEASE_OR_BETA and NIGHTLY_BUILD variables depending on the cycle we're in
# The logic works like this:
# - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
-# - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
# - otherwise, we're building Release/Beta (define RELEASE_OR_BETA)
@depends(check_build_environment, build_project, version_path, "--help")
@imports(_from="__builtin__", _import="open")
@@ -1224,7 +1223,7 @@ def milestone(build_env, build_project, version_path, _):
if "a1" in milestone:
is_nightly = True
- elif "a" not in milestone:
+ else:
is_release_or_beta = True
major_version = milestone.split(".")[0]
diff --git a/config/createprecomplete.py b/config/createprecomplete.py
index dda4efcdf8e1..e7405b21b61b 100644
--- a/config/createprecomplete.py
+++ b/config/createprecomplete.py
@@ -5,6 +5,7 @@
# update instructions which is used to remove files and directories that are no
# longer present in a complete update. The current working directory is used for
# the location to enumerate and to create the precomplete file.
+# For symlinks, remove instructions are always generated.
from __future__ import absolute_import
from __future__ import unicode_literals
@@ -13,9 +14,17 @@ import os
import io
+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
+# we should remove all lines in this file that contain:
+# TorBrowser/Data
+
def get_build_entries(root_path):
"""Iterates through the root_path, creating a list for each file and
directory. Excludes any file paths ending with channel-prefs.js.
+ To support Tor Browser updates, excludes:
+ TorBrowser/Data/Browser/profiles.ini
+ TorBrowser/Data/Browser/profile.default/bookmarks.html
+ TorBrowser/Data/Tor/torrc
"""
rel_file_path_set = set()
rel_dir_path_set = set()
@@ -27,6 +36,10 @@ def get_build_entries(root_path):
if not (
rel_path_file.endswith("channel-prefs.js")
or rel_path_file.endswith("update-settings.ini")
+ or rel_path_file == "TorBrowser/Data/Browser/profiles.ini"
+ or rel_path_file
+ == "TorBrowser/Data/Browser/profile.default/bookmarks.html"
+ or rel_path_file == "TorBrowser/Data/Tor/torrc"
or rel_path_file.find("distribution/") != -1
):
rel_file_path_set.add(rel_path_file)
@@ -36,7 +49,10 @@ def get_build_entries(root_path):
rel_path_dir = os.path.join(parent_dir_rel_path, dir_name)
rel_path_dir = rel_path_dir.replace("\\", "/") + "/"
if rel_path_dir.find("distribution/") == -1:
- rel_dir_path_set.add(rel_path_dir)
+ if os.path.islink(rel_path_dir[:-1]):
+ rel_file_path_set.add(rel_path_dir[:-1])
+ else:
+ rel_dir_path_set.add(rel_path_dir)
rel_file_path_list = list(rel_file_path_set)
rel_file_path_list.sort(reverse=True)
diff --git a/devtools/client/aboutdebugging/src/actions/runtimes.js b/devtools/client/aboutdebugging/src/actions/runtimes.js
index 3d9ce0490bf2..00dff36f28a2 100644
--- a/devtools/client/aboutdebugging/src/actions/runtimes.js
+++ b/devtools/client/aboutdebugging/src/actions/runtimes.js
@@ -71,6 +71,11 @@ async function getRuntimeIcon(runtime, channel) {
}
}
+ // Use the release build skin for devtools within Tor Browser alpha releases.
+ if (channel === "alpha") {
+ return "chrome://devtools/skin/images/aboutdebugging-firefox-release.svg";
+ }
+
return channel === "release" || channel === "beta" || channel === "aurora"
? `chrome://devtools/skin/images/aboutdebugging-firefox-${channel}.svg`
: "chrome://devtools/skin/images/aboutdebugging-firefox-nightly.svg";
diff --git a/toolkit/modules/UpdateUtils.jsm b/toolkit/modules/UpdateUtils.jsm
index a1a2ac7898fb..fa840d6c0b2d 100644
--- a/toolkit/modules/UpdateUtils.jsm
+++ b/toolkit/modules/UpdateUtils.jsm
@@ -96,7 +96,7 @@ var UpdateUtils = {
case "PRODUCT":
return Services.appinfo.name;
case "VERSION":
- return Services.appinfo.version;
+ return AppConstants.TOR_BROWSER_VERSION;
case "BUILD_ID":
return Services.appinfo.appBuildID;
case "BUILD_TARGET":
@@ -160,7 +160,8 @@ var UpdateUtils = {
* downloads and installs updates. This corresponds to whether or not the user
* has selected "Automatically install updates" in about:preferences.
*
- * On Windows, this setting is shared across all profiles for the installation
+ * On Windows (except in Tor Browser), this setting is shared across all profiles
+ * for the installation
* and is read asynchronously from the file. On other operating systems, this
* setting is stored in a pref and is thus a per-profile setting.
*
@@ -176,7 +177,8 @@ var UpdateUtils = {
* updates" and "Check for updates but let you choose to install them" options
* in about:preferences.
*
- * On Windows, this setting is shared across all profiles for the installation
+ * On Windows (except in Tor Browser), this setting is shared across all profiles
+ * for the installation
* and is written asynchronously to the file. On other operating systems, this
* setting is stored in a pref and is thus a per-profile setting.
*
@@ -248,7 +250,7 @@ var UpdateUtils = {
// setting is just to propagate it from a pref observer. This ensures that
// the expected observers still get notified, even if a user manually
// changes the pref value.
- if (!UpdateUtils.PER_INSTALLATION_PREFS_SUPPORTED) {
+ if (AppConstants.TOR_BROWSER_UPDATE || !UpdateUtils.PER_INSTALLATION_PREFS_SUPPORTED) {
let initialConfig = {};
for (const [prefName, pref] of Object.entries(
UpdateUtils.PER_INSTALLATION_PREFS
@@ -317,7 +319,7 @@ var UpdateUtils = {
}
}
- if (!this.PER_INSTALLATION_PREFS_SUPPORTED) {
+ if (AppConstants.TOR_BROWSER_UPDATE || !this.PER_INSTALLATION_PREFS_SUPPORTED) {
// If we don't have per-installation prefs, we use regular preferences.
let prefValue = prefTypeFns.getProfilePref(prefName, pref.defaultValue);
return Promise.resolve(prefValue);
@@ -413,7 +415,7 @@ var UpdateUtils = {
);
}
- if (!this.PER_INSTALLATION_PREFS_SUPPORTED) {
+ if (AppConstants.TOR_BROWSER_UPDATE || !this.PER_INSTALLATION_PREFS_SUPPORTED) {
// If we don't have per-installation prefs, we use regular preferences.
if (options.setDefaultOnly) {
prefTypeFns.setProfileDefaultPref(prefName, value);
@@ -549,14 +551,6 @@ UpdateUtils.PER_INSTALLATION_PREFS = {
migrate: true,
observerTopic: "auto-update-config-change",
policyFn: () => {
- if (!Services.policies.isAllowed("app-auto-updates-off")) {
- // We aren't allowed to turn off auto-update - it is forced on.
- return true;
- }
- if (!Services.policies.isAllowed("app-auto-updates-on")) {
- // We aren't allowed to turn on auto-update - it is forced off.
- return false;
- }
return null;
},
},
diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm
index 36d2220064cd..e2ccb5cc1d14 100644
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -23,6 +23,7 @@ const { AppConstants } = ChromeUtils.import(
const MOZ_COMPATIBILITY_NIGHTLY = ![
"aurora",
+ "alpha",
"beta",
"release",
"esr",
@@ -37,6 +38,7 @@ const PREF_EM_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault";
const PREF_EM_STRICT_COMPATIBILITY = "extensions.strictCompatibility";
const PREF_EM_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity";
const PREF_SYS_ADDON_UPDATE_ENABLED = "extensions.systemAddon.update.enabled";
+const PREF_EM_LAST_TORBROWSER_VERSION = "extensions.lastTorBrowserVersion";
const PREF_MIN_WEBEXT_PLATFORM_VERSION =
"extensions.webExtensionsMinPlatformVersion";
@@ -689,6 +691,28 @@ var AddonManagerInternal = {
);
}
+ // To ensure that extension and plugin code gets a chance to run
+ // after each browser update, set appChanged = true when the
+ // Tor Browser version has changed even if the Mozilla app
+ // version has not changed.
+ let tbChanged = undefined;
+ try {
+ tbChanged = AppConstants.TOR_BROWSER_VERSION !=
+ Services.prefs.getCharPref(PREF_EM_LAST_TORBROWSER_VERSION);
+ }
+ catch (e) { }
+ if (tbChanged !== false) {
+ // Because PREF_EM_LAST_TORBROWSER_VERSION was not present in older
+ // versions of Tor Browser, an app change is indicated when tbChanged
+ // is undefined or true.
+ if (appChanged === false) {
+ appChanged = true;
+ }
+
+ Services.prefs.setCharPref(PREF_EM_LAST_TORBROWSER_VERSION,
+ AppConstants.TOR_BROWSER_VERSION);
+ }
+
if (!MOZ_COMPATIBILITY_NIGHTLY) {
PREF_EM_CHECK_COMPATIBILITY =
PREF_EM_CHECK_COMPATIBILITY_BASE +
diff --git a/toolkit/mozapps/extensions/test/browser/head.js b/toolkit/mozapps/extensions/test/browser/head.js
index 32ce769afbc9..740ae52877f4 100644
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -43,6 +43,7 @@ var PREF_CHECK_COMPATIBILITY;
var channel = Services.prefs.getCharPref("app.update.channel", "default");
if (
channel != "aurora" &&
+ channel != "alpha" &&
channel != "beta" &&
channel != "release" &&
channel != "esr"
diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
index 439ecec5bd1f..a716eba87e02 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -390,6 +390,7 @@ function isNightlyChannel() {
return (
channel != "aurora" &&
+ channel != "alpha" &&
channel != "beta" &&
channel != "release" &&
channel != "esr"
diff --git a/toolkit/mozapps/update/UpdateService.jsm b/toolkit/mozapps/update/UpdateService.jsm
index cd87b21b0ff9..8552240a1df6 100644
--- a/toolkit/mozapps/update/UpdateService.jsm
+++ b/toolkit/mozapps/update/UpdateService.jsm
@@ -43,11 +43,15 @@ XPCOMUtils.defineLazyModuleGetters(this, {
AddonManager: "resource://gre/modules/AddonManager.jsm",
AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm",
CertUtils: "resource://gre/modules/CertUtils.jsm",
+#ifdef XP_WIN
ctypes: "resource://gre/modules/ctypes.jsm",
+#endif
DeferredTask: "resource://gre/modules/DeferredTask.jsm",
setTimeout: "resource://gre/modules/Timer.jsm",
UpdateUtils: "resource://gre/modules/UpdateUtils.jsm",
+#if !defined(TOR_BROWSER_UPDATE)
WindowsRegistry: "resource://gre/modules/WindowsRegistry.jsm",
+#endif
});
if (AppConstants.ENABLE_WEBDRIVER) {
@@ -525,6 +529,7 @@ function testWriteAccess(updateTestFile, createDirectory) {
updateTestFile.remove(false);
}
+#ifdef XP_WIN
/**
* Windows only function that closes a Win32 handle.
*
@@ -617,6 +622,7 @@ function getPerInstallationMutexName(aGlobal = true) {
(aGlobal ? "Global\\" : "") + "MozillaUpdateMutex-" + hasher.finish(true)
);
}
+#endif
/**
* Whether or not the current instance has the update mutex. The update mutex
@@ -627,6 +633,7 @@ function getPerInstallationMutexName(aGlobal = true) {
* @return true if this instance holds the update mutex
*/
function hasUpdateMutex() {
+#ifdef XP_WIN
if (AppConstants.platform != "win") {
return true;
}
@@ -634,6 +641,9 @@ function hasUpdateMutex() {
gUpdateMutexHandle = createMutex(getPerInstallationMutexName(true), false);
}
return !!gUpdateMutexHandle;
+#else
+ return true;
+#endif
}
/**
@@ -664,6 +674,11 @@ function areDirectoryEntriesWriteable(aDir) {
* @return true if elevation is required, false otherwise
*/
function getElevationRequired() {
+#if defined(TOR_BROWSER_UPDATE)
+ // To avoid potential security holes associated with running the updater
+ // process with elevated privileges, Tor Browser does not support elevation.
+ return false;
+#else
if (AppConstants.platform != "macosx") {
return false;
}
@@ -698,6 +713,7 @@ function getElevationRequired() {
"not required"
);
return false;
+#endif
}
/**
@@ -747,6 +763,7 @@ function getCanApplyUpdates() {
return false;
}
+#if !defined(TOR_BROWSER_UPDATE)
if (AppConstants.platform == "macosx") {
LOG(
"getCanApplyUpdates - bypass the write since elevation can be used " +
@@ -762,6 +779,7 @@ function getCanApplyUpdates() {
);
return true;
}
+#endif
try {
if (AppConstants.platform == "win") {
@@ -1587,6 +1605,9 @@ function handleUpdateFailure(update, errorCode) {
cancelations++;
Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS, cancelations);
if (AppConstants.platform == "macosx") {
+#if defined(TOR_BROWSER_UPDATE)
+ cleanupActiveUpdate();
+#else
let osxCancelations = Services.prefs.getIntPref(
PREF_APP_UPDATE_CANCELATIONS_OSX,
0
@@ -1610,6 +1631,7 @@ function handleUpdateFailure(update, errorCode) {
(update.state = STATE_PENDING_ELEVATE)
);
}
+#endif
update.statusText = gUpdateBundle.GetStringFromName("elevationFailure");
} else {
writeStatusFile(getReadyUpdateDir(), (update.state = STATE_PENDING));
@@ -2198,7 +2220,26 @@ function Update(update) {
this._patches.push(patch);
}
- if (!this._patches.length && !update.hasAttribute("unsupported")) {
+ if (update.hasAttribute("unsupported")) {
+ this.unsupported = ("true" == update.getAttribute("unsupported"));
+ } else if (update.hasAttribute("minSupportedOSVersion")) {
+ let minOSVersion = update.getAttribute("minSupportedOSVersion");
+ try {
+ let osVersion = Services.sysinfo.getProperty("version");
+ this.unsupported = (Services.vc.compare(osVersion, minOSVersion) < 0);
+ } catch (e) {}
+ }
+ if (!this.unsupported && update.hasAttribute("minSupportedInstructionSet")) {
+ let minInstructionSet = update.getAttribute("minSupportedInstructionSet");
+ if (['MMX', 'SSE', 'SSE2', 'SSE3',
+ 'SSE4A', 'SSE4_1', 'SSE4_2'].indexOf(minInstructionSet) >= 0) {
+ try {
+ this.unsupported = !Services.sysinfo.getProperty("has" + minInstructionSet);
+ } catch (e) {}
+ }
+ }
+
+ if (!this._patches.length && !this.unsupported) {
throw Components.Exception("", Cr.NS_ERROR_ILLEGAL_VALUE);
}
@@ -2236,9 +2277,7 @@ function Update(update) {
if (!isNaN(attr.value)) {
this.promptWaitTime = parseInt(attr.value);
}
- } else if (attr.name == "unsupported") {
- this.unsupported = attr.value == "true";
- } else {
+ } else if (attr.name != "unsupported") {
switch (attr.name) {
case "appVersion":
case "buildID":
@@ -2263,7 +2302,11 @@ function Update(update) {
}
if (!this.previousAppVersion) {
+#ifdef TOR_BROWSER_UPDATE
+ this.previousAppVersion = AppConstants.TOR_BROWSER_VERSION;
+#else
this.previousAppVersion = Services.appinfo.version;
+#endif
}
if (!this.elevationFailure) {
@@ -2651,6 +2694,7 @@ UpdateService.prototype = {
Services.obs.removeObserver(this, topic);
Services.prefs.removeObserver(PREF_APP_UPDATE_LOG, this);
+#ifdef XP_WIN
if (AppConstants.platform == "win" && gUpdateMutexHandle) {
// If we hold the update mutex, let it go!
// The OS would clean this up sometime after shutdown,
@@ -2658,6 +2702,7 @@ UpdateService.prototype = {
closeHandle(gUpdateMutexHandle);
gUpdateMutexHandle = null;
}
+#endif
if (this._retryTimer) {
this._retryTimer.cancel();
}
@@ -2688,6 +2733,7 @@ UpdateService.prototype = {
}
break;
case "test-close-handle-update-mutex":
+#ifdef XP_WIN
if (Cu.isInAutomation) {
if (AppConstants.platform == "win" && gUpdateMutexHandle) {
LOG("UpdateService:observe - closing mutex handle for testing");
@@ -2695,6 +2741,7 @@ UpdateService.prototype = {
gUpdateMutexHandle = null;
}
}
+#endif
break;
}
},
@@ -2726,6 +2773,9 @@ UpdateService.prototype = {
return;
}
gUpdateFileWriteInfo = { phase: "startup", failure: false };
+#if defined(TOR_BROWSER_UPDATE) && !defined(XP_MACOSX)
+ this._removeOrphanedTorBrowserFiles();
+#endif
if (!this.canCheckForUpdates) {
LOG(
"UpdateService:_postUpdateProcessing - unable to check for " +
@@ -3037,6 +3087,42 @@ UpdateService.prototype = {
}
},
+#if defined(TOR_BROWSER_UPDATE) && !defined(XP_MACOSX)
+ /**
+ * When updating from an earlier version to Tor Browser 6.0 or later, old
+ * update info files are left behind on Linux and Windows. Remove them.
+ */
+ _removeOrphanedTorBrowserFiles: function AUS__removeOrphanedTorBrowserFiles() {
+ try {
+ let oldUpdateInfoDir = getAppBaseDir(); // aka the Browser directory.
+
+#ifdef XP_WIN
+ // On Windows, the updater files were stored under
+ // Browser/TorBrowser/Data/Browser/Caches/firefox/
+ oldUpdateInfoDir.appendRelativePath(
+ "TorBrowser\\Data\\Browser\\Caches\\firefox");
+#endif
+
+ // Remove the updates directory.
+ let updatesDir = oldUpdateInfoDir.clone();
+ updatesDir.append("updates");
+ if (updatesDir.exists() && updatesDir.isDirectory()) {
+ updatesDir.remove(true);
+ }
+
+ // Remove files: active-update.xml and updates.xml
+ let filesToRemove = [ "active-update.xml", "updates.xml" ];
+ filesToRemove.forEach(function(aFileName) {
+ let f = oldUpdateInfoDir.clone();
+ f.append(aFileName);
+ if (f.exists()) {
+ f.remove(false);
+ }
+ });
+ } catch (e) {}
+ },
+#endif
+
/**
* Register an observer when the network comes online, so we can short-circuit
* the app.update.interval when there isn't connectivity
@@ -3481,9 +3567,14 @@ UpdateService.prototype = {
updates.forEach(function(aUpdate) {
// Ignore updates for older versions of the application and updates for
// the same version of the application with the same build ID.
- if (
- vc.compare(aUpdate.appVersion, Services.appinfo.version) < 0 ||
- (vc.compare(aUpdate.appVersion, Services.appinfo.version) == 0 &&
+#ifdef TOR_BROWSER_UPDATE
+ let compatVersion = AppConstants.TOR_BROWSER_VERSION;
+#else
+ let compatVersion = Services.appinfo.version;
+#endif
+ let rc = vc.compare(aUpdate.appVersion, compatVersion);
+ if (rc < 0 ||
+ (rc == 0 &&
aUpdate.buildID == Services.appinfo.appBuildID)
) {
LOG(
@@ -3935,20 +4026,32 @@ UpdateService.prototype = {
// build ID. If we already have an update ready, we want to apply those
// same checks against the version of the ready update, so that we don't
// download an update that isn't newer than the one we already have.
+#ifdef TOR_BROWSER_UPDATE
+ let compatVersion = AppConstants.TOR_BROWSER_VERSION;
+#else
+ let compatVersion = Services.appinfo.version;
+#endif
if (
updateIsAtLeastAsOldAs(
update,
- Services.appinfo.version,
+ compatVersion,
Services.appinfo.appBuildID
)
) {
LOG(
"UpdateService:downloadUpdate - canceling download of update since " +
"it is for an earlier or same application version and build ID.\n" +
+#ifdef TOR_BROWSER_UPDATE
+ "current Tor Browser version: " +
+ compatVersion +
+ "\n" +
+ "update Tor Browser version : " +
+#else
"current application version: " +
- Services.appinfo.version +
+ compatVersion +
"\n" +
"update application version : " +
+#endif
update.appVersion +
"\n" +
"current build ID: " +
@@ -4628,6 +4731,7 @@ Checker.prototype = {
*/
_callback: null,
+#if !defined(TOR_BROWSER_UPDATE)
_getCanMigrate: function UC__getCanMigrate() {
if (AppConstants.platform != "win") {
return false;
@@ -4697,6 +4801,7 @@ Checker.prototype = {
LOG("Checker:_getCanMigrate - no registry entries for this installation");
return false;
},
+#endif // !defined(TOR_BROWSER_UPDATE)
/**
* The URL of the update service XML file to connect to that contains details
@@ -4725,9 +4830,11 @@ Checker.prototype = {
url += (url.includes("?") ? "&" : "?") + "force=1";
}
+#if !defined(TOR_BROWSER_UPDATE)
if (this._getCanMigrate()) {
url += (url.includes("?") ? "&" : "?") + "mig64=1";
}
+#endif
LOG("Checker:getUpdateURL - update URL: " + url);
return url;
diff --git a/toolkit/mozapps/update/UpdateServiceStub.jsm b/toolkit/mozapps/update/UpdateServiceStub.jsm
index 45b9177a06cb..ab4bbfc0884c 100644
--- a/toolkit/mozapps/update/UpdateServiceStub.jsm
+++ b/toolkit/mozapps/update/UpdateServiceStub.jsm
@@ -84,8 +84,12 @@ function UpdateServiceStub() {
// contains the status file's path
// We may need to migrate update data
+ // In Tor Browser we skip this because we do not use an update agent and we
+ // do not want to store any data outside of the browser installation directory.
+ // For more info, see https://bugzilla.mozilla.org/show_bug.cgi?id=1458314
if (
AppConstants.platform == "win" &&
+ !AppConstants.TOR_BROWSER_UPDATE &&
!Services.prefs.getBoolPref(prefUpdateDirMigrated, false)
) {
migrateUpdateDirectory();
diff --git a/toolkit/mozapps/update/common/updatehelper.cpp b/toolkit/mozapps/update/common/updatehelper.cpp
index b094d9eb75e9..c825d3c1ea8e 100644
--- a/toolkit/mozapps/update/common/updatehelper.cpp
+++ b/toolkit/mozapps/update/common/updatehelper.cpp
@@ -66,6 +66,13 @@ BOOL PathGetSiblingFilePath(LPWSTR destinationBuffer, LPCWSTR siblingFilePath,
* @return TRUE if successful
*/
BOOL GetSecureOutputDirectoryPath(LPWSTR outBuf) {
+#ifdef TOR_BROWSER_UPDATE
+ // This function is used to support the maintenance service and elevated
+ // updates and is therefore not called by Tor Browser's updater. We stub
+ // it out to avoid any chance that the Tor Browser updater will create
+ // files under C:\Program Files (x86)\ or a similar location.
+ return FALSE;
+#else
PWSTR progFilesX86;
if (FAILED(SHGetKnownFolderPath(FOLDERID_ProgramFilesX86, KF_FLAG_CREATE,
nullptr, &progFilesX86))) {
@@ -99,6 +106,7 @@ BOOL GetSecureOutputDirectoryPath(LPWSTR outBuf) {
}
return TRUE;
+#endif
}
/**
diff --git a/toolkit/mozapps/update/moz.build b/toolkit/mozapps/update/moz.build
index 0ed2f39f66a0..47af63a104b3 100644
--- a/toolkit/mozapps/update/moz.build
+++ b/toolkit/mozapps/update/moz.build
@@ -22,7 +22,6 @@ EXTRA_COMPONENTS += [
EXTRA_JS_MODULES += [
"UpdateListener.jsm",
- "UpdateService.jsm",
"UpdateServiceStub.jsm",
"UpdateTelemetry.jsm",
]
@@ -44,6 +43,10 @@ if (
"BackgroundTask_backgroundupdate.jsm",
]
+EXTRA_PP_JS_MODULES += [
+ "UpdateService.jsm",
+]
+
XPCOM_MANIFESTS += [
"components.conf",
]
diff --git a/toolkit/mozapps/update/updater/launchchild_osx.mm b/toolkit/mozapps/update/updater/launchchild_osx.mm
index 3074c0da065b..a48318ece4c3 100644
--- a/toolkit/mozapps/update/updater/launchchild_osx.mm
+++ b/toolkit/mozapps/update/updater/launchchild_osx.mm
@@ -372,6 +372,7 @@ bool ObtainUpdaterArguments(int* argc, char*** argv) {
@end
+#ifndef TOR_BROWSER_UPDATE
bool ServeElevatedUpdate(int argc, const char** argv) {
MacAutoreleasePool pool;
@@ -387,6 +388,7 @@ bool ServeElevatedUpdate(int argc, const char** argv) {
[updater release];
return didSucceed;
}
+#endif
bool IsOwnedByGroupAdmin(const char* aAppBundle) {
MacAutoreleasePool pool;
diff --git a/toolkit/mozapps/update/updater/moz.build b/toolkit/mozapps/update/updater/moz.build
index 40d7a77a6b62..ac7f82a4f9ad 100644
--- a/toolkit/mozapps/update/updater/moz.build
+++ b/toolkit/mozapps/update/updater/moz.build
@@ -51,7 +51,7 @@ xpcshell_cert.script = "gen_cert_header.py:create_header"
dep1_cert.script = "gen_cert_header.py:create_header"
dep2_cert.script = "gen_cert_header.py:create_header"
-if CONFIG["MOZ_UPDATE_CHANNEL"] in ("beta", "release", "esr"):
+if CONFIG["MOZ_UPDATE_CHANNEL"] in ("alpha", "beta", "release", "esr"):
primary_cert.inputs += ["release_primary.der"]
secondary_cert.inputs += ["release_secondary.der"]
elif CONFIG["MOZ_UPDATE_CHANNEL"] in (
diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp
index ec2b4bcd60a1..646261c70967 100644
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -16,7 +16,7 @@
* updatev3.manifest
* -----------------
* method = "add" | "add-if" | "add-if-not" | "patch" | "patch-if" |
- * "remove" | "rmdir" | "rmrfdir" | type
+ * "remove" | "rmdir" | "rmrfdir" | "addsymlink" | type
*
* 'add-if-not' adds a file if it doesn't exist.
*
@@ -78,7 +78,9 @@ bool IsRecursivelyWritable(const char* aPath);
void LaunchChild(int argc, const char** argv);
void LaunchMacPostProcess(const char* aAppBundle);
bool ObtainUpdaterArguments(int* argc, char*** argv);
+# ifndef TOR_BROWSER_UPDATE
bool ServeElevatedUpdate(int argc, const char** argv);
+# endif
void SetGroupOwnershipAndPermissions(const char* aAppBundle);
struct UpdateServerThreadArgs {
int argc;
@@ -483,9 +485,12 @@ static const NS_tchar* get_relative_path(const NS_tchar* fullpath) {
* The line from the manifest that contains the path.
* @param isdir
* Whether the path is a directory path. Defaults to false.
+ * @param islinktarget
+ * Whether the path is a symbolic link target. Defaults to false.
* @return valid filesystem path or nullptr if the path checks fail.
*/
-static NS_tchar* get_valid_path(NS_tchar** line, bool isdir = false) {
+static NS_tchar* get_valid_path(NS_tchar** line, bool isdir = false,
+ bool islinktarget = false) {
NS_tchar* path = mstrtok(kQuote, line);
if (!path) {
LOG(("get_valid_path: unable to determine path: " LOG_S, *line));
@@ -521,10 +526,12 @@ static NS_tchar* get_valid_path(NS_tchar** line, bool isdir = false) {
path[NS_tstrlen(path) - 1] = NS_T('\0');
}
- // Don't allow relative paths that resolve to a parent directory.
- if (NS_tstrstr(path, NS_T("..")) != nullptr) {
- LOG(("get_valid_path: paths must not contain '..': " LOG_S, path));
- return nullptr;
+ if (!islinktarget) {
+ // Don't allow relative paths that resolve to a parent directory.
+ if (NS_tstrstr(path, NS_T("..")) != nullptr) {
+ LOG(("get_valid_path: paths must not contain '..': " LOG_S, path));
+ return nullptr;
+ }
}
return path;
@@ -564,7 +571,7 @@ static void ensure_write_permissions(const NS_tchar* path) {
(void)_wchmod(path, _S_IREAD | _S_IWRITE);
#else
struct stat fs;
- if (!stat(path, &fs) && !(fs.st_mode & S_IWUSR)) {
+ if (!lstat(path, &fs) && !S_ISLNK(fs.st_mode) && !(fs.st_mode & S_IWUSR)) {
(void)chmod(path, fs.st_mode | S_IWUSR);
}
#endif
@@ -751,11 +758,9 @@ static int ensure_copy(const NS_tchar* path, const NS_tchar* dest) {
return READ_ERROR;
}
-# ifdef XP_UNIX
if (S_ISLNK(ss.st_mode)) {
return ensure_copy_symlink(path, dest);
}
-# endif
AutoFile infile(ensure_open(path, NS_T("rb"), ss.st_mode));
if (!infile) {
@@ -842,12 +847,19 @@ static int ensure_copy_recursive(const NS_tchar* path, const NS_tchar* dest,
return READ_ERROR;
}
-#ifdef XP_UNIX
+#ifndef XP_WIN
if (S_ISLNK(sInfo.st_mode)) {
return ensure_copy_symlink(path, dest);
}
#endif
+#ifdef XP_UNIX
+ // Ignore Unix domain sockets. See #20691.
+ if (S_ISSOCK(sInfo.st_mode)) {
+ return 0;
+ }
+#endif
+
if (!S_ISDIR(sInfo.st_mode)) {
return ensure_copy(path, dest);
}
@@ -904,7 +916,7 @@ static int rename_file(const NS_tchar* spath, const NS_tchar* dpath,
}
struct NS_tstat_t spathInfo;
- rv = NS_tstat(spath, &spathInfo);
+ rv = NS_tlstat(spath, &spathInfo); // Get info about file or symlink.
if (rv) {
LOG(("rename_file: failed to read file status info: " LOG_S ", "
"err: %d",
@@ -912,7 +924,12 @@ static int rename_file(const NS_tchar* spath, const NS_tchar* dpath,
return READ_ERROR;
}
- if (!S_ISREG(spathInfo.st_mode)) {
+#ifdef XP_WIN
+ if (!S_ISREG(spathInfo.st_mode))
+#else
+ if (!S_ISREG(spathInfo.st_mode) && !S_ISLNK(spathInfo.st_mode))
+#endif
+ {
if (allowDirs && !S_ISDIR(spathInfo.st_mode)) {
LOG(("rename_file: path present, but not a file: " LOG_S ", err: %d",
spath, errno));
@@ -921,7 +938,12 @@ static int rename_file(const NS_tchar* spath, const NS_tchar* dpath,
LOG(("rename_file: proceeding to rename the directory"));
}
- if (!NS_taccess(dpath, F_OK)) {
+#ifdef XP_WIN
+ if (!NS_taccess(dpath, F_OK))
+#else
+ if (!S_ISLNK(spathInfo.st_mode) && !NS_taccess(dpath, F_OK))
+#endif
+ {
if (ensure_remove(dpath)) {
LOG(
("rename_file: destination file exists and could not be "
@@ -941,7 +963,7 @@ static int rename_file(const NS_tchar* spath, const NS_tchar* dpath,
return OK;
}
-#ifdef XP_WIN
+#if defined(XP_WIN) && !defined(TOR_BROWSER_UPDATE)
// Remove the directory pointed to by path and all of its files and
// sub-directories. If a file is in use move it to the tobedeleted directory
// and attempt to schedule removal of the file on reboot
@@ -1040,7 +1062,19 @@ static int backup_restore(const NS_tchar* path, const NS_tchar* relPath) {
NS_tsnprintf(relBackup, sizeof(relBackup) / sizeof(relBackup[0]),
NS_T("%s") BACKUP_EXT, relPath);
- if (NS_taccess(backup, F_OK)) {
+ bool isLink = false;
+#ifndef XP_WIN
+ struct stat linkInfo;
+ int rv = lstat(backup, &linkInfo);
+ if (rv) {
+ LOG(("backup_restore: cannot get info for backup file: " LOG_S ", err: %d",
+ relBackup, errno));
+ return OK;
+ }
+ isLink = S_ISLNK(linkInfo.st_mode);
+#endif
+
+ if (!isLink && NS_taccess(backup, F_OK)) {
LOG(("backup_restore: backup file doesn't exist: " LOG_S, relBackup));
return OK;
}
@@ -1058,8 +1092,18 @@ static int backup_discard(const NS_tchar* path, const NS_tchar* relPath) {
NS_tsnprintf(relBackup, sizeof(relBackup) / sizeof(relBackup[0]),
NS_T("%s") BACKUP_EXT, relPath);
+ bool isLink = false;
+#ifndef XP_WIN
+ struct stat linkInfo;
+ int rv2 = lstat(backup, &linkInfo);
+ if (rv2) {
+ return OK; // File does not exist; nothing to do.
+ }
+ isLink = S_ISLNK(linkInfo.st_mode);
+#endif
+
// Nothing to discard
- if (NS_taccess(backup, F_OK)) {
+ if (!isLink && NS_taccess(backup, F_OK)) {
return OK;
}
@@ -1074,6 +1118,8 @@ static int backup_discard(const NS_tchar* path, const NS_tchar* relPath) {
relBackup, relPath));
return WRITE_ERROR_DELETE_BACKUP;
}
+
+# if !defined(TOR_BROWSER_UPDATE)
// The MoveFileEx call to remove the file on OS reboot will fail if the
// process doesn't have write access to the HKEY_LOCAL_MACHINE registry key
// but this is ok since the installer / uninstaller will delete the
@@ -1090,6 +1136,7 @@ static int backup_discard(const NS_tchar* path, const NS_tchar* relPath) {
"file: " LOG_S,
relPath));
}
+# endif
}
#else
if (rv) {
@@ -1144,7 +1191,7 @@ class Action {
class RemoveFile : public Action {
public:
- RemoveFile() : mSkip(0) {}
+ RemoveFile() : mSkip(0), mIsLink(0) {}
int Parse(NS_tchar* line) override;
int Prepare() override;
@@ -1155,6 +1202,7 @@ class RemoveFile : public Action {
mozilla::UniquePtr<NS_tchar[]> mFile;
mozilla::UniquePtr<NS_tchar[]> mRelPath;
int mSkip;
+ int mIsLink;
};
int RemoveFile::Parse(NS_tchar* line) {
@@ -1177,28 +1225,39 @@ int RemoveFile::Parse(NS_tchar* line) {
}
int RemoveFile::Prepare() {
- // Skip the file if it already doesn't exist.
- int rv = NS_taccess(mFile.get(), F_OK);
- if (rv) {
- mSkip = 1;
- mProgressCost = 0;
- return OK;
+ int rv;
+#ifndef XP_WIN
+ struct stat linkInfo;
+ rv = lstat(mFile.get(), &linkInfo);
+ mIsLink = ((0 == rv) && S_ISLNK(linkInfo.st_mode));
+#endif
+
+ if (!mIsLink) {
+ // Skip the file if it already doesn't exist.
+ rv = NS_taccess(mFile.get(), F_OK);
+ if (rv) {
+ mSkip = 1;
+ mProgressCost = 0;
+ return OK;
+ }
}
LOG(("PREPARE REMOVEFILE " LOG_S, mRelPath.get()));
- // Make sure that we're actually a file...
- struct NS_tstat_t fileInfo;
- rv = NS_tstat(mFile.get(), &fileInfo);
- if (rv) {
- LOG(("failed to read file status info: " LOG_S ", err: %d", mFile.get(),
- errno));
- return READ_ERROR;
- }
+ if (!mIsLink) {
+ // Make sure that we're actually a file...
+ struct NS_tstat_t fileInfo;
+ rv = NS_tstat(mFile.get(), &fileInfo);
+ if (rv) {
+ LOG(("failed to read file status info: " LOG_S ", err: %d", mFile.get(),
+ errno));
+ return READ_ERROR;
+ }
- if (!S_ISREG(fileInfo.st_mode)) {
- LOG(("path present, but not a file: " LOG_S, mFile.get()));
- return DELETE_ERROR_EXPECTED_FILE;
+ if (!S_ISREG(fileInfo.st_mode)) {
+ LOG(("path present, but not a file: " LOG_S, mFile.get()));
+ return DELETE_ERROR_EXPECTED_FILE;
+ }
}
NS_tchar* slash = (NS_tchar*)NS_tstrrchr(mFile.get(), NS_T('/'));
@@ -1227,7 +1286,13 @@ int RemoveFile::Execute() {
// The file is checked for existence here and in Prepare since it might have
// been removed by a separate instruction: bug 311099.
- int rv = NS_taccess(mFile.get(), F_OK);
+ int rv = 0;
+ if (mIsLink) {
+ struct NS_tstat_t linkInfo;
+ rv = NS_tlstat(mFile.get(), &linkInfo);
+ } else {
+ rv = NS_taccess(mFile.get(), F_OK);
+ }
if (rv) {
LOG(("file cannot be removed because it does not exist; skipping"));
mSkip = 1;
@@ -1950,6 +2015,92 @@ void PatchIfFile::Finish(int status) {
PatchFile::Finish(status);
}
+#ifndef XP_WIN
+class AddSymlink : public Action {
+ public:
+ AddSymlink() : mAdded(false) {}
+
+ virtual int Parse(NS_tchar* line);
+ virtual int Prepare();
+ virtual int Execute();
+ virtual void Finish(int status);
+
+ private:
+ mozilla::UniquePtr<NS_tchar[]> mLinkPath;
+ mozilla::UniquePtr<NS_tchar[]> mRelPath;
+ mozilla::UniquePtr<NS_tchar[]> mTarget;
+ bool mAdded;
+};
+
+int AddSymlink::Parse(NS_tchar* line) {
+ // format "<linkname>" "target"
+
+ NS_tchar* validPath = get_valid_path(&line);
+ if (!validPath) return PARSE_ERROR;
+
+ mRelPath = mozilla::MakeUnique<NS_tchar[]>(MAXPATHLEN);
+ NS_tstrcpy(mRelPath.get(), validPath);
+ mLinkPath.reset(get_full_path(validPath));
+ if (!mLinkPath) {
+ return PARSE_ERROR;
+ }
+
+ // consume whitespace between args
+ NS_tchar* q = mstrtok(kQuote, &line);
+ if (!q) return PARSE_ERROR;
+
+ validPath = get_valid_path(&line, false, true);
+ if (!validPath) return PARSE_ERROR;
+
+ mTarget = mozilla::MakeUnique<NS_tchar[]>(MAXPATHLEN);
+ NS_tstrcpy(mTarget.get(), validPath);
+
+ return OK;
+}
+
+int AddSymlink::Prepare() {
+ LOG(("PREPARE ADDSYMLINK " LOG_S " -> " LOG_S, mRelPath.get(),
+ mTarget.get()));
+
+ return OK;
+}
+
+int AddSymlink::Execute() {
+ LOG(("EXECUTE ADDSYMLINK " LOG_S " -> " LOG_S, mRelPath.get(),
+ mTarget.get()));
+
+ // First make sure that we can actually get rid of any existing file or link.
+ struct stat linkInfo;
+ int rv = lstat(mLinkPath.get(), &linkInfo);
+ if ((0 == rv) && !S_ISLNK(linkInfo.st_mode)) {
+ rv = NS_taccess(mLinkPath.get(), F_OK);
+ }
+ if (rv == 0) {
+ rv = backup_create(mLinkPath.get());
+ if (rv) return rv;
+ } else {
+ rv = ensure_parent_dir(mLinkPath.get());
+ if (rv) return rv;
+ }
+
+ // Create the link.
+ rv = symlink(mTarget.get(), mLinkPath.get());
+ if (!rv) {
+ mAdded = true;
+ }
+
+ return rv;
+}
+
+void AddSymlink::Finish(int status) {
+ LOG(("FINISH ADDSYMLINK " LOG_S " -> " LOG_S, mRelPath.get(), mTarget.get()));
+ // When there is an update failure and a link has been added it is removed
+ // here since there might not be a backup to replace it.
+ if (status && mAdded) NS_tremove(mLinkPath.get());
+ backup_finish(mLinkPath.get(), mRelPath.get(), status);
+}
+#endif
+
//-----------------------------------------------------------------------------
#ifdef XP_WIN
@@ -2272,14 +2423,29 @@ static bool IsSecureUpdateStatusSucceeded(bool& isSucceeded) {
*/
static int CopyInstallDirToDestDir() {
// These files should not be copied over to the updated app
-#ifdef XP_WIN
-# define SKIPLIST_COUNT 3
-#elif XP_MACOSX
-# define SKIPLIST_COUNT 0
+#if defined(TOR_BROWSER_UPDATE) && !defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
+# ifdef XP_WIN
+# define SKIPLIST_COUNT 6
+# else
+# define SKIPLIST_COUNT 5
+# endif
#else
-# define SKIPLIST_COUNT 2
+# ifdef XP_WIN
+# define SKIPLIST_COUNT 3
+# elif XP_MACOSX
+# define SKIPLIST_COUNT 0
+# else
+# define SKIPLIST_COUNT 2
+# endif
#endif
copy_recursive_skiplist<SKIPLIST_COUNT> skiplist;
+#if defined(TOR_BROWSER_UPDATE) && !defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
+# ifdef XP_MACOSX
+ skiplist.append(0, gInstallDirPath, NS_T("Updated.app"));
+ skiplist.append(1, gInstallDirPath, NS_T("TorBrowser/UpdateInfo/updates/0"));
+# endif
+#endif
+
#ifndef XP_MACOSX
skiplist.append(0, gInstallDirPath, NS_T("updated"));
skiplist.append(1, gInstallDirPath, NS_T("updates/0"));
@@ -2288,6 +2454,19 @@ static int CopyInstallDirToDestDir() {
# endif
#endif
+#if defined(TOR_BROWSER_UPDATE) && !defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
+# ifdef XP_WIN
+ skiplist.append(SKIPLIST_COUNT - 3, gInstallDirPath,
+ NS_T("TorBrowser/Data/Browser/profile.default/parent.lock"));
+# else
+ skiplist.append(SKIPLIST_COUNT - 3, gInstallDirPath,
+ NS_T("TorBrowser/Data/Browser/profile.default/.parentlock"));
+# endif
+
+ skiplist.append(SKIPLIST_COUNT - 1, gInstallDirPath,
+ NS_T("TorBrowser/Data/Tor/lock"));
+#endif
+
return ensure_copy_recursive(gInstallDirPath, gWorkingDirPath, skiplist);
}
@@ -2425,7 +2604,9 @@ static int ProcessReplaceRequest() {
if (NS_taccess(deleteDir, F_OK)) {
NS_tmkdir(deleteDir, 0755);
}
+# if !defined(TOR_BROWSER_UPDATE)
remove_recursive_on_reboot(tmpDir, deleteDir);
+# endif
#endif
}
@@ -2433,8 +2614,45 @@ static int ProcessReplaceRequest() {
// On OS X, we we need to remove the staging directory after its Contents
// directory has been moved.
NS_tchar updatedAppDir[MAXPATHLEN];
+# if defined(TOR_BROWSER_UPDATE) && !defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
+ NS_tsnprintf(updatedAppDir, sizeof(updatedAppDir) / sizeof(updatedAppDir[0]),
+ NS_T("%s/Updated.app"), gInstallDirPath);
+ // For Tor Browser on OS X, we also need to copy everything else that is
+ // inside Updated.app.
+ NS_tDIR* dir = NS_topendir(updatedAppDir);
+ if (dir) {
+ NS_tdirent* entry;
+ while ((entry = NS_treaddir(dir)) != 0) {
+ if (NS_tstrcmp(entry->d_name, NS_T(".")) &&
+ NS_tstrcmp(entry->d_name, NS_T(".."))) {
+ NS_tchar childSrcPath[MAXPATHLEN];
+ NS_tsnprintf(childSrcPath,
+ sizeof(childSrcPath) / sizeof(childSrcPath[0]),
+ NS_T("%s/%s"), updatedAppDir, entry->d_name);
+ NS_tchar childDstPath[MAXPATHLEN];
+ NS_tsnprintf(childDstPath,
+ sizeof(childDstPath) / sizeof(childDstPath[0]),
+ NS_T("%s/%s"), gInstallDirPath, entry->d_name);
+ ensure_remove_recursive(childDstPath);
+ rv = rename_file(childSrcPath, childDstPath, true);
+ if (rv) {
+ LOG(("Moving " LOG_S " to " LOG_S " failed, err: %d", childSrcPath,
+ childDstPath, errno));
+ }
+ }
+ }
+
+ NS_tclosedir(dir);
+ } else {
+ LOG(("Updated.app dir can't be found: " LOG_S ", err: %d", updatedAppDir,
+ errno));
+ }
+# else
NS_tsnprintf(updatedAppDir, sizeof(updatedAppDir) / sizeof(updatedAppDir[0]),
NS_T("%s/Updated.app"), gPatchDirPath);
+# endif
+
+ // Remove the Updated.app directory.
ensure_remove_recursive(updatedAppDir);
#endif
@@ -2608,11 +2826,15 @@ static void UpdateThreadFunc(void* param) {
#ifdef XP_MACOSX
static void ServeElevatedUpdateThreadFunc(void* param) {
+# ifdef TOR_BROWSER_UPDATE
+ WriteStatusFile(ELEVATION_CANCELED);
+# else
UpdateServerThreadArgs* threadArgs = (UpdateServerThreadArgs*)param;
gSucceeded = ServeElevatedUpdate(threadArgs->argc, threadArgs->argv);
if (!gSucceeded) {
WriteStatusFile(ELEVATION_CANCELED);
}
+# endif
QuitProgressUI();
}
@@ -2636,7 +2858,7 @@ int LaunchCallbackAndPostProcessApps(int argc, NS_tchar** argv,
#endif
) {
if (argc > callbackIndex) {
-#if defined(XP_WIN)
+#if defined(XP_WIN) && !defined(TOR_BROWSER_UPDATE)
if (gSucceeded) {
if (!LaunchWinPostProcess(gInstallDirPath, gPatchDirPath)) {
fprintf(stderr, "The post update process was not launched");
@@ -2720,8 +2942,12 @@ int NS_main(int argc, NS_tchar** argv) {
UmaskContext umaskContext(0);
bool isElevated =
+# ifdef TOR_BROWSER_UPDATE
+ false;
+# else
strstr(argv[0], "/Library/PrivilegedHelperTools/org.mozilla.updater") !=
0;
+# endif
if (isElevated) {
if (!ObtainUpdaterArguments(&argc, &argv)) {
// Won't actually get here because ObtainUpdaterArguments will terminate
@@ -3372,6 +3598,26 @@ int NS_main(int argc, NS_tchar** argv) {
// using the service is because we are testing.
if (!useService && !noServiceFallback &&
updateLockFileHandle == INVALID_HANDLE_VALUE) {
+# ifdef TOR_BROWSER_UPDATE
+# ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
+ // Because the TorBrowser-Data directory that contains the user's
+ // profile is a sibling of the Tor Browser installation directory,
+ // the user probably has permission to apply updates. Therefore, to
+ // avoid potential security issues such as CVE-2015-0833, do not
+ // attempt to elevate privileges. Instead, write a "failed" message
+ // to the update status file (this function will return immediately
+ // after the CloseHandle(elevatedFileHandle) call below).
+# else
+ // Because the user profile is contained within the Tor Browser
+ // installation directory, the user almost certainly has permission to
+ // apply updates. Therefore, to avoid potential security issues such
+ // as CVE-2015-0833, do not attempt to elevate privileges. Instead,
+ // write a "failed" message to the update status file (this function
+ // will return immediately after the CloseHandle(elevatedFileHandle)
+ // call below).
+# endif
+ WriteStatusFile(WRITE_ERROR_ACCESS_DENIED);
+# else
// Get the secure ID before trying to update so it is possible to
// determine if the updater has created a new one.
char uuidStringBefore[UUID_LEN] = {'\0'};
@@ -3417,6 +3663,7 @@ int NS_main(int argc, NS_tchar** argv) {
gCopyOutputFiles = false;
WriteStatusFile(ELEVATION_CANCELED);
}
+# endif
}
// If we started the elevated updater, and it finished, check the secure
@@ -3786,6 +4033,7 @@ int NS_main(int argc, NS_tchar** argv) {
if (!sStagedUpdate && !sReplaceRequest && _wrmdir(gDeleteDirPath)) {
LOG(("NS_main: unable to remove directory: " LOG_S ", err: %d", DELETE_DIR,
errno));
+# if !defined(TOR_BROWSER_UPDATE)
// The directory probably couldn't be removed due to it containing files
// that are in use and will be removed on OS reboot. The call to remove the
// directory on OS reboot is done after the calls to remove the files so the
@@ -3804,6 +4052,7 @@ int NS_main(int argc, NS_tchar** argv) {
"directory: " LOG_S,
DELETE_DIR));
}
+# endif
}
#endif /* XP_WIN */
@@ -4445,7 +4694,13 @@ int DoUpdate() {
action = new AddIfNotFile();
} else if (NS_tstrcmp(token, NS_T("patch-if")) == 0) { // Patch if exists
action = new PatchIfFile();
- } else {
+ }
+#ifndef XP_WIN
+ else if (NS_tstrcmp(token, NS_T("addsymlink")) == 0) {
+ action = new AddSymlink();
+ }
+#endif
+ else {
LOG(("DoUpdate: unknown token: " LOG_S, token));
free(buf);
return PARSE_ERROR;
diff --git a/toolkit/xre/MacLaunchHelper.h b/toolkit/xre/MacLaunchHelper.h
index f8dc75ee4d08..ce816acd83e2 100644
--- a/toolkit/xre/MacLaunchHelper.h
+++ b/toolkit/xre/MacLaunchHelper.h
@@ -17,7 +17,9 @@ extern "C" {
* pid of the terminated process to confirm that it executed successfully.
*/
void LaunchChildMac(int aArgc, char** aArgv, pid_t* aPid = 0);
+#ifndef TOR_BROWSER_UPDATE
bool LaunchElevatedUpdate(int aArgc, char** aArgv, pid_t* aPid = 0);
+#endif
}
#endif
diff --git a/toolkit/xre/MacLaunchHelper.mm b/toolkit/xre/MacLaunchHelper.mm
index ec570ffab124..da2917c2a99e 100644
--- a/toolkit/xre/MacLaunchHelper.mm
+++ b/toolkit/xre/MacLaunchHelper.mm
@@ -40,6 +40,7 @@ void LaunchChildMac(int aArgc, char** aArgv, pid_t* aPid) {
}
}
+#ifndef TOR_BROWSER_UPDATE
BOOL InstallPrivilegedHelper() {
AuthorizationRef authRef = NULL;
OSStatus status = AuthorizationCreate(
@@ -116,3 +117,4 @@ bool LaunchElevatedUpdate(int aArgc, char** aArgv, pid_t* aPid) {
}
return didSucceed;
}
+#endif
diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
index 6d6238feda46..676126f2e06f 100644
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -3252,6 +3252,11 @@ static bool CheckCompatibility(nsIFile* aProfileDir, const nsCString& aVersion,
gLastAppBuildID.Assign(gAppData->buildID);
nsAutoCString buf;
+
+ nsAutoCString tbVersion(TOR_BROWSER_VERSION_QUOTED);
+ rv = parser.GetString("Compatibility", "LastTorBrowserVersion", buf);
+ if (NS_FAILED(rv) || !tbVersion.Equals(buf)) return false;
+
rv = parser.GetString("Compatibility", "LastOSABI", buf);
if (NS_FAILED(rv) || !aOSABI.Equals(buf)) return false;
@@ -3337,6 +3342,12 @@ static void WriteVersion(nsIFile* aProfileDir, const nsCString& aVersion,
PR_Write(fd, kHeader, sizeof(kHeader) - 1);
PR_Write(fd, aVersion.get(), aVersion.Length());
+ nsAutoCString tbVersion(TOR_BROWSER_VERSION_QUOTED);
+ static const char kTorBrowserVersionHeader[] =
+ NS_LINEBREAK "LastTorBrowserVersion=";
+ PR_Write(fd, kTorBrowserVersionHeader, sizeof(kTorBrowserVersionHeader) - 1);
+ PR_Write(fd, tbVersion.get(), tbVersion.Length());
+
static const char kOSABIHeader[] = NS_LINEBREAK "LastOSABI=";
PR_Write(fd, kOSABIHeader, sizeof(kOSABIHeader) - 1);
PR_Write(fd, aOSABI.get(), aOSABI.Length());
@@ -4734,8 +4745,17 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
if (CheckArg("test-process-updates")) {
SaveToEnv("MOZ_TEST_PROCESS_UPDATES=1");
}
+# ifdef TOR_BROWSER_UPDATE
+ nsAutoCString compatVersion(TOR_BROWSER_VERSION_QUOTED);
+# endif
ProcessUpdates(mDirProvider.GetGREDir(), exeDir, updRoot, gRestartArgc,
- gRestartArgv, mAppData->version);
+ gRestartArgv,
+# ifdef TOR_BROWSER_UPDATE
+ compatVersion.get()
+# else
+ mAppData->version
+# endif
+ );
if (EnvHasValue("MOZ_TEST_PROCESS_UPDATES")) {
SaveToEnv("MOZ_TEST_PROCESS_UPDATES=");
*aExitFlag = true;
diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp
index c85e7b98eb3f..f83f28288786 100644
--- a/toolkit/xre/nsUpdateDriver.cpp
+++ b/toolkit/xre/nsUpdateDriver.cpp
@@ -165,6 +165,13 @@ static nsresult GetInstallDirPath(nsIFile* appDir, nsACString& installDirPath) {
return NS_OK;
}
+#ifdef DEBUG
+static void dump_argv(const char* aPrefix, char** argv, int argc) {
+ printf("%s - %d args\n", aPrefix, argc);
+ for (int i = 0; i < argc; ++i) printf(" %d: %s\n", i, argv[i]);
+}
+#endif
+
static bool GetFile(nsIFile* dir, const nsACString& name,
nsCOMPtr<nsIFile>& result) {
nsresult rv;
@@ -226,6 +233,34 @@ typedef enum {
eAppliedService,
} UpdateStatus;
+#ifdef DEBUG
+static const char* UpdateStatusToString(UpdateStatus aStatus) {
+ const char* rv = "unknown";
+ switch (aStatus) {
+ case eNoUpdateAction:
+ rv = "NoUpdateAction";
+ break;
+ case ePendingUpdate:
+ rv = "PendingUpdate";
+ break;
+ case ePendingService:
+ rv = "PendingService";
+ break;
+ case ePendingElevate:
+ rv = "PendingElevate";
+ break;
+ case eAppliedUpdate:
+ rv = "AppliedUpdate";
+ break;
+ case eAppliedService:
+ rv = "AppliedService";
+ break;
+ }
+
+ return rv;
+}
+#endif
+
/**
* Returns a value indicating what needs to be done in order to handle an
* update.
@@ -298,9 +333,39 @@ static bool IsOlderVersion(nsIFile* versionFile, const char* appVersion) {
return false;
}
+#ifdef DEBUG
+ printf("IsOlderVersion checking appVersion %s against updateVersion %s\n",
+ appVersion, buf);
+#endif
+
return mozilla::Version(appVersion) > buf;
}
+#ifndef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
+# if defined(TOR_BROWSER_UPDATE) && defined(XP_MACOSX)
+static nsresult GetUpdateDirFromAppDir(nsIFile* aAppDir, nsIFile** aResult) {
+ // On Mac OSX, we stage the update to an Updated.app directory that is
+ // directly below the main Tor Browser.app directory (two levels up from
+ // the appDir).
+ NS_ENSURE_ARG_POINTER(aAppDir);
+ NS_ENSURE_ARG_POINTER(aResult);
+ nsCOMPtr<nsIFile> parentDir1, parentDir2;
+ nsresult rv = aAppDir->GetParent(getter_AddRefs(parentDir1));
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = parentDir1->GetParent(getter_AddRefs(parentDir2));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsIFile> updatedDir;
+ if (!GetFile(parentDir2, "Updated.app"_ns, updatedDir)) {
+ return NS_ERROR_FAILURE;
+ }
+
+ updatedDir.forget(aResult);
+ return NS_OK;
+}
+# endif
+#endif
+
/**
* Applies, switches, or stages an update.
*
@@ -448,7 +513,12 @@ static void ApplyUpdate(nsIFile* greDir, nsIFile* updateDir, nsIFile* appDir,
} else {
// Get the directory where the update is staged or will be staged.
#if defined(XP_MACOSX)
+# if defined(TOR_BROWSER_UPDATE) && !defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
+ rv = GetUpdateDirFromAppDir(appDir, getter_AddRefs(updatedDir));
+ if (NS_FAILED(rv)) {
+# else
if (!GetFile(updateDir, "Updated.app"_ns, updatedDir)) {
+# endif
#else
if (!GetFile(appDir, "updated"_ns, updatedDir)) {
#endif
@@ -543,6 +613,9 @@ static void ApplyUpdate(nsIFile* greDir, nsIFile* updateDir, nsIFile* appDir,
}
LOG(("spawning updater process [%s]\n", updaterPath.get()));
+#ifdef DEBUG
+ dump_argv("ApplyUpdate updater", argv, argc);
+#endif
#if defined(XP_UNIX) && !defined(XP_MACOSX)
// We use execv to spawn the updater process on all UNIX systems except Mac
@@ -581,6 +654,10 @@ static void ApplyUpdate(nsIFile* greDir, nsIFile* updateDir, nsIFile* appDir,
}
#elif defined(XP_MACOSX)
UpdateDriverSetupMacCommandLine(argc, argv, restart);
+# ifdef DEBUG
+dump_argv("ApplyUpdate after SetupMacCommandLine", argv, argc);
+# endif
+# ifndef TOR_BROWSER_UPDATE
// We need to detect whether elevation is required for this update. This can
// occur when an admin user installs the application, but another admin
// user attempts to update (see bug 394984).
@@ -593,6 +670,7 @@ if (restart && !IsRecursivelyWritable(installDirPath.get())) {
}
exit(0);
}
+# endif
if (isStaged) {
// Launch the updater to replace the installation with the staged updated.
@@ -663,9 +741,27 @@ static bool ProcessHasTerminated(ProcessType pt) {
nsresult ProcessUpdates(nsIFile* greDir, nsIFile* appDir, nsIFile* updRootDir,
int argc, char** argv, const char* appVersion,
bool restart, ProcessType* pid) {
+#if defined(XP_WIN) && defined(TOR_BROWSER_UPDATE)
+ // Try to remove the "tobedeleted" directory which, if present, contains
+ // files that could not be removed during a previous update (e.g., DLLs
+ // that were in use and therefore locked by Windows).
+ nsCOMPtr<nsIFile> deleteDir;
+ nsresult winrv = appDir->Clone(getter_AddRefs(deleteDir));
+ if (NS_SUCCEEDED(winrv)) {
+ winrv = deleteDir->AppendNative("tobedeleted"_ns);
+ if (NS_SUCCEEDED(winrv)) {
+ winrv = deleteDir->Remove(true);
+ }
+ }
+#endif
+
nsresult rv;
nsCOMPtr<nsIFile> updatesDir;
+#ifdef DEBUG
+ printf("ProcessUpdates updateRootDir: %s appVersion: %s\n",
+ updRootDir->HumanReadablePath().get(), appVersion);
+#endif
rv = updRootDir->Clone(getter_AddRefs(updatesDir));
NS_ENSURE_SUCCESS(rv, rv);
rv = updatesDir->AppendNative("updates"_ns);
@@ -685,6 +781,12 @@ nsresult ProcessUpdates(nsIFile* greDir, nsIFile* appDir, nsIFile* updRootDir,
nsCOMPtr<nsIFile> statusFile;
UpdateStatus status = GetUpdateStatus(updatesDir, statusFile);
+#ifdef DEBUG
+ printf("ProcessUpdates status: %s (%d)\n", UpdateStatusToString(status),
+ status);
+ printf("ProcessUpdates updatesDir: %s\n",
+ updatesDir->HumanReadablePath().get());
+#endif
switch (status) {
case ePendingUpdate:
case ePendingService: {
@@ -748,13 +850,16 @@ nsUpdateProcessor::ProcessUpdate() {
NS_ENSURE_SUCCESS(rv, rv);
}
+ nsAutoCString appVersion;
+#ifdef TOR_BROWSER_UPDATE
+ appVersion = TOR_BROWSER_VERSION_QUOTED;
+#else
nsCOMPtr<nsIXULAppInfo> appInfo =
do_GetService("@mozilla.org/xre/app-info;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
-
- nsAutoCString appVersion;
rv = appInfo->GetVersion(appVersion);
NS_ENSURE_SUCCESS(rv, rv);
+#endif
// Copy the parameters to the StagedUpdateInfo structure shared with the
// watcher thread.
diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp
index 2e965b3526ad..ff114a07faa5 100644
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -1232,6 +1232,41 @@ nsresult nsXREDirProvider::GetUpdateRootDir(nsIFile** aResult,
}
#endif
nsCOMPtr<nsIFile> updRoot;
+#if defined(TOR_BROWSER_UPDATE)
+ // For Tor Browser, we store update history, etc. within the UpdateInfo
+ // directory under the user data directory.
+ nsresult rv = GetTorBrowserUserDataDir(getter_AddRefs(updRoot));
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = updRoot->AppendNative("UpdateInfo"_ns);
+ NS_ENSURE_SUCCESS(rv, rv);
+# if defined(XP_MACOSX) && defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
+ // Since the TorBrowser-Data directory may be shared among different
+ // installations of the application, embed the app path in the update dir
+ // so that the update history is partitioned. This is much less likely to
+ // be an issue on Linux or Windows because the Tor Browser packages for
+ // those platforms include a "container" folder that provides partitioning
+ // by default, and we do not support use of a shared, OS-recommended area
+ // for user data on those platforms.
+ nsCOMPtr<nsIFile> appFile;
+ bool per = false;
+ rv = GetFile(XRE_EXECUTABLE_FILE, &per, getter_AddRefs(appFile));
+ NS_ENSURE_SUCCESS(rv, rv);
+ nsCOMPtr<nsIFile> appRootDirFile;
+ nsAutoString appDirPath;
+ if (NS_FAILED(appFile->GetParent(getter_AddRefs(appRootDirFile))) ||
+ NS_FAILED(appRootDirFile->GetPath(appDirPath))) {
+ return NS_ERROR_FAILURE;
+ }
+
+ int32_t dotIndex = appDirPath.RFind(".app");
+ if (dotIndex == kNotFound) {
+ dotIndex = appDirPath.Length();
+ }
+ appDirPath = Substring(appDirPath, 1, dotIndex - 1);
+ rv = updRoot->AppendRelativePath(appDirPath);
+ NS_ENSURE_SUCCESS(rv, rv);
+# endif
+#else // ! TOR_BROWSER_UPDATE
nsCOMPtr<nsIFile> appFile;
bool per = false;
nsresult rv = GetFile(XRE_EXECUTABLE_FILE, &per, getter_AddRefs(appFile));
@@ -1239,7 +1274,7 @@ nsresult nsXREDirProvider::GetUpdateRootDir(nsIFile** aResult,
rv = appFile->GetParent(getter_AddRefs(updRoot));
NS_ENSURE_SUCCESS(rv, rv);
-#ifdef XP_MACOSX
+# ifdef XP_MACOSX
nsCOMPtr<nsIFile> appRootDirFile;
nsCOMPtr<nsIFile> localDir;
nsAutoString appDirPath;
@@ -1273,7 +1308,7 @@ nsresult nsXREDirProvider::GetUpdateRootDir(nsIFile** aResult,
localDir.forget(aResult);
return NS_OK;
-#elif XP_WIN
+# elif XP_WIN
nsAutoString installPath;
rv = updRoot->GetPath(installPath);
NS_ENSURE_SUCCESS(rv, rv);
@@ -1302,7 +1337,8 @@ nsresult nsXREDirProvider::GetUpdateRootDir(nsIFile** aResult,
nsAutoString updatePathStr;
updatePathStr.Assign(updatePath.get());
updRoot->InitWithPath(updatePathStr);
-#endif // XP_WIN
+# endif // XP_WIN
+#endif // ! TOR_BROWSER_UPDATE
updRoot.forget(aResult);
return NS_OK;
}
diff --git a/tools/update-packaging/common.sh b/tools/update-packaging/common.sh
index 4b994f30169c..26eabbf31379 100755
--- a/tools/update-packaging/common.sh
+++ b/tools/update-packaging/common.sh
@@ -8,6 +8,10 @@
# Author: Darin Fisher
#
+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
+# we should remove all lines in this file that contain:
+# TorBrowser/Data
+
# -----------------------------------------------------------------------------
QUIET=0
@@ -76,17 +80,8 @@ make_add_instruction() {
forced=
fi
- is_extension=$(echo "$f" | grep -c 'distribution/extensions/.*/')
- if [ $is_extension = "1" ]; then
- # Use the subdirectory of the extensions folder as the file to test
- # before performing this add instruction.
- testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
- verbose_notice " add-if \"$testdir\" \"$f\""
- echo "add-if \"$testdir\" \"$f\"" >> "$filev3"
- else
- verbose_notice " add \"$f\"$forced"
- echo "add \"$f\"" >> "$filev3"
- fi
+ verbose_notice " add \"$f\"$forced"
+ echo "add \"$f\"" >> "$filev3"
}
check_for_add_if_not_update() {
@@ -109,21 +104,21 @@ make_add_if_not_instruction() {
echo "add-if-not \"$f\" \"$f\"" >> "$filev3"
}
+make_addsymlink_instruction() {
+ link="$1"
+ target="$2"
+ filev3="$3"
+
+ verbose_notice " addsymlink: $link -> $target"
+ echo "addsymlink \"$link\" \"$target\"" >> "$filev3"
+}
+
make_patch_instruction() {
f="$1"
filev3="$2"
- is_extension=$(echo "$f" | grep -c 'distribution/extensions/.*/')
- if [ $is_extension = "1" ]; then
- # Use the subdirectory of the extensions folder as the file to test
- # before performing this add instruction.
- testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
- verbose_notice " patch-if \"$testdir\" \"$f.patch\" \"$f\""
- echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> "$filev3"
- else
- verbose_notice " patch \"$f.patch\" \"$f\""
- echo "patch \"$f.patch\" \"$f\"" >> "$filev3"
- fi
+ verbose_notice " patch \"$f.patch\" \"$f\""
+ echo "patch \"$f.patch\" \"$f\"" >> "$filev3"
}
append_remove_instructions() {
@@ -168,6 +163,10 @@ append_remove_instructions() {
# List all files in the current directory, stripping leading "./"
# Pass a variable name and it will be filled as an array.
+# To support Tor Browser updates, skip the following files:
+# TorBrowser/Data/Browser/profiles.ini
+# TorBrowser/Data/Browser/profile.default/bookmarks.html
+# TorBrowser/Data/Tor/torrc
list_files() {
count=0
temp_filelist=$(mktemp)
@@ -178,6 +177,11 @@ list_files() {
| sed 's/\.\/\(.*\)/\1/' \
| sort -r > "${temp_filelist}"
while read file; do
+ if [ "$file" = "TorBrowser/Data/Browser/profiles.ini" -o \
+ "$file" = "TorBrowser/Data/Browser/profile.default/bookmarks.html" -o \
+ "$file" = "TorBrowser/Data/Tor/torrc" ]; then
+ continue;
+ fi
eval "${1}[$count]=\"$file\""
(( count++ ))
done < "${temp_filelist}"
@@ -199,3 +203,19 @@ list_dirs() {
done < "${temp_dirlist}"
rm "${temp_dirlist}"
}
+
+# List all symbolic links in the current directory, stripping leading "./"
+list_symlinks() {
+ count=0
+
+ find . -type l \
+ | sed 's/\.\/\(.*\)/\1/' \
+ | sort -r > "temp-symlinklist"
+ while read symlink; do
+ target=$(readlink "$symlink")
+ eval "${1}[$count]=\"$symlink\""
+ eval "${2}[$count]=\"$target\""
+ (( count++ ))
+ done < "temp-symlinklist"
+ rm "temp-symlinklist"
+}
diff --git a/tools/update-packaging/make_full_update.sh b/tools/update-packaging/make_full_update.sh
index db2c5898efdc..603988997405 100755
--- a/tools/update-packaging/make_full_update.sh
+++ b/tools/update-packaging/make_full_update.sh
@@ -71,6 +71,7 @@ if [ ! -f "precomplete" ]; then
fi
list_files files
+list_symlinks symlinks symlink_targets
popd
@@ -81,6 +82,21 @@ notice "Adding type instruction to update manifests"
notice " type complete"
echo "type \"complete\"" >> "$updatemanifestv3"
+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
+# we should remove the following lines:
+# If removal of any old, existing directories is desired, emit the appropriate
+# rmrfdir commands.
+notice ""
+notice "Adding directory removal instructions to update manifests"
+for dir_to_remove in $directories_to_remove; do
+ # rmrfdir requires a trailing slash; if slash is missing, add one.
+ if ! [[ "$dir_to_remove" =~ /$ ]]; then
+ dir_to_remove="${dir_to_remove}/"
+ fi
+ echo "rmrfdir \"$dir_to_remove\"" >> "$updatemanifestv3"
+done
+# END TOR_BROWSER_DATA_OUTSIDE_APP_DIR removal
+
notice ""
notice "Adding file add instructions to update manifests"
num_files=${#files[*]}
@@ -102,6 +118,15 @@ for ((i=0; $i<$num_files; i=$i+1)); do
targetfiles="$targetfiles \"$f\""
done
+notice ""
+notice "Adding symlink add instructions to update manifests"
+num_symlinks=${#symlinks[*]}
+for ((i=0; $i<$num_symlinks; i=$i+1)); do
+ link="${symlinks[$i]}"
+ target="${symlink_targets[$i]}"
+ make_addsymlink_instruction "$link" "$target" "$updatemanifestv3"
+done
+
# Append remove instructions for any dead files.
notice ""
notice "Adding file and directory remove instructions from file 'removed-files'"
diff --git a/tools/update-packaging/make_incremental_update.sh b/tools/update-packaging/make_incremental_update.sh
index 24d68616731a..1adfef8fd96e 100755
--- a/tools/update-packaging/make_incremental_update.sh
+++ b/tools/update-packaging/make_incremental_update.sh
@@ -78,7 +78,11 @@ if [ $# = 0 ]; then
exit 1
fi
-requested_forced_updates='Contents/MacOS/firefox'
+# Firefox uses requested_forced_updates='Contents/MacOS/firefox' due to
+# 770996 but in Tor Browser we do not need that fix.
+requested_forced_updates=""
+directories_to_remove=""
+extra_files_to_remove=""
while getopts "hqf:" flag
do
@@ -114,6 +118,28 @@ workdir="$(mktemp -d)"
updatemanifestv3="$workdir/updatev3.manifest"
archivefiles="updatev3.manifest"
+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
+# we should remove the following lines:
+# If the NoScript extension has changed between
+# releases, add it to the "force updates" list.
+ext_path='TorBrowser/Data/Browser/profile.default/extensions'
+if [ -d "$newdir/$ext_path" ]; then
+ noscript='{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi'
+
+ # NoScript is a packed extension, so we simply compare the old and the new
+ # .xpi files.
+ noscript_path="$ext_path/$noscript"
+ diff -a "$olddir/$noscript_path" "$newdir/$noscript_path" > /dev/null
+ rc=$?
+ if [ $rc -gt 1 ]; then
+ notice "Unexpected exit $rc from $noscript_path diff command"
+ exit 2
+ elif [ $rc -eq 1 ]; then
+ requested_forced_updates="$requested_forced_updates $noscript_path"
+ fi
+fi
+# END TOR_BROWSER_DATA_OUTSIDE_APP_DIR removal
+
mkdir -p "$workdir"
# Generate a list of all files in the target directory.
@@ -124,6 +150,7 @@ fi
list_files oldfiles
list_dirs olddirs
+list_symlinks oldsymlinks oldsymlink_targets
popd
@@ -141,6 +168,7 @@ fi
list_dirs newdirs
list_files newfiles
+list_symlinks newsymlinks newsymlink_targets
popd
@@ -151,6 +179,22 @@ notice "Adding type instruction to update manifests"
notice " type partial"
echo "type \"partial\"" >> $updatemanifestv3
+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
+# we should remove the following lines:
+# If removal of any old, existing directories is desired, emit the appropriate
+# rmrfdir commands.
+notice ""
+notice "Adding directory removal instructions to update manifests"
+for dir_to_remove in $directories_to_remove; do
+ # rmrfdir requires a trailing slash, so add one if missing.
+ if ! [[ "$dir_to_remove" =~ /$ ]]; then
+ dir_to_remove="${dir_to_remove}/"
+ fi
+ echo "rmrfdir \"$dir_to_remove\"" >> "$updatemanifestv3"
+done
+# END TOR_BROWSER_DATA_OUTSIDE_APP_DIR removal
+
+
notice ""
notice "Adding file patch and add instructions to update manifests"
@@ -242,6 +286,23 @@ for ((i=0; $i<$num_oldfiles; i=$i+1)); do
fi
done
+# Remove and re-add symlinks
+notice ""
+notice "Adding symlink remove/add instructions to update manifests"
+num_oldsymlinks=${#oldsymlinks[*]}
+for ((i=0; $i<$num_oldsymlinks; i=$i+1)); do
+ link="${oldsymlinks[$i]}"
+ verbose_notice " remove: $link"
+ echo "remove \"$link\"" >> "$updatemanifestv3"
+done
+
+num_newsymlinks=${#newsymlinks[*]}
+for ((i=0; $i<$num_newsymlinks; i=$i+1)); do
+ link="${newsymlinks[$i]}"
+ target="${newsymlink_targets[$i]}"
+ make_addsymlink_instruction "$link" "$target" "$updatemanifestv3"
+done
+
# Newly added files
notice ""
notice "Adding file add instructions to update manifests"
@@ -286,6 +347,14 @@ notice ""
notice "Adding file and directory remove instructions from file 'removed-files'"
append_remove_instructions "$newdir" "$updatemanifestv3"
+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
+# we should remove the following lines:
+for f in $extra_files_to_remove; do
+ notice " remove \"$f\""
+ echo "remove \"$f\"" >> "$updatemanifestv3"
+done
+# END TOR_BROWSER_DATA_OUTSIDE_APP_DIR removal
+
notice ""
notice "Adding directory remove instructions for directories that no longer exist"
num_olddirs=${#olddirs[*]}
1
0

[tor-browser/tor-browser-91.5.0esr-11.5-2] Bug 25741 - TBA: Disable GeckoNetworkManager
by richard@torproject.org 01 Feb '22
by richard@torproject.org 01 Feb '22
01 Feb '22
commit b93a923053c338189d8382ba72e6bae175861f87
Author: Matthew Finkel <Matthew.Finkel(a)gmail.com>
Date: Thu Apr 26 22:22:51 2018 +0000
Bug 25741 - TBA: Disable GeckoNetworkManager
The browser should not need information related to the network
interface or network state, tor should take care of that.
---
.../src/main/java/org/mozilla/geckoview/GeckoRuntime.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
index f084b522ad53..b94d8e803b6b 100644
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
@@ -122,7 +122,9 @@ public final class GeckoRuntime implements Parcelable {
mPaused = false;
// Monitor network status and send change notifications to Gecko
// while active.
- GeckoNetworkManager.getInstance().start(GeckoAppShell.getApplicationContext());
+ if (BuildConfig.TOR_BROWSER_VERSION == "") {
+ GeckoNetworkManager.getInstance().start(GeckoAppShell.getApplicationContext());
+ }
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
@@ -130,7 +132,9 @@ public final class GeckoRuntime implements Parcelable {
Log.d(LOGTAG, "Lifecycle: onPause");
mPaused = true;
// Stop monitoring network status while inactive.
- GeckoNetworkManager.getInstance().stop();
+ if (BuildConfig.TOR_BROWSER_VERSION == "") {
+ GeckoNetworkManager.getInstance().stop();
+ }
GeckoThread.onPause();
}
}
1
0