diff options
Diffstat (limited to 'toolkit/components/search/tests/xpcshell/test_searchTermFromResult.js')
-rw-r--r-- | toolkit/components/search/tests/xpcshell/test_searchTermFromResult.js | 169 |
1 files changed, 111 insertions, 58 deletions
diff --git a/toolkit/components/search/tests/xpcshell/test_searchTermFromResult.js b/toolkit/components/search/tests/xpcshell/test_searchTermFromResult.js index 700c6a3450..ea040aacd4 100644 --- a/toolkit/components/search/tests/xpcshell/test_searchTermFromResult.js +++ b/toolkit/components/search/tests/xpcshell/test_searchTermFromResult.js @@ -6,6 +6,53 @@ * Tests searchTermFromResult API. */ +let CONFIG_V2 = [ + { + recordType: "engine", + identifier: "engine-purposes", + base: { + name: "Test Engine With Purposes", + urls: { + search: { + base: "https://www.example.com/search", + params: [ + { name: "pc", value: "FIREFOX" }, + { + name: "form", + searchAccessPoint: { + newtab: "MOZNEWTAB", + homepage: "MOZHOMEPAGE", + searchbar: "MOZSEARCHBAR", + addressbar: "MOZKEYWORD", + contextmenu: "MOZCONTEXT", + }, + }, + { + name: "channel", + experimentConfig: "testChannelEnabled", + }, + ], + searchTermParamName: "q", + }, + }, + }, + variants: [ + { + environment: { allRegionsAndLocales: true }, + }, + ], + }, + { + recordType: "defaultEngines", + globalDefault: "engine-purpose", + specificDefaults: [], + }, + { + recordType: "engineOrders", + orders: [], + }, +]; + let defaultEngine; // The test string contains special characters to ensure @@ -14,66 +61,72 @@ const TERM = "c;,?:@&=+$-_.!~*'()# d\u00E8f"; const TERM_ENCODED = "c%3B%2C%3F%3A%40%26%3D%2B%24-_.!~*'()%23+d%C3%A8f"; add_setup(async function () { - await SearchTestUtils.useTestEngines("data", null, [ - { - 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", - }, + await SearchTestUtils.useTestEngines( + "data", + null, + SearchUtils.newSearchConfigEnabled + ? CONFIG_V2 + : [ { - name: "form", - condition: "purpose", - purpose: "newtab", - value: "MOZNEWTAB", + 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: [ + { + included: { everywhere: true }, + default: "yes", + }, + ], }, - { - 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: [ - { - included: { everywhere: true }, - default: "yes", - }, - ], - }, - ]); + ] + ); await AddonTestUtils.promiseStartupManager(); await Services.search.init(); |