commit 4a198c7b89b7b00a7cae956765210c4c9ed341da
parent a759d030f2f642f5e229348559337e7139adba8a
Author: Pier Angelo Vendrame <pierov@torproject.org>
Date: Mon, 2 Sep 2024 17:56:06 +0200
TB 42891: Set the bundled search engine for Tor Browser.
Diffstat:
6 files changed, 87 insertions(+), 3 deletions(-)
diff --git a/toolkit/components/search/SearchService.sys.mjs b/toolkit/components/search/SearchService.sys.mjs
@@ -2893,10 +2893,10 @@ export class SearchService {
// called in test_remove_engine_notification_box.js
async _fetchEngineSelectorEngines() {
let searchEngineSelectorProperties = {
- locale: Services.locale.appLocaleAsBCP47,
+ locale: "en-US",
region: lazy.Region.home || "unknown",
channel: lazy.SearchUtils.MODIFIED_APP_CHANNEL,
- experiment: this.#lazyPrefs.experimentPrefValue,
+ experiment: this._experimentPrefValue,
distroID: lazy.SearchUtils.distroID ?? "",
javascriptEnabled: lazy.SecurityLevelPrefs.javascriptEnabled,
};
diff --git a/toolkit/components/search/content/base-browser-search-engine-icons.json b/toolkit/components/search/content/base-browser-search-engine-icons.json
@@ -5,6 +5,9 @@
"ddg-noai": [
{ "url": "chrome://global/content/search/duckduckgo.ico", "imageSize": 32 }
],
+ "ddg-onion": [
+ { "url": "chrome://global/content/search/duckduckgo.ico", "imageSize": 32 }
+ ],
"startpage": [
{
"url": "chrome://global/content/search/startpage-16.png",
@@ -14,5 +17,18 @@
"url": "chrome://global/content/search/startpage-32.png",
"imageSize": 32
}
+ ],
+ "startpage-onion": [
+ {
+ "url": "chrome://global/content/search/startpage-16.png",
+ "imageSize": 16
+ },
+ {
+ "url": "chrome://global/content/search/startpage-32.png",
+ "imageSize": 32
+ }
+ ],
+ "wikipedia": [
+ { "url": "chrome://global/content/search/wikipedia.ico", "imageSize": 32 }
]
}
diff --git a/toolkit/components/search/content/base-browser-search-engines.json b/toolkit/components/search/content/base-browser-search-engines.json
@@ -37,6 +37,24 @@
},
{
"base": {
+ "aliases": ["ddgonion"],
+ "classification": "general",
+ "name": "DuckDuckGo (.onion)",
+ "urls": {
+ "search": {
+ "base": "https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/",
+ "params": [],
+ "searchTermParamName": "q"
+ }
+ }
+ },
+ "id": "1e431da4-a60c-4411-9251-a95a841d451f",
+ "identifier": "ddg-onion",
+ "recordType": "engine",
+ "variants": [{ "environment": { "allRegionsAndLocales": true } }]
+ },
+ {
+ "base": {
"aliases": ["startpage", "sp"],
"classification": "general",
"name": "Startpage",
@@ -54,6 +72,42 @@
"variants": [{ "environment": { "allRegionsAndLocales": true } }]
},
{
+ "base": {
+ "aliases": ["startpage-onion"],
+ "classification": "general",
+ "name": "Startpage (.onion)",
+ "urls": {
+ "search": {
+ "base": "http://startpagel6srwcjlue4zgq3zevrujfaow726kjytqbbjyrswwmjzcqd.onion/sp/search",
+ "params": [],
+ "searchTermParamName": "q"
+ }
+ }
+ },
+ "id": "e7eaba8d-6b9e-43fb-a799-b01b096c03ff",
+ "identifier": "startpage-onion",
+ "recordType": "engine",
+ "variants": [{ "environment": { "allRegionsAndLocales": true } }]
+ },
+ {
+ "base": {
+ "aliases": ["wikipedia"],
+ "classification": "unknown",
+ "name": "Wikipedia (en)",
+ "urls": {
+ "search": {
+ "base": "https://en.wikipedia.org/wiki/Special:Search",
+ "params": [],
+ "searchTermParamName": "search"
+ }
+ }
+ },
+ "id": "7f6d23c2-191e-483e-af3a-ce6451e3a8dd",
+ "identifier": "wikipedia",
+ "recordType": "engine",
+ "variants": [{ "environment": { "allRegionsAndLocales": true } }]
+ },
+ {
"recordType": "defaultEngines",
"globalDefault": "ddg",
"globalDefaultPrivate": "ddg"
@@ -63,7 +117,14 @@
"orders": [
{
"environment": { "allRegionsAndLocales": true },
- "order": ["ddg", "ddg-noai", "startpage"]
+ "order": [
+ "ddg",
+ "ddg-noai",
+ "ddg-onion",
+ "startpage",
+ "startpage-onion",
+ "wikipedia"
+ ]
}
]
}
diff --git a/toolkit/components/search/content/wikipedia.ico b/toolkit/components/search/content/wikipedia.ico
Binary files differ.
diff --git a/toolkit/components/search/tests/xpcshell/test_base_browser.js b/toolkit/components/search/tests/xpcshell/test_base_browser.js
@@ -13,7 +13,12 @@
const expectedURLs = {
ddg: "https://duckduckgo.com/?q=test",
"ddg-noai": "https://noai.duckduckgo.com/?q=test",
+ "ddg-onion":
+ "https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/?q=test",
startpage: "https://www.startpage.com/sp/search?q=test",
+ "startpage-onion":
+ "http://startpagel6srwcjlue4zgq3zevrujfaow726kjytqbbjyrswwmjzcqd.onion/sp/search?q=test",
+ wikipedia: "https://en.wikipedia.org/wiki/Special:Search?search=test",
};
const defaultEngine = "ddg";
diff --git a/toolkit/components/search/tests/xpcshell/test_security_level.js b/toolkit/components/search/tests/xpcshell/test_security_level.js
@@ -10,6 +10,8 @@
const expectedURLs = {
ddg: "https://html.duckduckgo.com/html?q=test",
+ "ddg-onion":
+ "https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/html?q=test",
};
add_task(async function test_securityLevel() {