Backed out 2 changesets (bug 1650880) for XPCshell failures in components/search/tests/xpcshell/test_engine_alias.js. CLOSED TREE
authorDorel Luca <dluca@mozilla.com>
Thu, 23 Jul 2020 20:46:18 +0300
changeset 541792 ee66b0925c55401bb7fd5e7eaa8db772ec16ed0c
parent 541791 f44fc6657963e9ee2fa02d8f51ef42a2dc8fe4ce
child 541793 c5dea073260ab635f66d73c59dd9f2156193fc12
push id37633
push userccoroiu@mozilla.com
push dateFri, 24 Jul 2020 09:32:06 +0000
treeherdermozilla-central@141543043270 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1650880
milestone80.0a1
backs out103d388bac7473c617ddf3c6794ee7651ff86422
0fb59851d956c1fce39125bf9b52de8003be840f
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 2 changesets (bug 1650880) for XPCshell failures in components/search/tests/xpcshell/test_engine_alias.js. CLOSED TREE Backed out changeset 103d388bac74 (bug 1650880) Backed out changeset 0fb59851d956 (bug 1650880)
toolkit/components/search/SearchEngine.jsm
toolkit/components/search/tests/xpcshell/data/search.json
toolkit/components/search/tests/xpcshell/test_engine_alias.js
toolkit/components/search/tests/xpcshell/test_json_cache.js
toolkit/components/search/tests/xpcshell/xpcshell.ini
--- a/toolkit/components/search/SearchEngine.jsm
+++ b/toolkit/components/search/SearchEngine.jsm
@@ -1160,23 +1160,25 @@ class SearchEngine {
     this._updateInterval = json._updateInterval || null;
     this._updateURL = json._updateURL || null;
     this._iconUpdateURL = json._iconUpdateURL || null;
     this._iconURI = SearchUtils.makeURI(json._iconURL);
     this._iconMapObj = json._iconMapObj;
     this._metaData = json._metaData || {};
     this._orderHint = json._orderHint || null;
     this._telemetryId = json._telemetryId || null;
-    this._definedAlias = json._definedAlias || null;
-    // These changed keys in Firefox 80, maintain the old keys
-    // for backwards compatibility.
-    this._filePath = json.filePath || json._filePath || null;
-    this._extensionID = json.extensionID || json._extensionID || null;
-    this._locale = json.extensionLocale || json._locale || null;
-
+    if (json.filePath) {
+      this._filePath = json.filePath;
+    }
+    if (json.extensionID) {
+      this._extensionID = json.extensionID;
+    }
+    if (json.extensionLocale) {
+      this._locale = json.extensionLocale;
+    }
     for (let i = 0; i < json._urls.length; ++i) {
       let url = json._urls[i];
       let engineURL = new EngineURL(
         url.type || SearchUtils.URL_TYPE.SEARCH,
         url.method || "GET",
         url.template,
         url.resultDomain || undefined
       );
@@ -1196,51 +1198,57 @@ class SearchEngine {
     if (gModernConfig && this._isAppProvided) {
       return {
         _name: this.name,
         _isAppProvided: true,
         _metaData: this._metaData,
       };
     }
 
-    const fieldsToCopy = [
-      "_name",
-      "_shortName",
-      "_loadPath",
-      "description",
-      "__searchForm",
-      "_iconURL",
-      "_iconMapObj",
-      "_metaData",
-      "_urls",
-      "_isAppProvided",
-      "_orderHint",
-      "_telemetryId",
-      "_updateInterval",
-      "_updateURL",
-      "_iconUpdateURL",
-      "_filePath",
-      "_extensionID",
-      "_locale",
-      "_definedAlias",
-    ];
+    var json = {
+      _name: this._name,
+      _shortName: this._shortName,
+      _loadPath: this._loadPath,
+      description: this.description,
+      __searchForm: this.__searchForm,
+      _iconURL: this._iconURL,
+      _iconMapObj: this._iconMapObj,
+      _metaData: this._metaData,
+      _urls: this._urls,
+      _isAppProvided: this._isAppProvided,
+      _orderHint: this._orderHint,
+      _telemetryId: this._telemetryId,
+    };
 
-    let json = {};
-    for (const field of fieldsToCopy) {
-      if (field in this) {
-        json[field] = this[field];
-      }
+    if (this._updateInterval) {
+      json._updateInterval = this._updateInterval;
     }
-
+    if (this._updateURL) {
+      json._updateURL = this._updateURL;
+    }
+    if (this._iconUpdateURL) {
+      json._iconUpdateURL = this._iconUpdateURL;
+    }
     if (!this._hasPreferredIcon) {
       json._hasPreferredIcon = this._hasPreferredIcon;
     }
     if (this.queryCharset != SearchUtils.DEFAULT_QUERY_CHARSET) {
       json.queryCharset = this.queryCharset;
     }
+    if (this._filePath) {
+      // File path is stored so that we can remove legacy xml files
+      // from the profile if the user removes the engine.
+      json.filePath = this._filePath;
+    }
+    if (this._extensionID) {
+      json.extensionID = this._extensionID;
+    }
+    if (this._locale) {
+      json.extensionLocale = this._locale;
+    }
 
     return json;
   }
 
   setAttr(name, val) {
     this._metaData[name] = val;
   }
 
--- a/toolkit/components/search/tests/xpcshell/data/search.json
+++ b/toolkit/components/search/tests/xpcshell/data/search.json
@@ -74,12 +74,12 @@
               "name": "channel",
               "value": "rcs",
               "purpose": "contextmenu"
             }
           ]
         }
       ],
       "queryCharset": "UTF-8",
