From 8f644aea91713b8c815c8511ddac6b329339ce46 Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Thu, 21 Nov 2019 21:54:14 +0000 Subject: [PATCH] Bug 1598270 - Add support for MozParams on Google search engine in the modern configuration, and update the schema. r=mikedeboer Differential Revision: https://phabricator.services.mozilla.com/D54114 --HG-- extra : moz-landing-system : lando --- .../components/search/extensions/engines.json | 15 ++++++ .../schema/search-engine-config-schema.json | 52 +++++++++++++++++++ .../search-engine-config-ui-schema.json | 1 + .../xpcshell/searchconfigs/test_google.js | 2 +- 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/browser/components/search/extensions/engines.json b/browser/components/search/extensions/engines.json index 3fd835ab869a..cb8fe35cc91c 100644 --- a/browser/components/search/extensions/engines.json +++ b/browser/components/search/extensions/engines.json @@ -12,6 +12,11 @@ "q": "{searchTerms}" } }, + "extraParams": [{ + "name": "channel", + "condition": "pref", + "pref": "google_channel_row" + }], "telemetryId": "google-b-d", "appliesTo": [{ "included": { "everywhere": true }, @@ -90,6 +95,11 @@ "q": "{searchTerms}" } }, + "extraParams": [{ + "name": "channel", + "condition": "pref", + "pref": "google_channel_us" + }], "telemetryId": "google-b-1-d" }, { "included": { "regions": ["us"] }, @@ -102,6 +112,11 @@ "q": "{searchTerms}" } }, + "extraParams": [{ + "name": "channel", + "condition": "pref", + "pref": "google_channel_us" + }], "telemetryId": "google-b-1-e" }] }, diff --git a/toolkit/components/search/schema/search-engine-config-schema.json b/toolkit/components/search/schema/search-engine-config-schema.json index 0f59faefa948..36ce9707238d 100644 --- a/toolkit/components/search/schema/search-engine-config-schema.json +++ b/toolkit/components/search/schema/search-engine-config-schema.json @@ -31,6 +31,9 @@ }, "params": { "$ref": "#/definitions/params" + }, + "extraParams": { + "$ref": "#/definitions/extraParams" } }, "definitions": { @@ -97,6 +100,52 @@ "no" ] }, + "extraParams": { + "type": "array", + "title": "Extra Parameters", + "description": "Extra parameters for the search engine (aka MozParams)", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": "Name", + "description": "Name of the parameter that will be used in the search query" + }, + "condition": { + "type": "string", + "title": "Condition", + "description": "The type of parameter (pref or purpose)", + "enum": [ + "pref", + "purpose" + ] + }, + "purpose": { + "type": "string", + "title": "Purpose", + "description": "The search purpose that triggers this parameter being appended.", + "enum": [ + "searchbar", + "keyword", + "contextmenu", + "homepage", + "newtab" + ] + }, + "value": { + "type": "string", + "title": "Value", + "description": "If this is a purpose type, the value is used as the value of the parameter in the query" + }, + "pref": { + "type": "string", + "title": "Preference name", + "description": "The preference name to get the value from (i.e. browser.search.param.)." + } + } + } + }, "orderHint": { "type": "number", "title": "Order Hint", @@ -308,6 +357,9 @@ }, "params": { "$ref": "#/definitions/params" + }, + "extraParams": { + "$ref": "#/definitions/extraParams" } } } diff --git a/toolkit/components/search/schema/search-engine-config-ui-schema.json b/toolkit/components/search/schema/search-engine-config-ui-schema.json index 334df7551360..fc5ade9e315c 100644 --- a/toolkit/components/search/schema/search-engine-config-ui-schema.json +++ b/toolkit/components/search/schema/search-engine-config-ui-schema.json @@ -6,6 +6,7 @@ "orderHint", "telemetryId", "params", + "extraParams", "appliesTo" ] } diff --git a/toolkit/components/search/tests/xpcshell/searchconfigs/test_google.js b/toolkit/components/search/tests/xpcshell/searchconfigs/test_google.js index 5dabefeb0d39..a981a7ef5426 100644 --- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_google.js +++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_google.js @@ -98,7 +98,7 @@ add_task(async function test_searchConfig_google_with_mozparam() { // TODO: Bug 1598270 will add the true option here, to test for the selector, // aka modern configuration. - for (const useSelector of [false]) { + for (const useSelector of [false, true]) { info("Using " + (useSelector ? "Selector" : "Legacy Configuration")); for (const testData of TEST_DATA) { info(`Checking region ${testData.region}, locale ${testData.locale}`);