forked from mirrors/gecko-dev
Bug 1863360 - Make tests pass for app provided search engine class. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D192862
This commit is contained in:
parent
5a00aa459f
commit
d8ddd3cc26
36 changed files with 1271 additions and 350 deletions
|
|
@ -2,7 +2,10 @@
|
|||
"data": [
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "basic@search.mozilla.org"
|
||||
"id": "basic@search.mozilla.org",
|
||||
"name": "basic",
|
||||
"search_url": "https://mochi.test:8888/browser/browser/components/search/test/browser/?search={searchTerms}&foo=1",
|
||||
"suggest_url": "https://mochi.test:8888/browser/browser/modules/test/browser/usageTelemetrySearchSuggestions.sjs?{searchTerms}"
|
||||
},
|
||||
"appliesTo": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1866,18 +1866,16 @@
|
|||
"us": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.com",
|
||||
"search_url": "https://www.amazon.com/exec/obidos/external-search/",
|
||||
"search_form": "https://www.amazon.com/exec/obidos/external-search/",
|
||||
"suggest_url": "https://completion.amazon.com/search/complete?q={searchTerms}&search-alias=aps&mkt=1",
|
||||
"search_url_get_params": "field-keywords={searchTerms}&ie={inputEncoding}&mode=blended&tag=moz-us-20&sourceid=Mozilla-search"
|
||||
"search_url": "https://www.amazon.com/exec/s",
|
||||
"search_form": "https://www.amazon.com/",
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
},
|
||||
"en": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.com",
|
||||
"search_url": "https://www.amazon.com/exec/obidos/external-search/",
|
||||
"search_form": "https://www.amazon.com/exec/obidos/external-search/",
|
||||
"suggest_url": "https://completion.amazon.com/search/complete?q={searchTerms}&search-alias=aps&mkt=1",
|
||||
"search_url_get_params": "field-keywords={searchTerms}&ie={inputEncoding}&mode=blended&tag=mozilla-20&sourceid=Mozilla-search"
|
||||
"search_url": "https://www.amazon.com/exec/s",
|
||||
"search_form": "https://www.amazon.com/",
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -1978,101 +1976,79 @@
|
|||
"sweden": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.se",
|
||||
"search_url": "https://www.amazon.se/exec/obidos/external-search/",
|
||||
"search_url": "https://www.amazon.se/s",
|
||||
"search_form": "https://www.amazon.se/",
|
||||
"search_url_get_params": "field-keywords={searchTerms}&ie={inputEncoding}&mode=blended&tag=mozillasweede-21&sourceid=Mozilla-search",
|
||||
"suggest_url": "https://completion.amazon.se/search/complete",
|
||||
"suggest_url_get_params": "q={searchTerms}&search-alias=aps&mkt=704403121"
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
},
|
||||
"france": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.fr",
|
||||
"search_url": "https://www.amazon.fr/exec/obidos/external-search/",
|
||||
"search_url": "https://www.amazon.fr/exec/s",
|
||||
"search_form": "https://www.amazon.fr/",
|
||||
"search_url_get_params": "field-keywords={searchTerms}&ie={inputEncoding}&mode=blended&tag=firefox-fr-21&sourceid=Mozilla-search",
|
||||
"suggest_url": "https://completion.amazon.fr/search/complete",
|
||||
"suggest_url_get_params": "q={searchTerms}&search-alias=aps&mkt=5"
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
},
|
||||
"in": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.in",
|
||||
"search_url": "https://www.amazon.in/exec/obidos/external-search/",
|
||||
"search_url": "https://www.amazon.in/s",
|
||||
"search_form": "https://www.amazon.in/",
|
||||
"search_url_get_params": "field-keywords={searchTerms}&ie={inputEncoding}&mode=blended&sourceid=Mozilla-search",
|
||||
"suggest_url": "https://completion.amazon.in/search/complete",
|
||||
"suggest_url_get_params": "q={searchTerms}&search-alias=aps&mkt=44571"
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
},
|
||||
"spain": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.es",
|
||||
"search_url": "https://www.amazon.es/exec/obidos/external-search/",
|
||||
"search_url": "https://www.amazon.es/s",
|
||||
"search_form": "https://www.amazon.es/",
|
||||
"search_url_get_params": "field-keywords={searchTerms}&ie={inputEncoding}&mode=blended&tag=mozillaspain-21&sourceid=Mozilla-search",
|
||||
"suggest_url": "https://completion.amazon.es/search/complete",
|
||||
"suggest_url_get_params": "q={searchTerms}&search-alias=aps&mkt=44551"
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
},
|
||||
"it": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.it",
|
||||
"search_url": "https://www.amazon.it/exec/obidos/external-search/",
|
||||
"search_url": "https://www.amazon.it/s",
|
||||
"search_form": "https://www.amazon.it/",
|
||||
"search_url_get_params": "field-keywords={searchTerms}&ie={inputEncoding}&mode=blended&tag=firefoxit-21&sourceid=Mozilla-search",
|
||||
"suggest_url": "https://completion.amazon.it/search/complete",
|
||||
"suggest_url_get_params": "q={searchTerms}&search-alias=aps&mkt=35691"
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
},
|
||||
"ca": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.ca",
|
||||
"search_url": "https://www.amazon.ca/exec/obidos/external-search/",
|
||||
"search_form": "https://www.amazon.ca/exec/obidos/external-search/",
|
||||
"search_url_get_params": "field-keywords={searchTerms}&ie={inputEncoding}&mode=blended&tag=mozillacanada-20&sourceid=Mozilla-search",
|
||||
"suggest_url": "https://completion.amazon.ca/search/complete",
|
||||
"suggest_url_get_params": "q={searchTerms}&search-alias=aps&mkt=7"
|
||||
"search_url": "https://www.amazon.ca/s",
|
||||
"search_form": "https://www.amazon.ca/",
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
},
|
||||
"en-GB": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.co.uk",
|
||||
"search_url": "https://www.amazon.co.uk/exec/obidos/external-search/",
|
||||
"search_url": "https://www.amazon.co.uk/s",
|
||||
"search_form": "https://www.amazon.co.uk/",
|
||||
"search_url_get_params": "field-keywords={searchTerms}&ie={inputEncoding}&mode=blended&tag=firefox-uk-21&sourceid=Mozilla-search",
|
||||
"suggest_url": "https://completion.amazon.co.uk/search/complete",
|
||||
"suggest_url_get_params": "q={searchTerms}&search-alias=aps&mkt=3"
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
},
|
||||
"au": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.com.au",
|
||||
"search_url": "https://www.amazon.com.au/exec/obidos/external-search/",
|
||||
"search_form": "https://www.amazon.com.au/exec/obidos/external-search/",
|
||||
"search_url_get_params": "field-keywords={searchTerms}&ie={inputEncoding}&mode=blended",
|
||||
"suggest_url": "https://completion.amazon.com.au/search/complete",
|
||||
"suggest_url_get_params": "q={searchTerms}&search-alias=aps&mkt=111172"
|
||||
"search_url": "https://www.amazon.com.au/s",
|
||||
"search_form": "https://www.amazon.com.au/",
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
},
|
||||
"nl": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.nl",
|
||||
"search_url": "https://www.amazon.nl/gp/search",
|
||||
"search_url": "https://www.amazon.nl/s",
|
||||
"search_form": "https://www.amazon.nl/",
|
||||
"search_url_get_params": "ie={inputEncoding}&tag=mozillanether-21&index=aps&keywords={searchTerms}",
|
||||
"suggest_url": "https://completion.amazon.nl/search/complete",
|
||||
"suggest_url_get_params": "q={searchTerms}&search-alias=aps&mkt=328451"
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
},
|
||||
"de": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.de",
|
||||
"search_url": "https://www.amazon.de/exec/obidos/external-search/",
|
||||
"search_url": "https://www.amazon.de/s",
|
||||
"search_form": "https://www.amazon.de/",
|
||||
"search_url_get_params": "field-keywords={searchTerms}&ie={inputEncoding}&mode=blended&tag=firefox-de-21&sourceid=Mozilla-search",
|
||||
"suggest_url": "https://completion.amazon.de/search/complete",
|
||||
"suggest_url_get_params": "q={searchTerms}&search-alias=aps&mkt=4"
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
},
|
||||
"jp": {
|
||||
"keyword": "@amazon",
|
||||
"name": "Amazon.co.jp",
|
||||
"search_url": "https://www.amazon.co.jp/exec/obidos/external-search/",
|
||||
"search_form": "https://www.amazon.co.jp/",
|
||||
"search_url_get_params": "field-keywords={searchTerms}&mode=blended&tag=mozillajapan-fx-22&sourceid=Mozilla-search",
|
||||
"suggest_url": "https://completion.amazon.co.jp/search/complete",
|
||||
"suggest_url_get_params": "q={searchTerms}&search-alias=aps&mkt=6"
|
||||
"search_url_get_params": "field-keywords={searchTerms}&mode=blended&tag=mozillajapan-fx-22&sourceid=Mozilla-search"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -2098,16 +2074,16 @@
|
|||
"default": {
|
||||
"keyword": "@amazon",
|
||||
"name": "亚马逊",
|
||||
"search_url": "https://www.amazon.cn/mn/searchApp",
|
||||
"search_url": "https://www.amazon.cn/s",
|
||||
"search_form": "https://www.amazon.cn/",
|
||||
"search_url_get_params": "ix=sunray&pageletid=headsearch&searchType=&Go.x=0&Go.y=0&bestSaleNum=0&keywords={searchTerms}"
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
},
|
||||
"mozillaonline": {
|
||||
"keyword": "@amazon",
|
||||
"name": "亚马逊",
|
||||
"search_url": "https://www.amazon.cn/gp/search",
|
||||
"search_url": "https://www.amazon.cn/gp/s",
|
||||
"search_form": "https://www.amazon.cn/",
|
||||
"search_url_get_params": "ie=UTF8&camp=536&creative=3200&index=aps&linkCode=ur2&tag=mozilla&keywords={searchTerms}"
|
||||
"search_url_get_params": "k={searchTerms}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ export class AppProvidedSearchEngine extends SearchEngine {
|
|||
id,
|
||||
});
|
||||
|
||||
this._extensionID = extensionId;
|
||||
this._locale = details?.locale;
|
||||
|
||||
if (details) {
|
||||
if (!details.config.webExtension.id) {
|
||||
throw Components.Exception(
|
||||
|
|
@ -58,6 +61,8 @@ export class AppProvidedSearchEngine extends SearchEngine {
|
|||
* The search engine configuration for application provided engines.
|
||||
*/
|
||||
update({ locale, configuration } = {}) {
|
||||
this._urls = [];
|
||||
this._iconMapObj = null;
|
||||
this.#init(locale, configuration);
|
||||
lazy.SearchUtils.notifyAction(this, lazy.SearchUtils.MODIFIED_TYPE.CHANGED);
|
||||
}
|
||||
|
|
@ -68,18 +73,33 @@ export class AppProvidedSearchEngine extends SearchEngine {
|
|||
*
|
||||
* @param {object} options
|
||||
* The options object.
|
||||
* @param {object} [options.config]
|
||||
* @param {object} [options.configuration]
|
||||
* The search engine configuration for application provided engines.
|
||||
* @param {string} [options.locale]
|
||||
* The locale to use for getting details of the search engine.
|
||||
* @returns {boolean}
|
||||
* Returns true if the engine was updated, false otherwise.
|
||||
*/
|
||||
async updateIfNoNameChange({ config, locale }) {
|
||||
if (this.name != config.search_provider.name.trim()) {
|
||||
async updateIfNoNameChange({ configuration, locale }) {
|
||||
let newName;
|
||||
if (locale != "default") {
|
||||
newName = configuration.webExtension.searchProvider[locale].name;
|
||||
} else if (
|
||||
locale == "default" &&
|
||||
configuration.webExtension.default_locale
|
||||
) {
|
||||
newName =
|
||||
configuration.webExtension.searchProvider[
|
||||
configuration.webExtension.default_locale
|
||||
].name;
|
||||
} else {
|
||||
newName = configuration.webExtension.name;
|
||||
}
|
||||
|
||||
if (this.name != newName.trim()) {
|
||||
return false;
|
||||
}
|
||||
this.update(locale, config);
|
||||
this.update({ locale, configuration });
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +131,8 @@ export class AppProvidedSearchEngine extends SearchEngine {
|
|||
|
||||
get isGeneralPurposeEngine() {
|
||||
return !!(
|
||||
this.id && lazy.SearchUtils.GENERAL_SEARCH_ENGINE_IDS.has(this.id)
|
||||
this._extensionID &&
|
||||
lazy.SearchUtils.GENERAL_SEARCH_ENGINE_IDS.has(this._extensionID)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1650,29 +1650,34 @@ export class SearchService {
|
|||
this.#addEngineToStore(engine);
|
||||
}
|
||||
|
||||
if (!lazy.SearchUtils.newSearchConfigEnabled) {
|
||||
lazy.logConsole.debug(
|
||||
"#loadEngines: loading",
|
||||
this.#startupExtensions.size,
|
||||
"engines reported by AddonManager startup"
|
||||
);
|
||||
for (let extension of this.#startupExtensions) {
|
||||
try {
|
||||
await this.#installExtensionEngine(
|
||||
extension,
|
||||
[lazy.SearchUtils.DEFAULT_TAG],
|
||||
true
|
||||
);
|
||||
} catch (ex) {
|
||||
lazy.logConsole.error(
|
||||
`#installExtensionEngine failed for ${extension.id}`,
|
||||
ex
|
||||
);
|
||||
}
|
||||
}
|
||||
this.#startupExtensions.clear();
|
||||
if (
|
||||
this.#startupExtensions.size &&
|
||||
lazy.SearchUtils.newSearchConfigEnabled
|
||||
) {
|
||||
await lazy.AddonManager.readyPromise;
|
||||
}
|
||||
|
||||
lazy.logConsole.debug(
|
||||
"#loadEngines: loading",
|
||||
this.#startupExtensions.size,
|
||||
"engines reported by AddonManager startup"
|
||||
);
|
||||
for (let extension of this.#startupExtensions) {
|
||||
try {
|
||||
await this.#installExtensionEngine(
|
||||
extension,
|
||||
[lazy.SearchUtils.DEFAULT_TAG],
|
||||
true
|
||||
);
|
||||
} catch (ex) {
|
||||
lazy.logConsole.error(
|
||||
`#installExtensionEngine failed for ${extension.id}`,
|
||||
ex
|
||||
);
|
||||
}
|
||||
}
|
||||
this.#startupExtensions.clear();
|
||||
|
||||
this.#loadEnginesFromPolicies();
|
||||
|
||||
this.#loadEnginesFromSettings(settings.engines);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,28 @@
|
|||
"data": [
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine@search.mozilla.org"
|
||||
"id": "engine@search.mozilla.org",
|
||||
"name": "Test search engine",
|
||||
"search_url": "https://www.google.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "contextmenu",
|
||||
"value": "rcs"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "keyword",
|
||||
"value": "fflb"
|
||||
}
|
||||
],
|
||||
"suggest_url": "https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}"
|
||||
},
|
||||
"appliesTo": [
|
||||
{
|
||||
|
|
@ -13,7 +34,33 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine-rel-searchform-purpose@search.mozilla.org"
|
||||
"id": "engine-rel-searchform-purpose@search.mozilla.org",
|
||||
"name": "engine-rel-searchform-purpose",
|
||||
"search_url": "https://www.google.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "contextmenu",
|
||||
"value": "rcs"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "keyword",
|
||||
"value": "fflb"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "searchbar",
|
||||
"value": "sb"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderHint": 1000,
|
||||
"appliesTo": [
|
||||
|
|
@ -26,7 +73,15 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine-chromeicon@search.mozilla.org"
|
||||
"id": "engine-chromeicon@search.mozilla.org",
|
||||
"name": "engine-chromeicon",
|
||||
"search_url": "https://www.google.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderHint": 1000,
|
||||
"appliesTo": [
|
||||
|
|
@ -43,7 +98,19 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine-resourceicon@search.mozilla.org"
|
||||
"id": "engine-resourceicon@search.mozilla.org",
|
||||
"name": "engine-resourceicon",
|
||||
"search_url": "https://www.google.com/search",
|
||||
"search_provider": {
|
||||
"en": {
|
||||
"name": "engine-resourceicon",
|
||||
"search_url": "https://www.google.com/search"
|
||||
},
|
||||
"gd": {
|
||||
"name": "engine-resourceicon-gd",
|
||||
"search_url": "https://www.google.com/search"
|
||||
}
|
||||
}
|
||||
},
|
||||
"appliesTo": [
|
||||
{
|
||||
|
|
@ -57,7 +124,28 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine-reordered@search.mozilla.org"
|
||||
"id": "engine-reordered@search.mozilla.org",
|
||||
"name": "Test search engine (Reordered)",
|
||||
"search_url": "https://www.google.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "contextmenu",
|
||||
"value": "rcs"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "keyword",
|
||||
"value": "fflb"
|
||||
}
|
||||
],
|
||||
"suggest_url": "https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}"
|
||||
},
|
||||
"appliesTo": [
|
||||
{
|
||||
|
|
@ -69,7 +157,25 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine-pref@search.mozilla.org"
|
||||
"id": "engine-pref@search.mozilla.org",
|
||||
"name": "engine-pref",
|
||||
"search_url": "https://www.google.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
},
|
||||
{
|
||||
"name": "code",
|
||||
"condition": "pref",
|
||||
"pref": "code"
|
||||
},
|
||||
{
|
||||
"name": "test",
|
||||
"condition": "pref",
|
||||
"pref": "test"
|
||||
}
|
||||
]
|
||||
},
|
||||
"appliesTo": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,28 @@
|
|||
"data": [
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine@search.mozilla.org"
|
||||
"id": "engine@search.mozilla.org",
|
||||
"name": "Test search engine",
|
||||
"search_url": "https://www.google.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "contextmenu",
|
||||
"value": "rcs"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "keyword",
|
||||
"value": "fflb"
|
||||
}
|
||||
],
|
||||
"suggest_url": "https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}"
|
||||
},
|
||||
"orderHint": 10000,
|
||||
"appliesTo": [
|
||||
|
|
@ -15,7 +36,25 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine-pref@search.mozilla.org"
|
||||
"id": "engine-pref@search.mozilla.org",
|
||||
"name": "engine-pref",
|
||||
"search_url": "https://www.google.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
},
|
||||
{
|
||||
"name": "code",
|
||||
"condition": "pref",
|
||||
"pref": "code"
|
||||
},
|
||||
{
|
||||
"name": "test",
|
||||
"condition": "pref",
|
||||
"pref": "test"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderHint": 7000,
|
||||
"appliesTo": [
|
||||
|
|
@ -29,7 +68,33 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine-rel-searchform-purpose@search.mozilla.org"
|
||||
"id": "engine-rel-searchform-purpose@search.mozilla.org",
|
||||
"name": "engine-rel-searchform-purpose",
|
||||
"search_url": "https://www.google.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "contextmenu",
|
||||
"value": "rcs"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "keyword",
|
||||
"value": "fflb"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "searchbar",
|
||||
"value": "sb"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderHint": 6000,
|
||||
"appliesTo": [
|
||||
|
|
@ -46,7 +111,15 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine-chromeicon@search.mozilla.org"
|
||||
"id": "engine-chromeicon@search.mozilla.org",
|
||||
"name": "engine-chromeicon",
|
||||
"search_url": "https://www.google.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderHint": 8000,
|
||||
"appliesTo": [
|
||||
|
|
@ -63,7 +136,18 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine-resourceicon@search.mozilla.org"
|
||||
"id": "engine-resourceicon@search.mozilla.org",
|
||||
"default_locale": "en",
|
||||
"searchProvider": {
|
||||
"en": {
|
||||
"name": "engine-resourceicon",
|
||||
"search_url": "https://www.google.com/search"
|
||||
},
|
||||
"gd": {
|
||||
"name": "engine-resourceicon-gd",
|
||||
"search_url": "https://www.google.com/search"
|
||||
}
|
||||
}
|
||||
},
|
||||
"orderHint": 9000,
|
||||
"appliesTo": [
|
||||
|
|
@ -83,7 +167,28 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine-reordered@search.mozilla.org"
|
||||
"id": "engine-reordered@search.mozilla.org",
|
||||
"name": "Test search engine (Reordered)",
|
||||
"search_url": "https://www.google.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "contextmenu",
|
||||
"value": "rcs"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"condition": "purpose",
|
||||
"purpose": "keyword",
|
||||
"value": "fflb"
|
||||
}
|
||||
],
|
||||
"suggest_url": "https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}"
|
||||
},
|
||||
"orderHint": 5000,
|
||||
"appliesTo": [
|
||||
|
|
|
|||
|
|
@ -2,7 +2,15 @@
|
|||
"data": [
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine1@search.mozilla.org"
|
||||
"id": "engine1@search.mozilla.org",
|
||||
"name": "engine1",
|
||||
"search_url": "https://1.example.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderHint": 10000,
|
||||
"appliesTo": [
|
||||
|
|
@ -15,7 +23,15 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "engine2@search.mozilla.org"
|
||||
"id": "engine2@search.mozilla.org",
|
||||
"name": "engine2",
|
||||
"search_url": "https://2.example.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderHint": 7000,
|
||||
"appliesTo": [
|
||||
|
|
@ -32,7 +48,15 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "exp2@search.mozilla.org"
|
||||
"id": "exp2@search.mozilla.org",
|
||||
"name": "exp2",
|
||||
"search_url": "https://2.example.com/searchexp",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderHint": 5000,
|
||||
"appliesTo": [
|
||||
|
|
@ -45,7 +69,15 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "exp3@search.mozilla.org"
|
||||
"id": "exp3@search.mozilla.org",
|
||||
"name": "exp3",
|
||||
"search_url": "https://3.example.com/searchexp",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"orderHint": 20000,
|
||||
"appliesTo": [
|
||||
|
|
|
|||
|
|
@ -2,7 +2,12 @@
|
|||
"data": [
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "get@search.mozilla.org"
|
||||
"id": "get@search.mozilla.org",
|
||||
"name": "Get Engine",
|
||||
"search_url": "https://example.com",
|
||||
"search_url_get_params": "webExtension=1&search={searchTerms}",
|
||||
"suggest_url": "https://example.com",
|
||||
"suggest_url_get_params": "webExtension=1&suggest={searchTerms}"
|
||||
},
|
||||
"params": {
|
||||
"searchUrlGetParams": [
|
||||
|
|
@ -23,7 +28,12 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "post@search.mozilla.org"
|
||||
"id": "post@search.mozilla.org",
|
||||
"name": "Post Engine",
|
||||
"search_url": "https://example.com",
|
||||
"search_url_post_params": "webExtension=1&search={searchTerms}",
|
||||
"suggest_url": "https://example.com",
|
||||
"suggest_url_post_params": "webExtension=1&suggest={searchTerms}"
|
||||
},
|
||||
"params": {
|
||||
"searchUrlPostParams": [
|
||||
|
|
|
|||
|
|
@ -2,7 +2,20 @@
|
|||
"data": [
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "basic@search.mozilla.org"
|
||||
"id": "basic@search.mozilla.org",
|
||||
"name": "basic",
|
||||
"search_url": "https://ar.wikipedia.org/wiki/%D8%AE%D8%A7%D8%B5:%D8%A8%D8%AD%D8%AB",
|
||||
"params": [
|
||||
{
|
||||
"name": "search",
|
||||
"value": "{searchTerms}"
|
||||
},
|
||||
{
|
||||
"name": "sourceId",
|
||||
"value": "Mozilla-search"
|
||||
}
|
||||
],
|
||||
"suggest_url": "https://ar.wikipedia.org/w/api.php?action=opensearch&search={searchTerms}"
|
||||
},
|
||||
"telemetryId": "telemetry",
|
||||
"appliesTo": [
|
||||
|
|
@ -14,7 +27,20 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "simple@search.mozilla.org"
|
||||
"id": "simple@search.mozilla.org",
|
||||
"name": "Simple Engine",
|
||||
"search_url": "https://example.com",
|
||||
"params": [
|
||||
{
|
||||
"name": "sourceId",
|
||||
"value": "Mozilla-search"
|
||||
},
|
||||
{
|
||||
"name": "search",
|
||||
"value": "{searchTerms}"
|
||||
}
|
||||
],
|
||||
"suggest_url": "https://example.com?search={searchTerms}"
|
||||
},
|
||||
"appliesTo": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,46 @@
|
|||
"data": [
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "plainengine@search.mozilla.org"
|
||||
"id": "plainengine@search.mozilla.org",
|
||||
"name": "Plain",
|
||||
"search_url": "https://duckduckgo.com/",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
},
|
||||
{
|
||||
"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/q={searchTerms}&type=list"
|
||||
},
|
||||
"orderHint": 10000,
|
||||
"sendAttributionRequest": true,
|
||||
|
|
@ -15,7 +54,28 @@
|
|||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "special-engine@search.mozilla.org"
|
||||
"id": "special-engine@search.mozilla.org",
|
||||
"name": "Special",
|
||||
"search_url": "https://www.google.com/search",
|
||||
"params": [
|
||||
{
|
||||
"name": "q",
|
||||
"value": "{searchTerms}"
|
||||
},
|
||||
{
|
||||
"name": "client",
|
||||
"condition": "purpose",
|
||||
"purpose": "keyword",
|
||||
"value": "firefox-b-1-ab"
|
||||
},
|
||||
{
|
||||
"name": "client",
|
||||
"condition": "purpose",
|
||||
"purpose": "searchbar",
|
||||
"value": "firefox-b-1"
|
||||
}
|
||||
],
|
||||
"suggest_url": "https://www.google.com/complete/search?client=firefox&q={searchTerms}"
|
||||
},
|
||||
"orderHint": 7000,
|
||||
"appliesTo": [
|
||||
|
|
@ -32,25 +92,37 @@
|
|||
{
|
||||
"webExtension": {
|
||||
"id": "multilocale@search.mozilla.org",
|
||||
"locales": ["an"]
|
||||
"default_locale": "af",
|
||||
"searchProvider": {
|
||||
"an": {
|
||||
"name": "Multilocale AN",
|
||||
"description": "A enciclopedia Libre",
|
||||
"search_url": "https://an.wikipedia.org/wiki/Especial:Mirar",
|
||||
"suggest_url": "https://an.wikipedia.org/w/api.php"
|
||||
},
|
||||
"af": {
|
||||
"name": "Multilocale AF",
|
||||
"description": "Wikipedia, die vrye ensiklopedie",
|
||||
"search_url": "https://af.wikipedia.org/wiki/Spesiaal:Soek",
|
||||
"suggest_url": "https://af.wikipedia.org/w/api.php"
|
||||
}
|
||||
}
|
||||
},
|
||||
"orderHint": 6000,
|
||||
"appliesTo": [
|
||||
{
|
||||
"included": { "regions": ["an"] },
|
||||
"webExtension": {
|
||||
"locales": ["an"]
|
||||
},
|
||||
"default": "yes"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"webExtension": {
|
||||
"id": "multilocale@search.mozilla.org",
|
||||
"locales": ["af", "an"]
|
||||
},
|
||||
"orderHint": 6500,
|
||||
"appliesTo": [
|
||||
},
|
||||
{
|
||||
"included": { "regions": ["af"] }
|
||||
"included": { "regions": ["af"] },
|
||||
"webExtension": {
|
||||
"locales": ["af", "an"]
|
||||
},
|
||||
"orderHint": 6500
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,14 +56,18 @@ add_task(async function test_defaultPrivateEngine() {
|
|||
normal: {
|
||||
engineId: "engine",
|
||||
displayName: "Test search engine",
|
||||
loadPath: "[addon]engine@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]engine@search.mozilla.org"
|
||||
: "[addon]engine@search.mozilla.org",
|
||||
submissionUrl: "https://www.google.com/search?q=",
|
||||
verified: "default",
|
||||
},
|
||||
private: {
|
||||
engineId: "engine-pref",
|
||||
displayName: "engine-pref",
|
||||
loadPath: "[addon]engine-pref@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]engine-pref@search.mozilla.org"
|
||||
: "[addon]engine-pref@search.mozilla.org",
|
||||
submissionUrl: "https://www.google.com/search?q=",
|
||||
verified: "default",
|
||||
},
|
||||
|
|
@ -92,14 +96,18 @@ add_task(async function test_defaultPrivateEngine() {
|
|||
normal: {
|
||||
engineId: "engine",
|
||||
displayName: "Test search engine",
|
||||
loadPath: "[addon]engine@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]engine@search.mozilla.org"
|
||||
: "[addon]engine@search.mozilla.org",
|
||||
submissionUrl: "https://www.google.com/search?q=",
|
||||
verified: "default",
|
||||
},
|
||||
private: {
|
||||
engineId: "engine-rel-searchform-purpose",
|
||||
displayName: "engine-rel-searchform-purpose",
|
||||
loadPath: "[addon]engine-rel-searchform-purpose@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]engine-rel-searchform-purpose@search.mozilla.org"
|
||||
: "[addon]engine-rel-searchform-purpose@search.mozilla.org",
|
||||
submissionUrl: "https://www.google.com/search?q=&channel=sb",
|
||||
verified: "default",
|
||||
},
|
||||
|
|
@ -139,14 +147,18 @@ add_task(async function test_defaultPrivateEngine() {
|
|||
normal: {
|
||||
engineId: "engine",
|
||||
displayName: "Test search engine",
|
||||
loadPath: "[addon]engine@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]engine@search.mozilla.org"
|
||||
: "[addon]engine@search.mozilla.org",
|
||||
submissionUrl: "https://www.google.com/search?q=",
|
||||
verified: "default",
|
||||
},
|
||||
private: {
|
||||
engineId: "engine-chromeicon",
|
||||
displayName: "engine-chromeicon",
|
||||
loadPath: "[addon]engine-chromeicon@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]engine-chromeicon@search.mozilla.org"
|
||||
: "[addon]engine-chromeicon@search.mozilla.org",
|
||||
submissionUrl: "https://www.google.com/search?q=",
|
||||
verified: "default",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -15,6 +15,28 @@ const CONFIG = [
|
|||
{
|
||||
webExtension: {
|
||||
id: "engine@search.mozilla.org",
|
||||
name: "Test search engine",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "contextmenu",
|
||||
value: "rcs",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "keyword",
|
||||
value: "fflb",
|
||||
},
|
||||
],
|
||||
suggest_url:
|
||||
"https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}",
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ const TEST_CONFIG = [
|
|||
const engineSelector = new SearchEngineSelectorOld();
|
||||
|
||||
add_setup(async function () {
|
||||
const settings = await RemoteSettings(SearchUtils.SETTINGS_KEY);
|
||||
const settings = await RemoteSettings(SearchUtils.OLD_SETTINGS_KEY);
|
||||
sinon.stub(settings, "get").returns(TEST_CONFIG);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ const expectedDefaultEngine = {
|
|||
const engineSelector = new SearchEngineSelectorOld();
|
||||
|
||||
add_task(async function test_engine_selector_channels() {
|
||||
const settings = await RemoteSettings(SearchUtils.SETTINGS_KEY);
|
||||
const settings = await RemoteSettings(SearchUtils.OLD_SETTINGS_KEY);
|
||||
sinon.stub(settings, "get").returns(TEST_CONFIG);
|
||||
|
||||
for (let [channel, expected] of Object.entries(expectedEnginesPerChannel)) {
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ const CONFIG = [
|
|||
|
||||
const engineSelector = new SearchEngineSelectorOld();
|
||||
add_setup(async function () {
|
||||
Services.prefs.setBoolPref("browser.search.newSearchConfig.enabled", false);
|
||||
await SearchTestUtils.useTestEngines("data", null, CONFIG);
|
||||
await AddonTestUtils.promiseStartupManager();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ const tests = [
|
|||
];
|
||||
|
||||
add_setup(async function () {
|
||||
Services.prefs.setBoolPref("browser.search.newSearchConfig.enabled", false);
|
||||
await SearchTestUtils.useTestEngines("data", null, CONFIG);
|
||||
await AddonTestUtils.promiseStartupManager();
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ function getConfigData(testInput) {
|
|||
const engineSelector = new SearchEngineSelectorOld();
|
||||
|
||||
add_task(async function () {
|
||||
const settings = await RemoteSettings(SearchUtils.SETTINGS_KEY);
|
||||
const settings = await RemoteSettings(SearchUtils.OLD_SETTINGS_KEY);
|
||||
const getStub = sinon.stub(settings, "get");
|
||||
|
||||
let i = 0;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ const TEST_CONFIG = [
|
|||
const engineSelector = new SearchEngineSelectorOld();
|
||||
|
||||
add_setup(async function () {
|
||||
const settings = await RemoteSettings(SearchUtils.SETTINGS_KEY);
|
||||
const settings = await RemoteSettings(SearchUtils.OLD_SETTINGS_KEY);
|
||||
sinon.stub(settings, "get").returns(TEST_CONFIG);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,9 @@ const TEST_CONFIG = [
|
|||
let getStub;
|
||||
|
||||
add_setup(async function () {
|
||||
const searchConfigSettings = await RemoteSettings(SearchUtils.SETTINGS_KEY);
|
||||
const searchConfigSettings = await RemoteSettings(
|
||||
SearchUtils.OLD_SETTINGS_KEY
|
||||
);
|
||||
getStub = sinon.stub(searchConfigSettings, "get");
|
||||
|
||||
// We expect this error from remove settings as we're invalidating the
|
||||
|
|
@ -187,7 +189,7 @@ add_task(async function test_selector_config_update() {
|
|||
|
||||
getStub.resetHistory();
|
||||
getStub.onFirstCall().returns(NEW_DATA);
|
||||
await RemoteSettings(SearchUtils.SETTINGS_KEY).emit("sync", {
|
||||
await RemoteSettings(SearchUtils.OLD_SETTINGS_KEY).emit("sync", {
|
||||
data: {
|
||||
current: NEW_DATA,
|
||||
},
|
||||
|
|
@ -210,7 +212,7 @@ add_task(async function test_selector_config_update() {
|
|||
add_task(async function test_selector_db_modification() {
|
||||
const engineSelector = new SearchEngineSelectorOld();
|
||||
// Fill the database with some values that we can use to test that it is cleared.
|
||||
const db = RemoteSettings(SearchUtils.SETTINGS_KEY).db;
|
||||
const db = RemoteSettings(SearchUtils.OLD_SETTINGS_KEY).db;
|
||||
await db.importChanges(
|
||||
{},
|
||||
Date.now(),
|
||||
|
|
@ -256,7 +258,7 @@ add_task(async function test_selector_db_modification() {
|
|||
add_task(async function test_selector_db_modification_never_succeeds() {
|
||||
const engineSelector = new SearchEngineSelectorOld();
|
||||
// Fill the database with some values that we can use to test that it is cleared.
|
||||
const db = RemoteSettings(SearchUtils.SETTINGS_KEY).db;
|
||||
const db = RemoteSettings(SearchUtils.OLD_SETTINGS_KEY).db;
|
||||
await db.importChanges(
|
||||
{},
|
||||
Date.now(),
|
||||
|
|
@ -300,7 +302,7 @@ add_task(async function test_empty_results() {
|
|||
// Check that returning an empty result re-tries.
|
||||
const engineSelector = new SearchEngineSelectorOld();
|
||||
// Fill the database with some values that we can use to test that it is cleared.
|
||||
const db = RemoteSettings(SearchUtils.SETTINGS_KEY).db;
|
||||
const db = RemoteSettings(SearchUtils.OLD_SETTINGS_KEY).db;
|
||||
await db.importChanges(
|
||||
{},
|
||||
Date.now(),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,28 @@ const CONFIG = [
|
|||
{
|
||||
webExtension: {
|
||||
id: "engine@search.mozilla.org",
|
||||
name: "Test search engine",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "contextmenu",
|
||||
value: "rcs",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "keyword",
|
||||
value: "fflb",
|
||||
},
|
||||
],
|
||||
suggest_url:
|
||||
"https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}",
|
||||
},
|
||||
orderHint: 30,
|
||||
appliesTo: [
|
||||
|
|
@ -24,6 +46,24 @@ const CONFIG = [
|
|||
{
|
||||
webExtension: {
|
||||
id: "engine-pref@search.mozilla.org",
|
||||
name: "engine-pref",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "code",
|
||||
condition: "pref",
|
||||
pref: "code",
|
||||
},
|
||||
{
|
||||
name: "test",
|
||||
condition: "pref",
|
||||
pref: "test",
|
||||
},
|
||||
],
|
||||
},
|
||||
orderHint: 20,
|
||||
appliesTo: [
|
||||
|
|
|
|||
|
|
@ -5,11 +5,46 @@
|
|||
|
||||
const TEST_CONFIG = [
|
||||
{
|
||||
webExtension: { id: "plainengine@search.mozilla.org" },
|
||||
webExtension: {
|
||||
id: "plainengine@search.mozilla.org",
|
||||
name: "Plain",
|
||||
search_url: "https://duckduckgo.com/",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
],
|
||||
suggest_url: "https://ac.duckduckgo.com/ac/q={searchTerms}&type=list",
|
||||
},
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
},
|
||||
{
|
||||
webExtension: { id: "special-engine@search.mozilla.org" },
|
||||
webExtension: {
|
||||
id: "special-engine@search.mozilla.org",
|
||||
name: "Special",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "client",
|
||||
condition: "purpose",
|
||||
purpose: "keyword",
|
||||
value: "firefox-b-1-ab",
|
||||
},
|
||||
{
|
||||
name: "client",
|
||||
condition: "purpose",
|
||||
purpose: "searchbar",
|
||||
value: "firefox-b-1",
|
||||
},
|
||||
],
|
||||
suggest_url:
|
||||
"https://www.google.com/complete/search?client=firefox&q={searchTerms}",
|
||||
},
|
||||
appliesTo: [{ default: "yes", included: { regions: ["FR"] } }],
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -10,6 +10,28 @@ const GOOD_CONFIG = [
|
|||
{
|
||||
webExtension: {
|
||||
id: "engine@search.mozilla.org",
|
||||
name: "Test search engine",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "contextmenu",
|
||||
value: "rcs",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "keyword",
|
||||
value: "fflb",
|
||||
},
|
||||
],
|
||||
suggest_url:
|
||||
"https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}",
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -375,7 +375,9 @@ for (const test of tests) {
|
|||
{
|
||||
defaultSearchEngine: "simple-addon",
|
||||
defaultSearchEngineData: {
|
||||
loadPath: "[addon]simple@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]simple@search.mozilla.org"
|
||||
: "[addon]simple@search.mozilla.org",
|
||||
name: "Simple Engine",
|
||||
origin: "default",
|
||||
submissionURL: test.expected.searchUrl.replace("{searchTerms}", ""),
|
||||
|
|
|
|||
|
|
@ -8,6 +8,28 @@ const CONFIG = [
|
|||
// Engine initially default, but the defaults will be changed to engine-pref.
|
||||
webExtension: {
|
||||
id: "engine@search.mozilla.org",
|
||||
name: "Test search engine",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "contextmenu",
|
||||
value: "rcs",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "keyword",
|
||||
value: "fflb",
|
||||
},
|
||||
],
|
||||
suggest_url:
|
||||
"https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}",
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
@ -26,6 +48,24 @@ const CONFIG = [
|
|||
// This will become defaults when region is changed to FR.
|
||||
webExtension: {
|
||||
id: "engine-pref@search.mozilla.org",
|
||||
name: "engine-pref",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "code",
|
||||
condition: "pref",
|
||||
pref: "code",
|
||||
},
|
||||
{
|
||||
name: "test",
|
||||
condition: "pref",
|
||||
pref: "test",
|
||||
},
|
||||
],
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
@ -42,6 +82,14 @@ const CONFIG = [
|
|||
// This engine will get an update when region is changed to FR.
|
||||
webExtension: {
|
||||
id: "engine-chromeicon@search.mozilla.org",
|
||||
name: "engine-chromeicon",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
],
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
@ -60,6 +108,32 @@ const CONFIG = [
|
|||
// This engine will be removed when the region is changed to FR.
|
||||
webExtension: {
|
||||
id: "engine-rel-searchform-purpose@search.mozilla.org",
|
||||
name: "engine-rel-searchform-purpose",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "contextmenu",
|
||||
value: "rcs",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "keyword",
|
||||
value: "fflb",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "searchbar",
|
||||
value: "sb",
|
||||
},
|
||||
],
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
@ -72,6 +146,28 @@ const CONFIG = [
|
|||
// This engine will be added when the region is changed to FR.
|
||||
webExtension: {
|
||||
id: "engine-reordered@search.mozilla.org",
|
||||
name: "Test search engine (Reordered)",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "contextmenu",
|
||||
value: "rcs",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "keyword",
|
||||
value: "fflb",
|
||||
},
|
||||
],
|
||||
suggest_url:
|
||||
"https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}",
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
@ -83,6 +179,18 @@ const CONFIG = [
|
|||
// This engine will be re-ordered and have a changed name, when moved to FR.
|
||||
webExtension: {
|
||||
id: "engine-resourceicon@search.mozilla.org",
|
||||
name: "engine-resourceicon",
|
||||
search_url: "https://www.google.com/search",
|
||||
searchProvider: {
|
||||
en: {
|
||||
name: "engine-resourceicon",
|
||||
search_url: "https://www.google.com/search",
|
||||
},
|
||||
gd: {
|
||||
name: "engine-resourceicon-gd",
|
||||
search_url: "https://www.google.com/search",
|
||||
},
|
||||
},
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
@ -102,6 +210,18 @@ const CONFIG = [
|
|||
// This engine has the same name, but still should be replaced correctly.
|
||||
webExtension: {
|
||||
id: "engine-same-name@search.mozilla.org",
|
||||
name: "engine-same-name",
|
||||
search_url: "https://www.google.com/search?q={searchTerms}",
|
||||
searchProvider: {
|
||||
en: {
|
||||
name: "engine-same-name",
|
||||
search_url: "https://www.google.com/search?q={searchTerms}",
|
||||
},
|
||||
gd: {
|
||||
name: "engine-same-name",
|
||||
search_url: "https://www.example.com/search?q={searchTerms}",
|
||||
},
|
||||
},
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,6 +8,28 @@ const CONFIG = [
|
|||
// Just a basic engine that won't be changed.
|
||||
webExtension: {
|
||||
id: "engine@search.mozilla.org",
|
||||
name: "Test search engine",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "contextmenu",
|
||||
value: "rcs",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "keyword",
|
||||
value: "fflb",
|
||||
},
|
||||
],
|
||||
suggest_url:
|
||||
"https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}",
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
@ -20,6 +42,17 @@ const CONFIG = [
|
|||
// This engine will have the locale swapped when the experiment is set.
|
||||
webExtension: {
|
||||
id: "engine-same-name@search.mozilla.org",
|
||||
default_locale: "en",
|
||||
searchProvider: {
|
||||
en: {
|
||||
name: "engine-same-name",
|
||||
search_url: "https://www.google.com/search?q={searchTerms}",
|
||||
},
|
||||
gd: {
|
||||
name: "engine-same-name",
|
||||
search_url: "https://www.example.com/search?q={searchTerms}",
|
||||
},
|
||||
},
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,28 @@ const CONFIG = [
|
|||
{
|
||||
webExtension: {
|
||||
id: "engine@search.mozilla.org",
|
||||
name: "Test search engine",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "contextmenu",
|
||||
value: "rcs",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "keyword",
|
||||
value: "fflb",
|
||||
},
|
||||
],
|
||||
suggest_url:
|
||||
"https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}",
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
@ -23,6 +45,17 @@ const CONFIG = [
|
|||
{
|
||||
webExtension: {
|
||||
id: "engine-diff-name@search.mozilla.org",
|
||||
default_locale: "en",
|
||||
searchProvider: {
|
||||
en: {
|
||||
name: "engine-diff-name-en",
|
||||
search_url: "https://en.wikipedia.com/search",
|
||||
},
|
||||
gd: {
|
||||
name: "engine-diff-name-gd",
|
||||
search_url: "https://gd.wikipedia.com/search",
|
||||
},
|
||||
},
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ const CONFIG = [
|
|||
// Engine initially default, but the defaults will be changed to engine-pref.
|
||||
webExtension: {
|
||||
id: "engine@search.mozilla.org",
|
||||
name: "Test search engine",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
],
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
@ -26,6 +34,14 @@ const CONFIG = [
|
|||
// This will become defaults when region is changed to FR.
|
||||
webExtension: {
|
||||
id: "engine-pref@search.mozilla.org",
|
||||
name: "engine-pref",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
],
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
@ -39,22 +55,9 @@ const CONFIG = [
|
|||
},
|
||||
];
|
||||
|
||||
const CONFIG_UPDATED = [
|
||||
{
|
||||
webExtension: {
|
||||
id: "engine-pref@search.mozilla.org",
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
included: { everywhere: true },
|
||||
},
|
||||
{
|
||||
included: { regions: ["FR"] },
|
||||
default: "yes",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
const CONFIG_UPDATED = CONFIG.filter(r =>
|
||||
r.webExtension.id.startsWith("engine-pref")
|
||||
);
|
||||
|
||||
let stub;
|
||||
let settingsFilePath;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,14 @@
|
|||
|
||||
const TEST_CONFIG = [
|
||||
{
|
||||
webExtension: { id: "get@search.mozilla.org" },
|
||||
webExtension: {
|
||||
id: "get@search.mozilla.org",
|
||||
name: "Get Engine",
|
||||
search_url: "https://example.com",
|
||||
search_url_get_params: "webExtension=1&search={searchTerms}",
|
||||
suggest_url: "https://example.com",
|
||||
suggest_url_get_params: "webExtension=1&suggest={searchTerms}",
|
||||
},
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
suggestExtraParams: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,6 +18,53 @@ add_setup(async function () {
|
|||
{
|
||||
webExtension: {
|
||||
id: "engine-purposes@search.mozilla.org",
|
||||
name: "Test Engine With Purposes",
|
||||
search_url: "https://www.example.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "form",
|
||||
condition: "purpose",
|
||||
purpose: "keyword",
|
||||
value: "MOZKEYWORD",
|
||||
},
|
||||
{
|
||||
name: "form",
|
||||
condition: "purpose",
|
||||
purpose: "contextmenu",
|
||||
value: "MOZCONTEXT",
|
||||
},
|
||||
{
|
||||
name: "form",
|
||||
condition: "purpose",
|
||||
purpose: "newtab",
|
||||
value: "MOZNEWTAB",
|
||||
},
|
||||
{
|
||||
name: "form",
|
||||
condition: "purpose",
|
||||
purpose: "searchbar",
|
||||
value: "MOZSEARCHBAR",
|
||||
},
|
||||
{
|
||||
name: "form",
|
||||
condition: "purpose",
|
||||
purpose: "homepage",
|
||||
value: "MOZHOMEPAGE",
|
||||
},
|
||||
{
|
||||
name: "pc",
|
||||
value: "FIREFOX",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "pref",
|
||||
pref: "testChannelEnabled",
|
||||
},
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
],
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,21 +5,38 @@
|
|||
|
||||
const CONFIG_DEFAULT = [
|
||||
{
|
||||
webExtension: { id: "plainengine@search.mozilla.org" },
|
||||
webExtension: {
|
||||
id: "plainengine@search.mozilla.org",
|
||||
name: "Plain",
|
||||
search_url: "https://duckduckgo.com/",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
],
|
||||
},
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
},
|
||||
{
|
||||
webExtension: { id: "special-engine@search.mozilla.org" },
|
||||
webExtension: {
|
||||
id: "special-engine@search.mozilla.org",
|
||||
name: "Special",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
],
|
||||
},
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
},
|
||||
];
|
||||
|
||||
const CONFIG_UPDATED = [
|
||||
{
|
||||
webExtension: { id: "plainengine@search.mozilla.org" },
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
},
|
||||
];
|
||||
const CONFIG_UPDATED = CONFIG_DEFAULT.filter(r =>
|
||||
r.webExtension.id.startsWith("plainengine")
|
||||
);
|
||||
|
||||
async function startup() {
|
||||
let settingsFileWritten = promiseAfterSettings();
|
||||
|
|
|
|||
|
|
@ -5,13 +5,34 @@
|
|||
|
||||
const CONFIG = [
|
||||
{
|
||||
webExtension: { id: "engine@search.mozilla.org" },
|
||||
webExtension: {
|
||||
id: "engine@search.mozilla.org",
|
||||
name: "Test search engine",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
],
|
||||
},
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
},
|
||||
{
|
||||
// This engine has the same name, but still should be replaced correctly.
|
||||
webExtension: {
|
||||
id: "engine-same-name@search.mozilla.org",
|
||||
default_locale: "en",
|
||||
searchProvider: {
|
||||
en: {
|
||||
name: "engine-same-name",
|
||||
search_url: "https://www.google.com/search?q={searchTerms}",
|
||||
},
|
||||
gd: {
|
||||
name: "engine-same-name",
|
||||
search_url: "https://www.example.com/search?q={searchTerms}",
|
||||
},
|
||||
},
|
||||
},
|
||||
appliesTo: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,24 +16,101 @@ ChromeUtils.defineESModuleGetters(this, {
|
|||
|
||||
const BASE_CONFIG = [
|
||||
{
|
||||
webExtension: { id: "engine@search.mozilla.org" },
|
||||
webExtension: {
|
||||
id: "engine@search.mozilla.org",
|
||||
name: "Test search engine",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "contextmenu",
|
||||
value: "rcs",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "keyword",
|
||||
value: "fflb",
|
||||
},
|
||||
],
|
||||
suggest_url:
|
||||
"https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}",
|
||||
},
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
default: "yes",
|
||||
},
|
||||
];
|
||||
const MAIN_CONFIG = [
|
||||
{
|
||||
webExtension: { id: "engine@search.mozilla.org" },
|
||||
webExtension: {
|
||||
id: "engine@search.mozilla.org",
|
||||
name: "Test search engine",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "contextmenu",
|
||||
value: "rcs",
|
||||
},
|
||||
{
|
||||
name: "channel",
|
||||
condition: "purpose",
|
||||
purpose: "keyword",
|
||||
value: "fflb",
|
||||
},
|
||||
],
|
||||
suggest_url:
|
||||
"https://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}",
|
||||
},
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
default: "no",
|
||||
},
|
||||
{
|
||||
webExtension: { id: "engine-chromeicon@search.mozilla.org" },
|
||||
webExtension: {
|
||||
id: "engine-chromeicon@search.mozilla.org",
|
||||
|
||||
name: "engine-chromeicon",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
],
|
||||
},
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
default: "yes-if-no-other",
|
||||
},
|
||||
{
|
||||
webExtension: { id: "engine-fr@search.mozilla.org" },
|
||||
webExtension: {
|
||||
id: "engine-fr@search.mozilla.org",
|
||||
name: "Test search engine (fr)",
|
||||
search_url: "https://www.google.fr/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "ie",
|
||||
value: "iso-8859-1",
|
||||
},
|
||||
{
|
||||
name: "oe",
|
||||
value: "iso-8859-1",
|
||||
},
|
||||
],
|
||||
},
|
||||
appliesTo: [
|
||||
{ included: { everywhere: true } },
|
||||
{
|
||||
|
|
@ -45,7 +122,27 @@ const MAIN_CONFIG = [
|
|||
default: "no",
|
||||
},
|
||||
{
|
||||
webExtension: { id: "engine-pref@search.mozilla.org" },
|
||||
webExtension: {
|
||||
id: "engine-pref@search.mozilla.org",
|
||||
name: "engine-pref",
|
||||
search_url: "https://www.google.com/search",
|
||||
params: [
|
||||
{
|
||||
name: "q",
|
||||
value: "{searchTerms}",
|
||||
},
|
||||
{
|
||||
name: "code",
|
||||
condition: "pref",
|
||||
pref: "code",
|
||||
},
|
||||
{
|
||||
name: "test",
|
||||
condition: "pref",
|
||||
pref: "test",
|
||||
},
|
||||
],
|
||||
},
|
||||
appliesTo: [
|
||||
{ included: { everywhere: true } },
|
||||
{ included: { regions: ["DE"] }, default: "yes" },
|
||||
|
|
@ -53,7 +150,11 @@ const MAIN_CONFIG = [
|
|||
default: "no",
|
||||
},
|
||||
{
|
||||
webExtension: { id: "engine2@search.mozilla.org" },
|
||||
webExtension: {
|
||||
id: "engine2@search.mozilla.org",
|
||||
name: "A second test engine",
|
||||
search_url: "https://duckduckgo.com/?q={searchTerms}",
|
||||
},
|
||||
appliesTo: [
|
||||
{ included: { everywhere: true } },
|
||||
{ included: { everywhere: true }, experiment: "test1", default: "yes" },
|
||||
|
|
@ -65,31 +166,42 @@ const MAIN_CONFIG = [
|
|||
const testSearchEngine = {
|
||||
id: "engine",
|
||||
name: "Test search engine",
|
||||
loadPath: "[addon]engine@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]engine@search.mozilla.org"
|
||||
: "[addon]engine@search.mozilla.org",
|
||||
submissionUrl: "https://www.google.com/search?q=",
|
||||
};
|
||||
const testChromeIconEngine = {
|
||||
id: "engine-chromeicon",
|
||||
name: "engine-chromeicon",
|
||||
loadPath: "[addon]engine-chromeicon@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]engine-chromeicon@search.mozilla.org"
|
||||
: "[addon]engine-chromeicon@search.mozilla.org",
|
||||
|
||||
submissionUrl: "https://www.google.com/search?q=",
|
||||
};
|
||||
const testFrEngine = {
|
||||
id: "engine-fr",
|
||||
name: "Test search engine (fr)",
|
||||
loadPath: "[addon]engine-fr@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]engine-fr@search.mozilla.org"
|
||||
: "[addon]engine-fr@search.mozilla.org",
|
||||
submissionUrl: "https://www.google.fr/search?q=&ie=iso-8859-1&oe=iso-8859-1",
|
||||
};
|
||||
const testPrefEngine = {
|
||||
id: "engine-pref",
|
||||
name: "engine-pref",
|
||||
loadPath: "[addon]engine-pref@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]engine-pref@search.mozilla.org"
|
||||
: "[addon]engine-pref@search.mozilla.org",
|
||||
submissionUrl: "https://www.google.com/search?q=",
|
||||
};
|
||||
const testEngine2 = {
|
||||
id: "engine2",
|
||||
name: "A second test engine",
|
||||
loadPath: "[addon]engine2@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]engine2@search.mozilla.org"
|
||||
: "[addon]engine2@search.mozilla.org",
|
||||
submissionUrl: "https://duckduckgo.com/?q=",
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,7 @@ add_task(async function test_validate_engines() {
|
|||
},
|
||||
},
|
||||
],
|
||||
webExtension: {
|
||||
id: e.webExtension.id,
|
||||
},
|
||||
webExtension: e.webExtension,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -140,113 +140,125 @@ function makeMultiLocaleExtension(version) {
|
|||
};
|
||||
}
|
||||
|
||||
add_setup(async function () {
|
||||
await SearchTestUtils.useTestEngines("test-extensions", null, TEST_CONFIG);
|
||||
await promiseStartupManager();
|
||||
add_setup(
|
||||
{ skip_if: () => SearchUtils.newSearchConfigEnabled },
|
||||
async function () {
|
||||
await SearchTestUtils.useTestEngines("test-extensions", null, TEST_CONFIG);
|
||||
await promiseStartupManager();
|
||||
|
||||
registerCleanupFunction(promiseShutdownManager);
|
||||
await Services.search.init();
|
||||
});
|
||||
registerCleanupFunction(promiseShutdownManager);
|
||||
await Services.search.init();
|
||||
}
|
||||
);
|
||||
|
||||
add_task(async function basic_multilocale_test() {
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
"Plain",
|
||||
]);
|
||||
add_task(
|
||||
{ skip_if: () => SearchUtils.newSearchConfigEnabled },
|
||||
async function basic_multilocale_test() {
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
"Plain",
|
||||
]);
|
||||
|
||||
let ext = ExtensionTestUtils.loadExtension(makeMultiLocaleExtension("2.0"));
|
||||
await ext.startup();
|
||||
await AddonTestUtils.waitForSearchProviderStartup(ext);
|
||||
let ext = ExtensionTestUtils.loadExtension(makeMultiLocaleExtension("2.0"));
|
||||
await ext.startup();
|
||||
await AddonTestUtils.waitForSearchProviderStartup(ext);
|
||||
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
"Plain",
|
||||
]);
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
"Plain",
|
||||
]);
|
||||
|
||||
let engine = await Services.search.getEngineByName("Multilocale AF");
|
||||
Assert.equal(
|
||||
engine.getSubmission("test").uri.spec,
|
||||
"https://example.af/?q=test&version=2.0",
|
||||
"Engine got update"
|
||||
);
|
||||
engine = await Services.search.getEngineByName("Multilocale AN");
|
||||
Assert.equal(
|
||||
engine.getSubmission("test").uri.spec,
|
||||
"https://example.an/?q=test&version=2.0",
|
||||
"Engine got update"
|
||||
);
|
||||
let engine = await Services.search.getEngineByName("Multilocale AF");
|
||||
Assert.equal(
|
||||
engine.getSubmission("test").uri.spec,
|
||||
"https://example.af/?q=test&version=2.0",
|
||||
"Engine got update"
|
||||
);
|
||||
engine = await Services.search.getEngineByName("Multilocale AN");
|
||||
Assert.equal(
|
||||
engine.getSubmission("test").uri.spec,
|
||||
"https://example.an/?q=test&version=2.0",
|
||||
"Engine got update"
|
||||
);
|
||||
|
||||
await ext.unload();
|
||||
});
|
||||
await ext.unload();
|
||||
}
|
||||
);
|
||||
|
||||
add_task(async function upgrade_with_configuration_change_test() {
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
"Plain",
|
||||
]);
|
||||
add_task(
|
||||
{ skip_if: () => SearchUtils.newSearchConfigEnabled },
|
||||
async function upgrade_with_configuration_change_test() {
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
"Plain",
|
||||
]);
|
||||
|
||||
let engine = await Services.search.getEngineByName("Plain");
|
||||
Assert.ok(engine.isAppProvided);
|
||||
Assert.equal(
|
||||
engine.getSubmission("test").uri.spec,
|
||||
// This test engine specifies the q and t params in its search_url, therefore
|
||||
// we get both those and the extra parameter specified in the test config.
|
||||
"https://duckduckgo.com/?q=test&t=ffsb&config=applied",
|
||||
"Should have the configuration applied before update."
|
||||
);
|
||||
let engine = await Services.search.getEngineByName("Plain");
|
||||
Assert.ok(engine.isAppProvided);
|
||||
Assert.equal(
|
||||
engine.getSubmission("test").uri.spec,
|
||||
// This test engine specifies the q and t params in its search_url, therefore
|
||||
// we get both those and the extra parameter specified in the test config.
|
||||
"https://duckduckgo.com/?q=test&t=ffsb&config=applied",
|
||||
"Should have the configuration applied before update."
|
||||
);
|
||||
|
||||
let ext = ExtensionTestUtils.loadExtension(makePlainExtension("2.0"));
|
||||
await ext.startup();
|
||||
await AddonTestUtils.waitForSearchProviderStartup(ext);
|
||||
let ext = ExtensionTestUtils.loadExtension(makePlainExtension("2.0"));
|
||||
await ext.startup();
|
||||
await AddonTestUtils.waitForSearchProviderStartup(ext);
|
||||
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
"Plain",
|
||||
]);
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
"Plain",
|
||||
]);
|
||||
|
||||
engine = await Services.search.getEngineByName("Plain");
|
||||
Assert.equal(
|
||||
engine.getSubmission("test").uri.spec,
|
||||
// This test engine specifies the q and t params in its search_url, therefore
|
||||
// we get both those and the extra parameter specified in the test config.
|
||||
"https://duckduckgo.com/?q=test&t=ffsb&config=applied",
|
||||
"Should still have the configuration applied after update."
|
||||
);
|
||||
engine = await Services.search.getEngineByName("Plain");
|
||||
Assert.equal(
|
||||
engine.getSubmission("test").uri.spec,
|
||||
// This test engine specifies the q and t params in its search_url, therefore
|
||||
// we get both those and the extra parameter specified in the test config.
|
||||
"https://duckduckgo.com/?q=test&t=ffsb&config=applied",
|
||||
"Should still have the configuration applied after update."
|
||||
);
|
||||
|
||||
await ext.unload();
|
||||
});
|
||||
await ext.unload();
|
||||
}
|
||||
);
|
||||
|
||||
add_task(async function test_upgrade_with_name_change() {
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
"Plain",
|
||||
]);
|
||||
add_task(
|
||||
{ skip_if: () => SearchUtils.newSearchConfigEnabled },
|
||||
async function test_upgrade_with_name_change() {
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
"Plain",
|
||||
]);
|
||||
|
||||
let ext = ExtensionTestUtils.loadExtension(
|
||||
makePlainExtension("2.0", "Plain2")
|
||||
);
|
||||
await ext.startup();
|
||||
await AddonTestUtils.waitForSearchProviderStartup(ext);
|
||||
let ext = ExtensionTestUtils.loadExtension(
|
||||
makePlainExtension("2.0", "Plain2")
|
||||
);
|
||||
await ext.startup();
|
||||
await AddonTestUtils.waitForSearchProviderStartup(ext);
|
||||
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
"Plain2",
|
||||
]);
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
"Plain2",
|
||||
]);
|
||||
|
||||
let engine = await Services.search.getEngineByName("Plain2");
|
||||
Assert.equal(
|
||||
engine.getSubmission("test").uri.spec,
|
||||
// This test engine specifies the q and t params in its search_url, therefore
|
||||
// we get both those and the extra parameter specified in the test config.
|
||||
"https://duckduckgo.com/?q=test&t=ffsb&config=applied",
|
||||
"Should still have the configuration applied after update."
|
||||
);
|
||||
let engine = await Services.search.getEngineByName("Plain2");
|
||||
Assert.equal(
|
||||
engine.getSubmission("test").uri.spec,
|
||||
// This test engine specifies the q and t params in its search_url, therefore
|
||||
// we get both those and the extra parameter specified in the test config.
|
||||
"https://duckduckgo.com/?q=test&t=ffsb&config=applied",
|
||||
"Should still have the configuration applied after update."
|
||||
);
|
||||
|
||||
await ext.unload();
|
||||
});
|
||||
await ext.unload();
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -88,43 +88,55 @@ add_task(async function test_install_duplicate_engine() {
|
|||
await extension.unload();
|
||||
});
|
||||
|
||||
add_task(async function basic_multilocale_test() {
|
||||
await promiseSetHomeRegion("an");
|
||||
add_task(
|
||||
// Not needed for new configuration.
|
||||
{ skip_if: () => SearchUtils.newSearchConfigEnabled },
|
||||
async function basic_multilocale_test() {
|
||||
await promiseSetHomeRegion("an");
|
||||
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Plain",
|
||||
"Special",
|
||||
"Multilocale AN",
|
||||
]);
|
||||
});
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Plain",
|
||||
"Special",
|
||||
"Multilocale AN",
|
||||
]);
|
||||
}
|
||||
);
|
||||
|
||||
add_task(async function complex_multilocale_test() {
|
||||
await promiseSetHomeRegion("af");
|
||||
add_task(
|
||||
// Not needed for new configuration.
|
||||
{ skip_if: () => SearchUtils.newSearchConfigEnabled },
|
||||
async function complex_multilocale_test() {
|
||||
await promiseSetHomeRegion("af");
|
||||
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Plain",
|
||||
"Special",
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
]);
|
||||
});
|
||||
Assert.deepEqual(await getEngineNames(), [
|
||||
"Plain",
|
||||
"Special",
|
||||
"Multilocale AF",
|
||||
"Multilocale AN",
|
||||
]);
|
||||
}
|
||||
);
|
||||
|
||||
add_task(async function test_manifest_selection() {
|
||||
// Sets the home region without updating.
|
||||
Region._setHomeRegion("an", false);
|
||||
await promiseSetLocale("af");
|
||||
add_task(
|
||||
// Not needed for new configuration.
|
||||
{ skip_if: () => SearchUtils.newSearchConfigEnabled },
|
||||
async function test_manifest_selection() {
|
||||
// Sets the home region without updating.
|
||||
Region._setHomeRegion("an", false);
|
||||
await promiseSetLocale("af");
|
||||
|
||||
let engine = await Services.search.getEngineByName("Multilocale AN");
|
||||
Assert.ok(
|
||||
engine.iconURI.spec.endsWith("favicon-an.ico"),
|
||||
"Should have the correct favicon for an extension of one locale using a different locale."
|
||||
);
|
||||
Assert.equal(
|
||||
engine.description,
|
||||
"A enciclopedia Libre",
|
||||
"Should have the correct engine name for an extension of one locale using a different locale."
|
||||
);
|
||||
});
|
||||
let engine = await Services.search.getEngineByName("Multilocale AN");
|
||||
Assert.ok(
|
||||
engine.iconURI.spec.endsWith("favicon-an.ico"),
|
||||
"Should have the correct favicon for an extension of one locale using a different locale."
|
||||
);
|
||||
Assert.equal(
|
||||
engine.description,
|
||||
"A enciclopedia Libre",
|
||||
"Should have the correct engine name for an extension of one locale using a different locale."
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
add_task(async function test_load_favicon_invalid() {
|
||||
let observed = TestUtils.consoleMessageObserved(msg => {
|
||||
|
|
|
|||
|
|
@ -34,60 +34,73 @@ async function getEngineNames() {
|
|||
return engines.map(engine => engine._name);
|
||||
}
|
||||
|
||||
add_setup(async function () {
|
||||
await SearchTestUtils.useTestEngines("test-extensions", null, CONFIG_DEFAULT);
|
||||
await AddonTestUtils.promiseStartupManager();
|
||||
registerCleanupFunction(AddonTestUtils.promiseShutdownManager);
|
||||
SearchTestUtils.useMockIdleService();
|
||||
await Services.search.init();
|
||||
});
|
||||
add_setup(
|
||||
{ skip_if: () => SearchUtils.newSearchConfigEnabled },
|
||||
async function () {
|
||||
await SearchTestUtils.useTestEngines(
|
||||
"test-extensions",
|
||||
null,
|
||||
CONFIG_DEFAULT
|
||||
);
|
||||
await AddonTestUtils.promiseStartupManager();
|
||||
registerCleanupFunction(AddonTestUtils.promiseShutdownManager);
|
||||
SearchTestUtils.useMockIdleService();
|
||||
await Services.search.init();
|
||||
}
|
||||
);
|
||||
|
||||
// Test the situation where we receive an updated configuration
|
||||
// that references an engine that doesnt exist locally as it
|
||||
// will be installed by Normandy.
|
||||
add_task(async function test_config_before_normandy() {
|
||||
// Ensure initial default setup.
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(CONFIG_DEFAULT);
|
||||
await restart();
|
||||
Assert.deepEqual(await getEngineNames(), ["Plain"]);
|
||||
// Updated configuration references nonexistant engine.
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(CONFIG_UPDATED);
|
||||
Assert.deepEqual(
|
||||
await getEngineNames(),
|
||||
["Plain"],
|
||||
"Updated engine hasnt been installed yet"
|
||||
);
|
||||
// Normandy then installs the engine.
|
||||
let addon = await SearchTestUtils.installSystemSearchExtension();
|
||||
Assert.deepEqual(
|
||||
await getEngineNames(),
|
||||
["Plain", "Example"],
|
||||
"Both engines are now enabled"
|
||||
);
|
||||
await addon.unload();
|
||||
});
|
||||
add_task(
|
||||
{ skip_if: () => SearchUtils.newSearchConfigEnabled },
|
||||
async function test_config_before_normandy() {
|
||||
// Ensure initial default setup.
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(CONFIG_DEFAULT);
|
||||
await restart();
|
||||
Assert.deepEqual(await getEngineNames(), ["Plain"]);
|
||||
// Updated configuration references nonexistant engine.
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(CONFIG_UPDATED);
|
||||
Assert.deepEqual(
|
||||
await getEngineNames(),
|
||||
["Plain"],
|
||||
"Updated engine hasnt been installed yet"
|
||||
);
|
||||
// Normandy then installs the engine.
|
||||
let addon = await SearchTestUtils.installSystemSearchExtension();
|
||||
Assert.deepEqual(
|
||||
await getEngineNames(),
|
||||
["Plain", "Example"],
|
||||
"Both engines are now enabled"
|
||||
);
|
||||
await addon.unload();
|
||||
}
|
||||
);
|
||||
|
||||
// Test the situation where we receive a newly installed
|
||||
// engine from Normandy followed by the update to the
|
||||
// configuration that uses that engine.
|
||||
add_task(async function test_normandy_before_config() {
|
||||
// Ensure initial default setup.
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(CONFIG_DEFAULT);
|
||||
await restart();
|
||||
Assert.deepEqual(await getEngineNames(), ["Plain"]);
|
||||
// Normandy installs the enigne.
|
||||
let addon = await SearchTestUtils.installSystemSearchExtension();
|
||||
Assert.deepEqual(
|
||||
await getEngineNames(),
|
||||
["Plain"],
|
||||
"Normandy engine ignored as not in config yet"
|
||||
);
|
||||
// Configuration is updated to use the engine.
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(CONFIG_UPDATED);
|
||||
Assert.deepEqual(
|
||||
await getEngineNames(),
|
||||
["Plain", "Example"],
|
||||
"Both engines are now enabled"
|
||||
);
|
||||
await addon.unload();
|
||||
});
|
||||
add_task(
|
||||
{ skip_if: () => SearchUtils.newSearchConfigEnabled },
|
||||
async function test_normandy_before_config() {
|
||||
// Ensure initial default setup.
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(CONFIG_DEFAULT);
|
||||
await restart();
|
||||
Assert.deepEqual(await getEngineNames(), ["Plain"]);
|
||||
// Normandy installs the enigne.
|
||||
let addon = await SearchTestUtils.installSystemSearchExtension();
|
||||
Assert.deepEqual(
|
||||
await getEngineNames(),
|
||||
["Plain"],
|
||||
"Normandy engine ignored as not in config yet"
|
||||
);
|
||||
// Configuration is updated to use the engine.
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(CONFIG_UPDATED);
|
||||
Assert.deepEqual(
|
||||
await getEngineNames(),
|
||||
["Plain", "Example"],
|
||||
"Both engines are now enabled"
|
||||
);
|
||||
await addon.unload();
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue