Bug 1552188 - Add Alias checks for the main search engines. r=daleharvey
authorMark Banner <standard8@mozilla.com>
Thu, 23 May 2019 14:26:13 +0000
changeset 475205 f310229807a47d75373d48994be96355ccbe6e61
parent 475204 963955816d383e7a277930c8ce58a08fefa7b26a
child 475206 7db5627ab9bd5c0267d23796e6b3e099091ace7d
push id36057
push useraciure@mozilla.com
push dateThu, 23 May 2019 21:52:03 +0000
treeherdermozilla-central@d551d37b9ad0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaleharvey
bugs1552188
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1552188 - Add Alias checks for the main search engines. r=daleharvey Depends on D32226 Differential Revision: https://phabricator.services.mozilla.com/D32296
toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js
toolkit/components/search/tests/xpcshell/searchconfigs/test_amazon.js
toolkit/components/search/tests/xpcshell/searchconfigs/test_baidu.js
toolkit/components/search/tests/xpcshell/searchconfigs/test_bing.js
toolkit/components/search/tests/xpcshell/searchconfigs/test_duckduckgo.js
toolkit/components/search/tests/xpcshell/searchconfigs/test_ebay.js
toolkit/components/search/tests/xpcshell/searchconfigs/test_google.js
toolkit/components/search/tests/xpcshell/searchconfigs/test_yandex.js
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.js
@@ -1,16 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 XPCOMUtils.defineLazyModuleGetters(this, {
   AddonTestUtils: "resource://testing-common/AddonTestUtils.jsm",
+  ObjectUtils: "resource://gre/modules/ObjectUtils.jsm",
   OS: "resource://gre/modules/osfile.jsm",
   SearchTestUtils: "resource://testing-common/SearchTestUtils.jsm",
   Services: "resource://gre/modules/Services.jsm",
 });
 
 const GLOBAL_SCOPE = this;
 
 const URLTYPE_SUGGEST_JSON = "application/x-suggestions+json";
@@ -329,26 +330,35 @@ class SearchConfigTest {
       const included = this._localeRegionInSection(value.included, region, locale);
       const excluded = value.excluded && this._localeRegionInSection(value.excluded, region, locale);
       return included && !excluded;
     });
 
     const engine = this._findEngine(engines, this._config.identifier);
     this.assertOk(engine, "Should have an engine present");
 
