Backed out changeset 4db69eae7372 (bug 1541414) for linting failure on test_baidu.js . CLOSED TREE
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Tue, 07 May 2019 17:56:02 +0300
changeset 472902 1dde02f1def7fe94b166386bb5cabb60a1bcd78a
parent 472901 4db69eae737243de67e3eecf4b4afbba34921471
child 472903 1d8541a0ffe7f3f185f55f4c5a3939f6c6e28e6b
push id35983
push userncsoregi@mozilla.com
push dateWed, 08 May 2019 03:38:51 +0000
treeherdermozilla-central@0e9e744accd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1541414
milestone68.0a1
backs out4db69eae737243de67e3eecf4b4afbba34921471
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
Backed out changeset 4db69eae7372 (bug 1541414) for linting failure on test_baidu.js . CLOSED TREE
toolkit/components/search/tests/xpcshell/searchconfigs/head_searchconfig.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_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
@@ -92,21 +92,21 @@ class SearchConfigTest {
   async run() {
     const locales = await this._getLocales();
     const regions = this._regions;
 
     // We loop on region and then locale, so that we always cause a re-init
     // when updating the requested/available locales.
     for (let region of regions) {
       for (let locale of locales) {
-        info(`Checking region: "${region}" locale: "${locale}"`);
+        const infoString = `region: "${region}" locale: "${locale}"`;
+        info(`Checking ${infoString}`);
         await this._reinit(region, locale);
 
-        this._assertDefaultEngines(region, locale);
-        await this._assertAvailableEngines(region, locale);
+        this._assertDefaultEngines(region, locale, infoString);
       }
     }
 
     Assert.ok(!this._testDebug, "Should not have test debug turned on in production");
   }
 
   /**
    * Causes re-initialization of the SearchService with the new region and locale.
@@ -184,89 +184,57 @@ class SearchConfigTest {
    *   The two-letter region code.
    * @param {string} locale
    *   The two-letter locale code.
    * @returns {boolean}
    *   True if the locale/region pair matches the section.
    */
   _localeRegionInSection(section, region, locale) {
     for (const {regions, locales} of section) {
-      // If we only specify a regions or locales section then
-      // it is always considered included in the other section.
-      const inRegions = !regions || regions.includes(region);
-      const inLocales = !locales || this._localeIncludes(locales, locale);
-      if (inRegions && inLocales) {
+      if (regions.includes(region) &&
+          this._localeIncludes(locales, locale)) {
         return true;
       }
     }
     return false;
   }
 
   /**
-   * Asserts whether the engines rules defined in the configuration are met.
-   *
-   * @param {Array} engines
-   *   The list of engines to check.
-   * @param {string} region
-   *   The two-letter region code.
-   * @param {string} locale
-   *   The two-letter locale code.
-   * @param {string} section
-   *   The section of the configuration to check.
-   */
-  _assertEngineRules(engines, region, locale, section) {
-    const infoString = `region: "${region}" locale: "${locale}"`;
-    const config = this._config[section];
-    const hasIncluded = "included" in config;
-    const hasExcluded = "excluded" in config;
-
-    // If there's not included/excluded, then this shouldn't be the default anywhere.
-    if (section == "default" && !hasIncluded && !hasExcluded) {
-      Assert.ok(!engines.includes(this._config.identifier),
-        `Should not be ${section} for any locale/region,
-         currently set for ${infoString}`);
-      return;
-    }
-
-    // If there's no included section, we assume the engine is default everywhere
-    // and we should apply the exclusions instead.
-    let included = (hasIncluded &&
-      this._localeRegionInSection(config.included, region, locale));
-
-    let notExcluded = (hasExcluded &&
-     !this._localeRegionInSection(config.excluded, region, locale));
-
-    if (included || notExcluded) {
-      Assert.ok(engines.includes(this._config.identifier),
-        `Should be ${section} for ${infoString}`);
-      return;
-    }
-    Assert.ok(!engines.includes(this._config.identifier),
-      `Should not be ${section} for ${infoString}`);
-  }
-
-  /**
    * Asserts whether the engine is correctly set as default or not.
    *
    * @param {string} region
    *   The two-letter region code.
    * @param {string} locale
    *   The two-letter locale code.
+   * @param {string} infoString
+   *   An additional message to output with assertions.
    */
-  _assertDefaultEngines(region, locale) {
+  _assertDefaultEngines(region, locale, infoString) {
+    // We use the originalDefaultEngine here as due to the way we run the tests
+    // the default engine may not have changed.
     const identifier = Services.search.originalDefaultEngine.identifier;
-    this._assertEngineRules([identifier], region, locale, "default");
-  }
 
-  /**
-   * Asserts whether the engine is correctly available or not.
-   *
-   * @param {string} region
-   *   The two-letter region code.
-   * @param {string} locale
-   *   The two-letter locale code.
-   */
-  async _assertAvailableEngines(region, locale) {
-    const engines = await Services.search.getVisibleEngines();
-    const engineNames = engines.map(engine => engine._shortName);
-    this._assertEngineRules(engineNames, region, locale, "available");
+    // If there's not included/excluded, then this shouldn't be the default anywhere.
+    if (!("included" in this._config.default) &&
+        !("excluded" in this._config.default)) {
+      Assert.notEqual(identifier,
+        this._config.identifier,
+        `Should not be set as the default engine for any locale/region,
+         currently set for ${infoString}`);
+      return;
+    }
+
+    // If there's no included section, we assume the engine is default everywhere
+    // and we should apply the exclusions instead.
+    if (("included" in this._config.default &&
+        this._localeRegionInSection(this._config.default.included, region, locale)) ||
+        ("excluded" in this._config.default &&
+         !this._localeRegionInSection(this._config.default.excluded, region, locale))) {
+      Assert.equal(identifier,
+        this._config.identifier,
+        `Should be set as the default engine for ${infoString}`);
+      return;
+    }
+    Assert.notEqual(identifier,
+      this._config.identifier,
+      `Should not be set as the default engine for ${infoString}`);
   }
 }
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_baidu.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_baidu.js
@@ -10,23 +10,16 @@ const test = new SearchConfigTest({
       regions: [
         "cn",
       ],
       locales: {
         matches: ["zh-CN"],
       },
     }],
   },
-  available: {
-    included: [{
-      locales: {
-        matches: ["zh-CN"],
-      },
-    }]
-  },
 });
 
 add_task(async function setup() {
   await test.setup();
 });
 
 add_task(async function test_searchConfig_baidu() {
   await test.run();
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_bing.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_bing.js
@@ -3,40 +3,16 @@
 
 "use strict";
 
 const test = new SearchConfigTest({
   identifier: "bing",
   default: {
     // Not included anywhere.
   },
-  available: {
-    included: [{
-      //regions: [
-        // These arent currently enforced.
-        // "au", "at", "be", "br", "ca", "fi", "fr", "de",
-        // "in", "ie", "it", "jp", "my", "mx", "nl", "nz",
-        // "no", "sg", "es", "se", "ch", "gb", "us",
-      //],
-      locales: {
-        matches: [
-          "ach", "af", "an", "ar", "ast", "az", "bn", "bn-BD",
-          "bn-ID", "ca", "cak", "da","de", "dsb", "el", "en-CA",
-          "en-GB", "en-US", "en-ZA", "eo", "es-CL", "es-ES",
-          "es-MX", "eu", "fa", "ff", "fi", "fr", "fy-NL", "gn",
-          "gu-IN", "hi-IN", "hr", "hsb", "ia", "is", "it",
-          "ja-JP-mac", "ja", "ka", "kab", "km", "kn", "lij", "lo",
-          "lt", "mai", "mk", "ml", "ms", "my", "nb-NO", "ne-NP", "nl",
-          "nn-NO", "oc", "or", "pa-IN", "pt-BR", "rm", "ro", "son",
-          "sq", "sr", "sv-SE", "th", "tl", "trs", "uk", "ur", "uz",
-          "wo", "xh", "zh-CN",
-        ],
-      },
-    }],
-  },
 });
 
 add_task(async function setup() {
   await test.setup();
 });
 
 add_task(async function test_searchConfig_bing() {
   await test.run();
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_google.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_google.js
@@ -18,21 +18,16 @@ const test = new SearchConfigTest({
       },
     }, {
       regions: ["cn"],
       locales: {
         matches: ["zh-CN"],
       },
     }],
   },
-  available: {
-    excluded: [
-      // Should be available everywhere.
-    ],
-  },
 });
 
 add_task(async function setup() {
   await test.setup();
 });
 
 add_task(async function test_searchConfig_google() {
   await test.run();
--- a/toolkit/components/search/tests/xpcshell/searchconfigs/test_yandex.js
+++ b/toolkit/components/search/tests/xpcshell/searchconfigs/test_yandex.js
@@ -11,23 +11,16 @@ const test = new SearchConfigTest({
         "ru", "tr", "by", "kz",
       ],
       locales: {
         matches: ["ru", "tr", "be", "kk"],
         startsWith: ["en"],
       },
     }],
   },
-  available: {
-    included: [{
-      locales: {
-        matches: ["az", "ru", "be", "kk", "tr"]
-      },
-    }],
-  },
 });
 
 add_task(async function setup() {
   await test.setup();
 });
 
 add_task(async function test_searchConfig_yandex() {
   await test.run();