[tor-commits] [tor-browser] 25/76: Bug 1759008 - Update search parameters. r=mkaply a=pascalc
gitolite role
git at cupani.torproject.org
Wed Mar 30 20:39:53 UTC 2022
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.8.0esr-11.0-1
in repository tor-browser.
commit 2aad63ad5eb55c219ac4cf533fec7469729a186c
Author: Mark Banner <standard8 at mozilla.com>
AuthorDate: Fri Mar 11 15:42:09 2022 +0000
Bug 1759008 - Update search parameters. r=mkaply a=pascalc
Differential Revision: https://phabricator.services.mozilla.com/D140917
---
.../extensions/google/_locales/by/messages.json | 20 +++++++
.../extensions/google/_locales/kz/messages.json | 20 +++++++
.../extensions/google/_locales/ru/messages.json | 20 +++++++
.../extensions/google/_locales/tr/messages.json | 20 +++++++
.../search/extensions/google/manifest.json | 2 +-
toolkit/components/search/SearchEngineSelector.jsm | 17 +++++-
.../search/docs/SearchConfigurationSchema.rst | 10 ++++
.../search/schema/search-engine-config-schema.json | 4 +-
.../search/tests/xpcshell/test_engine_selector.js | 64 +++++++++++++++++++++-
9 files changed, 171 insertions(+), 6 deletions(-)
diff --git a/browser/components/search/extensions/google/_locales/by/messages.json b/browser/components/search/extensions/google/_locales/by/messages.json
new file mode 100644
index 0000000000000..ffcf375a30f00
--- /dev/null
+++ b/browser/components/search/extensions/google/_locales/by/messages.json
@@ -0,0 +1,20 @@
+{
+ "extensionName": {
+ "message": "Google"
+ },
+ "extensionDescription": {
+ "message": "Google Search"
+ },
+ "searchUrl": {
+ "message": "https://www.google.by/search"
+ },
+ "searchForm": {
+ "message": "https://www.google.by/search?q={searchTerms}"
+ },
+ "suggestUrl": {
+ "message": "https://www.google.by/complete/search?q={searchTerms}"
+ },
+ "searchUrlGetParams": {
+ "message": "q={searchTerms}"
+ }
+}
diff --git a/browser/components/search/extensions/google/_locales/kz/messages.json b/browser/components/search/extensions/google/_locales/kz/messages.json
new file mode 100644
index 0000000000000..d94530101d777
--- /dev/null
+++ b/browser/components/search/extensions/google/_locales/kz/messages.json
@@ -0,0 +1,20 @@
+{
+ "extensionName": {
+ "message": "Google"
+ },
+ "extensionDescription": {
+ "message": "Google Search"
+ },
+ "searchUrl": {
+ "message": "https://www.google.kz/search"
+ },
+ "searchForm": {
+ "message": "https://www.google.kz/search?q={searchTerms}"
+ },
+ "suggestUrl": {
+ "message": "https://www.google.kz/complete/search?q={searchTerms}"
+ },
+ "searchUrlGetParams": {
+ "message": "q={searchTerms}"
+ }
+}
diff --git a/browser/components/search/extensions/google/_locales/ru/messages.json b/browser/components/search/extensions/google/_locales/ru/messages.json
new file mode 100644
index 0000000000000..ba103cb6314bc
--- /dev/null
+++ b/browser/components/search/extensions/google/_locales/ru/messages.json
@@ -0,0 +1,20 @@
+{
+ "extensionName": {
+ "message": "Google"
+ },
+ "extensionDescription": {
+ "message": "Google Search"
+ },
+ "searchUrl": {
+ "message": "https://www.google.ru/search"
+ },
+ "searchForm": {
+ "message": "https://www.google.ru/search?q={searchTerms}"
+ },
+ "suggestUrl": {
+ "message": "https://www.google.ru/complete/search?q={searchTerms}"
+ },
+ "searchUrlGetParams": {
+ "message": "q={searchTerms}"
+ }
+}
diff --git a/browser/components/search/extensions/google/_locales/tr/messages.json b/browser/components/search/extensions/google/_locales/tr/messages.json
new file mode 100644
index 0000000000000..0087bc2135a0f
--- /dev/null
+++ b/browser/components/search/extensions/google/_locales/tr/messages.json
@@ -0,0 +1,20 @@
+{
+ "extensionName": {
+ "message": "Google"
+ },
+ "extensionDescription": {
+ "message": "Google Search"
+ },
+ "searchUrl": {
+ "message": "https://www.google.com.tr/search"
+ },
+ "searchForm": {
+ "message": "https://www.google.com.tr/search?q={searchTerms}"
+ },
+ "suggestUrl": {
+ "message": "https://www.google.com.tr/complete/search?q={searchTerms}"
+ },
+ "searchUrlGetParams": {
+ "message": "q={searchTerms}"
+ }
+}
diff --git a/browser/components/search/extensions/google/manifest.json b/browser/components/search/extensions/google/manifest.json
index d62049705ae2e..6cd4d2a42358e 100644
--- a/browser/components/search/extensions/google/manifest.json
+++ b/browser/components/search/extensions/google/manifest.json
@@ -2,7 +2,7 @@
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__",
"manifest_version": 2,
- "version": "1.1",
+ "version": "1.2",
"applications": {
"gecko": {
"id": "google at search.mozilla.org"
diff --git a/toolkit/components/search/SearchEngineSelector.jsm b/toolkit/components/search/SearchEngineSelector.jsm
index 9f61477182009..d44de4139bb3a 100644
--- a/toolkit/components/search/SearchEngineSelector.jsm
+++ b/toolkit/components/search/SearchEngineSelector.jsm
@@ -18,6 +18,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
});
const USER_LOCALE = "$USER_LOCALE";
+const USER_REGION = "$USER_REGION";
XPCOMUtils.defineLazyGetter(this, "logConsole", () => {
return console.createInstance({
@@ -265,8 +266,17 @@ class SearchEngineSelector {
const engine = { ...baseConfig };
engine.webExtension = { ...baseConfig.webExtension };
delete engine.webExtension.locales;
- engine.webExtension.locale =
- webExtensionLocale == USER_LOCALE ? locale : webExtensionLocale;
+ switch (webExtensionLocale) {
+ case USER_LOCALE:
+ engine.webExtension.locale = locale;
+ break;
+ case USER_REGION:
+ engine.webExtension.locale = lcRegion;
+ break;
+ default:
+ engine.webExtension.locale = webExtensionLocale;
+ break;
+ }
engines.push(engine);
}
} else {
@@ -292,6 +302,9 @@ class SearchEngineSelector {
}
for (const engine of engines) {
+ engine.telemetryId = engine.telemetryId
+ ?.replace(USER_LOCALE, locale)
+ .replace(USER_REGION, lcRegion);
if (
"default" in engine &&
shouldPrefer(
diff --git a/toolkit/components/search/docs/SearchConfigurationSchema.rst b/toolkit/components/search/docs/SearchConfigurationSchema.rst
index ce28f0f2ecb20..65726b4bfffad 100644
--- a/toolkit/components/search/docs/SearchConfigurationSchema.rst
+++ b/toolkit/components/search/docs/SearchConfigurationSchema.rst
@@ -114,6 +114,16 @@ configuration object with the users locale. For example:
Will report either ``[us]`` or ``[gb]`` as the ``webExtension.locales``
depending on the user's locale.
+From Firefox 98.0.1 and 97.7.1esr, ``"$USER_LOCALE"`` may also be used in the
+``telemetryId`` field.
+
+$USER_REGION
+------------
+
+This can be used in the same situations as ``"$USER_LOCALE"``.
+
+It was added in the Firefox 98.0.1 and 97.7.1esr releases.
+
"default"
---------
diff --git a/toolkit/components/search/schema/search-engine-config-schema.json b/toolkit/components/search/schema/search-engine-config-schema.json
index 5f3e477982b95..3cf5e80fc4483 100644
--- a/toolkit/components/search/schema/search-engine-config-schema.json
+++ b/toolkit/components/search/schema/search-engine-config-schema.json
@@ -319,7 +319,7 @@
"telemetryId": {
"type": "string",
"title": "Telemetry Id",
- "pattern": "^[a-zA-Z0-9-]{0,100}$",
+ "pattern": "^[a-zA-Z0-9-$_]{0,100}$",
"description": "The telemetry Id as used for some of SEARCH_COUNTS telemetry."
},
"webExtension": {
@@ -335,7 +335,7 @@
"locale": {
"type": "string",
"title": "WebExtension Locale",
- "pattern": "^[a-zA-Z0-9-]{0,100}$",
+ "pattern": "^[a-zA-Z0-9-$_]{0,100}$",
"description": "Overrides the WebExtension locales and specifies to use a particular one. Ideally this should only be used when really necessary, otherwise considered deprecated."
}
}
diff --git a/toolkit/components/search/tests/xpcshell/test_engine_selector.js b/toolkit/components/search/tests/xpcshell/test_engine_selector.js
index def9393d230cd..02f6aae451ab8 100644
--- a/toolkit/components/search/tests/xpcshell/test_engine_selector.js
+++ b/toolkit/components/search/tests/xpcshell/test_engine_selector.js
@@ -23,6 +23,14 @@ const TEST_CONFIG = [
webExtension: {
locales: ["$USER_LOCALE"],
},
+ telemetryId: "foo-$USER_LOCALE",
+ },
+ {
+ included: { regions: ["fr"] },
+ webExtension: {
+ locales: ["$USER_REGION"],
+ },
+ telemetryId: "bar-$USER_REGION",
},
],
},
@@ -71,10 +79,12 @@ const TEST_CONFIG = [
const engineSelector = new SearchEngineSelector();
-add_task(async function() {
+add_task(async function setup() {
const settings = await RemoteSettings(SearchUtils.SETTINGS_KEY);
sinon.stub(settings, "get").returns(TEST_CONFIG);
+});
+add_task(async function test_engine_selector() {
let {
engines,
privateDefault,
@@ -135,3 +145,55 @@ add_task(async function() {
"Should set altavista as privateDefault"
);
});
+
+add_task(async function test_locale_region_replacement() {
+ let { engines } = await engineSelector.fetchEngineConfiguration({
+ locale: "en-US",
+ region: "us",
+ });
+ let engine = engines.find(e => e.engineName == "aol");
+ Assert.equal(
+ engine.webExtension.locale,
+ "en-US",
+ "The locale is correctly inserted into the locale field"
+ );
+ Assert.equal(
+ engine.telemetryId,
+ "foo-en-US",
+ "The locale is correctly inserted into the telemetryId"
+ );
+
+ ({ engines } = await engineSelector.fetchEngineConfiguration({
+ locale: "it",
+ region: "us",
+ }));
+ engine = engines.find(e => e.engineName == "aol");
+
+ Assert.equal(
+ engines.find(e => e.engineName == "aol").webExtension.locale,
+ "it",
+ "The locale is correctly inserted into the locale field"
+ );
+ Assert.equal(
+ engine.telemetryId,
+ "foo-it",
+ "The locale is correctly inserted into the telemetryId"
+ );
+
+ ({ engines } = await engineSelector.fetchEngineConfiguration({
+ locale: "en-CA",
+ region: "fr",
+ }));
+ engine = engines.find(e => e.engineName == "aol");
+
+ Assert.equal(
+ engines.find(e => e.engineName == "aol").webExtension.locale,
+ "fr",
+ "The region is correctly inserted into the locale field"
+ );
+ Assert.equal(
+ engine.telemetryId,
+ "bar-fr",
+ "The region is correctly inserted into the telemetryId"
+ );
+});
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the tor-commits
mailing list