+    if (this._config.aliases) {
+      this.assertDeepEqual(engine._internalAliases,
+        this._config.aliases, "Should have the correct aliases for the engine");
+    }
+
     const location = `in region:${region}, locale:${locale}`;
 
     for (const rule of details) {
       this._assertCorrectDomains(location, engine, rule);
       if (rule.codes) {
         this._assertCorrectCodes(location, engine, rule);
       }
       if (rule.searchUrlCode || rule.searchFormUrlCode) {
         this._assertCorrectUrlCode(location, engine, rule);
       }
+      if (rule.aliases) {
+        this.assertDeepEqual(engine._internalAliases,
+          rule.aliases, "Should have the correct aliases for the engine");
+      }
     }
   }
 
   /**
    * Asserts whether the engine is using the correct domains or not.
    *
    * @param {string} location
    *   Debug string with locale + region information.
@@ -438,9 +448,15 @@ class SearchConfigTest {
     }
   }
 
   assertEqual(actual, expected, message) {
     if (actual != expected || this._testDebug) {
       Assert.equal(actual, expected, message);
     }
   }
+
+  assertDeepEqual(actual, expected, message) {
+    if (!ObjectUtils.deepEqual(actual, expected)) {
+      Assert.deepEqual(actual, expected, message);
+    }
+  }
 }
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_amazon.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_amazon.js
@@ -29,16 +29,17 @@ const test = new SearchConfigTest({
       },
     }],
   },
   details: [{
     // Note: These should be based on region, but we don't currently enforce that.
     // Note: the order here is important. A region/locale match higher up in the
     // list will override a region/locale match lower down.
     domain: "amazon.com.au",
+    aliases: ["@amazon"],
     included: [{
       regions: ["au"],
       locales: {
         matches: [
           "ach", "af", "ar", "as", "az", "bg", "bn-IN", "cak", "eo", "en-US",
           "en-ZA", "es-AR", "fa", "gn", "hy-AM", "ia", "is", "ka", "km", "lt",
           "mk", "ms", "my", "ro", "si", "th", "tl", "trs", "uz",
         ],
@@ -50,16 +51,17 @@ const test = new SearchConfigTest({
           "cy", "da", "el", "en-GB", "eu", "ga-IE", "gd", "gl", "hr", "nb-NO",
           "nn-NO", "pt-PT", "sq", "sr",
         ],
       },
     }],
     noSuggestionsURL: true,
   }, {
     domain: "amazon.ca",
+    aliases: ["@amazon"],
     included: [{
       locales: {
         matches: ["ca", "en-CA"],
       },
     }, {
       regions: ["ca"],
       locales: {
         matches: [
@@ -74,16 +76,17 @@ const test = new SearchConfigTest({
         matches: [
           "br", "fr", "ff", "son", "wo",
         ],
       },
     }],
     noSuggestionsURL: true,
   }, {
     domain: "amazon.fr",
+    aliases: ["@amazon"],
     included: [{
       locales: {
         matches: ["br", "fr", "ff", "son", "wo"],
       },
     }, {
       regions: ["fr"],
       locales: {
         matches: [
@@ -93,16 +96,17 @@ const test = new SearchConfigTest({
         ],
       },
     }],
     excluded: [{regions: ["ca"]}],
     searchUrlCode: "tag=firefox-fr-21",
     noSuggestionsURL: true,
   }, {
     domain: "amazon.co.uk",
+    aliases: ["@amazon"],
     included: [{
       locales: {
         matches: [
           "cy", "da", "el", "en-GB", "eu", "ga-IE", "gd", "gl", "hr", "nb-NO",
           "nn-NO", "pt-PT", "sq", "sr",
         ],
       },
     }, {
@@ -115,16 +119,17 @@ const test = new SearchConfigTest({
         ],
       },
     }],
     excluded: [{regions: ["au"]}],
     searchUrlCode: "tag=firefox-uk-21",
     noSuggestionsURL: true,
   }, {
     domain: "amazon.com",
+    aliases: ["@amazon"],
     included: [{
       locales: {
         matches: [
           "ach", "af", "ar", "as", "az", "bg", "bn-IN", "cak", "eo", "en-US",
           "en-ZA", "es-AR", "fa", "gn", "hy-AM", "ia", "is", "ka", "km", "lt",
           "mk", "ms", "my", "ro", "si", "th", "tl", "trs", "uz",
         ],
       },
@@ -137,44 +142,48 @@ const test = new SearchConfigTest({
       locales: {
         matches: ["zh-CN"],
       },
     }],
     searchUrlCode: "ix=sunray",
     noSuggestionsURL: true,
   }, {
     domain: "amazon.co.jp",
+    aliases: ["@amazon"],
     included: [{
       locales: {
         startsWith: ["ja"],
       },
     }],
     searchUrlCode: "tag=mozillajapan-fx-22",
     noSuggestionsURL: true,
   }, {
     domain: "amazon.de",
+    aliases: ["@amazon"],
     included: [{
       locales: {
         matches: ["de", "dsb", "hsb"],
       },
     }],
     noSuggestionsURL: true,
   }, {
     domain: "amazon.in",
+    aliases: ["@amazon"],
     included: [{
       locales: {
         matches: [
           "bn", "gu-IN", "kn", "mai", "ml", "mr", "or", "pa-IN", "ta",
           "te", "ur",
         ],
       },
     }],
     noSuggestionsURL: true,
   }, {
     domain: "amazon.it",
+    aliases: ["@amazon"],
     included: [{
       locales: {
         matches: ["it", "lij"],
       },
     }],
     searchUrlCode: "tag=firefoxit-21",
     noSuggestionsURL: true,
   }],
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_baidu.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_baidu.js
@@ -1,15 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const test = new SearchConfigTest({
   identifier: "baidu",
+  aliases: ["@\u767E\u5EA6", "@baidu"],
   default: {
     included: [{
       regions: [
         "cn",
       ],
       locales: {
         matches: ["zh-CN"],
       },
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_bing.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_bing.js
@@ -1,15 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const test = new SearchConfigTest({
   identifier: "bing",
+  aliases: ["@bing"],
   default: {
     // Not included anywhere.
   },
   available: {
     included: [{
       // regions: [
         // These arent currently enforced.
         // "au", "at", "be", "br", "ca", "fi", "fr", "de",
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_duckduckgo.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_duckduckgo.js
@@ -1,15 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const test = new SearchConfigTest({
   identifier: "ddg",
+  aliases: ["@duckduckgo", "@ddg"],
   default: {
     // Not included anywhere.
   },
   available: {
     excluded: [
       // Should be available everywhere.
     ],
   },
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_ebay.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_ebay.js
@@ -1,15 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const test = new SearchConfigTest({
   identifier: "ebay",
+  aliases: ["@ebay"],
   default: {
     // Not included anywhere.
   },
   available: {
     included: [{
       // We don't currently enforce by region, but do locale instead.
       // regions: [
       //   "us", "gb", "ca", "ie", "fr", "it", "de", "at", "es", "nl", "ch", "au"
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_google.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_google.js
@@ -1,15 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const test = new SearchConfigTest({
   identifier: "google",
+  aliases: ["@google"],
   default: {
     // Included everywhere apart from the exclusions below. These are basically
     // just excluding what Yandex and Baidu include.
     excluded: [{
       regions: [
         "ru", "tr", "by", "kz",
       ],
       locales: {
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_yandex.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_yandex.js
@@ -1,15 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const test = new SearchConfigTest({
   identifier: "yandex",
+  aliases: ["@\u044F\u043D\u0434\u0435\u043A\u0441", "@yandex"],
   default: {
     included: [{
       regions: [
         "ru", "tr", "by", "kz",
       ],
       locales: {
         matches: ["ru", "tr", "be", "kk"],
         // We don't currently enforce this.