From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../urlbar/tests/unit/test_providerAliasEngines.js | 146 +++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 browser/components/urlbar/tests/unit/test_providerAliasEngines.js (limited to 'browser/components/urlbar/tests/unit/test_providerAliasEngines.js') diff --git a/browser/components/urlbar/tests/unit/test_providerAliasEngines.js b/browser/components/urlbar/tests/unit/test_providerAliasEngines.js new file mode 100644 index 0000000000..bf2ce13e7e --- /dev/null +++ b/browser/components/urlbar/tests/unit/test_providerAliasEngines.js @@ -0,0 +1,146 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Tests search engine aliases. See + * browser/components/urlbar/tests/browser/browser_tokenAlias.js for tests of + * the token alias list (i.e. showing all aliased engines on a "@" query). + */ + +testEngine_setup(); + +// Basic test that uses two engines, a GET engine and a POST engine, neither +// providing search suggestions. +add_task(async function basicGetAndPost() { + await SearchTestUtils.installSearchExtension({ + name: "AliasedGETMozSearch", + keyword: "get", + search_url: "https://s.example.com/search", + }); + await SearchTestUtils.installSearchExtension({ + name: "AliasedPOSTMozSearch", + keyword: "post", + search_url: "https://s.example.com/search", + search_url_post_params: "q={searchTerms}", + }); + + for (let alias of ["get", "post"]) { + let context = createContext(alias, { isPrivate: false }); + await check_results({ + context, + matches: [ + makeSearchResult(context, { + engineName: SUGGESTIONS_ENGINE_NAME, + heuristic: true, + providerName: "HeuristicFallback", + }), + ], + }); + + context = createContext(`${alias} `, { isPrivate: false }); + await check_results({ + context, + matches: [ + makeSearchResult(context, { + engineName: `Aliased${alias.toUpperCase()}MozSearch`, + query: "", + alias, + heuristic: true, + providerName: "AliasEngines", + }), + ], + }); + + context = createContext(`${alias} fire`, { isPrivate: false }); + await check_results({ + context, + matches: [ + makeSearchResult(context, { + engineName: `Aliased${alias.toUpperCase()}MozSearch`, + query: "fire", + alias, + heuristic: true, + providerName: "AliasEngines", + }), + ], + }); + + context = createContext(`${alias} mozilla`, { isPrivate: false }); + await check_results({ + context, + matches: [ + makeSearchResult(context, { + engineName: `Aliased${alias.toUpperCase()}MozSearch`, + query: "mozilla", + alias, + heuristic: true, + providerName: "AliasEngines", + }), + ], + }); + + context = createContext(`${alias} MoZiLlA`, { isPrivate: false }); + await check_results({ + context, + matches: [ + makeSearchResult(context, { + engineName: `Aliased${alias.toUpperCase()}MozSearch`, + query: "MoZiLlA", + alias, + heuristic: true, + providerName: "AliasEngines", + }), + ], + }); + + context = createContext(`${alias} mozzarella mozilla`, { + isPrivate: false, + }); + await check_results({ + context, + matches: [ + makeSearchResult(context, { + engineName: `Aliased${alias.toUpperCase()}MozSearch`, + query: "mozzarella mozilla", + alias, + heuristic: true, + providerName: "AliasEngines", + }), + ], + }); + + context = createContext(`${alias} kitten?`, { + isPrivate: false, + }); + await check_results({ + context, + matches: [ + makeSearchResult(context, { + engineName: `Aliased${alias.toUpperCase()}MozSearch`, + query: "kitten?", + alias, + heuristic: true, + providerName: "AliasEngines", + }), + ], + }); + + context = createContext(`${alias} kitten ?`, { + isPrivate: false, + }); + await check_results({ + context, + matches: [ + makeSearchResult(context, { + engineName: `Aliased${alias.toUpperCase()}MozSearch`, + query: "kitten ?", + alias, + heuristic: true, + providerName: "AliasEngines", + }), + ], + }); + } + + await cleanupPlaces(); +}); -- cgit v1.2.3