-      "_extensionID": "test-addon-id@mozilla.org"
+      "extensionID": "test-addon-id@mozilla.org"
     }
   ]
 }
deleted file mode 100644
--- a/toolkit/components/search/tests/xpcshell/test_engine_alias.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-SearchTestUtils.initXPCShellAddonManager(this);
-SearchTestUtils.init(Assert, registerCleanupFunction);
-
-const NAME = "Test Alias Engine";
-
-add_task(async function setup() {
-  await AddonTestUtils.promiseStartupManager();
-  await Services.search.init();
-});
-
-add_task(async function upgrade_with_configuration_change_test() {
-  let cacheFileWritten = promiseAfterCache();
-  let extension = await SearchTestUtils.installSearchExtension({
-    name: NAME,
-    keyword: "testalias",
-  });
-  await extension.awaitStartup();
-  await cacheFileWritten;
-
-  let engine = Services.search.getEngineByAlias("testalias");
-  Assert.equal(engine?.name, NAME, "Engine can be fetched by alias");
-
-  // Restart the search service but not the AddonManager, we will
-  // load the engines from cache.
-  Services.search.wrappedJSObject.reset();
-  await Services.search.init();
-
-  engine = Services.search.getEngineByAlias("testalias");
-  Assert.equal(engine?.name, NAME, "Engine can be fetched by alias");
-
-  await extension.unload();
-});
--- a/toolkit/components/search/tests/xpcshell/test_json_cache.js
+++ b/toolkit/components/search/tests/xpcshell/test_json_cache.js
@@ -61,20 +61,16 @@ async function loadCacheFile(cacheFile) 
   if (!gModernConfig) {
     // For the legacy config, make sure we switch _isBuiltin to _isAppProvided
     // after saving, so that the expected results match.
     for (let engine of cacheTemplate.engines) {
       if ("_isBuiltin" in engine) {
         engine._isAppProvided = engine._isBuiltin;
         delete engine._isBuiltin;
       }
-      if ("extensionID" in engine) {
-        engine._extensionID = engine.extensionID;
-        delete engine.extensionID;
-      }
     }
   }
 }
 
 /**
  * Start the search service and confirm the engine properties match the expected values.
  *
  * @param {string} cacheFile
--- a/toolkit/components/search/tests/xpcshell/xpcshell.ini
+++ b/toolkit/components/search/tests/xpcshell/xpcshell.ini
@@ -60,17 +60,16 @@ support-files =
 
 [include:xpcshell-common.ini]
 
 [test_config_engine_params.js]
 support-files =
   method-extensions/get/manifest.json
   method-extensions/post/manifest.json
   method-extensions/engines.json
-[test_engine_alias.js]
 [test_engine_selector_application_distribution.js]
 [test_engine_selector_application_name.js]
 [test_initialization.js]
 [test_initialization_with_region.js]
 [test_region_params.js]
 [test_reload_engines.js]
 [test_missing_engine.js]
 [test_sort_orders-no-hints.js]