Backed out changeset 1f187635f2e4 (bug 1482125) for test_nsDefaultURIFixup_search.js failures CLOSED TREE
authorBogdan Tara <btara@mozilla.com>
Fri, 10 Aug 2018 20:18:43 +0300
changeset 486093 c5109843829d5758ac7e5ad618b826141396ad59
parent 486092 5d5bb48ca0b9dc79f6f0c62f3f11b97c6f25cd2d
child 486094 818a07277354cacbf0956fdaed0100771dde3a92
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1482125
milestone63.0a1
backs out1f187635f2e4b801134bd6b549a55df5e3ed96c7
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 1f187635f2e4 (bug 1482125) for test_nsDefaultURIFixup_search.js failures CLOSED TREE
toolkit/components/places/PlacesSearchAutocompleteProvider.jsm
toolkit/components/places/tests/unifiedcomplete/test_PlacesSearchAutocompleteProvider.js
toolkit/components/search/nsSearchService.js
--- a/toolkit/components/places/PlacesSearchAutocompleteProvider.jsm
+++ b/toolkit/components/places/PlacesSearchAutocompleteProvider.jsm
@@ -12,16 +12,21 @@ var EXPORTED_SYMBOLS = [ "PlacesSearchAu
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 ChromeUtils.defineModuleGetter(this, "SearchSuggestionController",
   "resource://gre/modules/SearchSuggestionController.jsm");
 
 const SEARCH_ENGINE_TOPIC = "browser-search-engine-modified";
 
+const ENGINE_ALIASES = new Map([
+  ["Google", "@google"],
+  ["Amazon", "@amazon"],
+]);
+
 const SearchAutocompleteProviderInternal = {
   /**
    * Array of objects in the format returned by findMatchByToken.
    */
   priorityMatches: null,
 
   /**
    * Array of objects in the format returned by findMatchByAlias.
@@ -97,20 +102,28 @@ const SearchAutocompleteProviderInternal
         url: engine.searchForm,
         engineName: engine.name,
         iconUrl: engine.iconURI ? engine.iconURI.spec : null,
       });
     }
 
     let aliases = [];
 
+    for (let [name, alias] of ENGINE_ALIASES) {
+      if (!engine.wrappedJSObject._isDefault ||
+          !engine.name.startsWith(name)) {
+        continue;
+      }
+      aliases.push(alias);
+      break;
+    }
+
     if (engine.alias) {
       aliases.push(engine.alias);
     }
-    aliases.push(...engine.wrappedJSObject._internalAliases);
 
     if (aliases.length) {
       this.aliasMatches.push({
         aliases,
         engineName: engine.name,
         iconUrl: engine.iconURI ? engine.iconURI.spec : null,
         resultDomain: domain,
       });
--- a/toolkit/components/places/tests/unifiedcomplete/test_PlacesSearchAutocompleteProvider.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_PlacesSearchAutocompleteProvider.js
@@ -114,18 +114,22 @@ add_task(async function test_parseSubmis
 
   result = PlacesSearchAutocompleteProvider.parseSubmissionURL("http://example.org/");
   Assert.equal(result, null);
 });
 
 add_task(async function test_builtin_aliased_search_engine_match() {
   let match = await PlacesSearchAutocompleteProvider.findMatchByAlias("@google");
   Assert.equal(match.engineName, "Google");
+
+  let match1 = await PlacesSearchAutocompleteProvider.findMatchByAlias("@amazon");
+  Assert.ok(match1.engineName.startsWith("Amazon"));
 });
 
+
 function promiseDefaultSearchEngine() {
   return new Promise(resolve => {
     Services.search.init( () => {
       resolve(Services.search.defaultEngine);
     });
   });
 }
 
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -931,46 +931,16 @@ function ParamSubstitution(aParamValue, 
         return param[1];
     }
 
     // Don't replace unknown non-optional parameters.
     return match;
   });
 }
 
-const ENGINE_ALIASES = new Map([
-  ["google", ["@google"]],
-  ["amazondotcom", ["@amazon"]],
-  ["amazondotcom-de", ["@amazon"]],
-  ["amazon-en-GB", ["@amazon"]],
-  ["amazon-france", ["@amazon"]],
-  ["amazon-jp", ["@amazon"]],
-  ["amazon-it", ["@amazon"]],
-  ["twitter", ["@twitter"]],
-  ["wikipedia", ["@wikipedia"]],
-  ["ebay", ["@ebay"]],
-  ["bing", ["@bing"]],
-  ["ddg", ["@duckduckgo", "@ddg"]],
-  ["yandex", ["@yandex"]],
-  ["baidu", ["@baidu"]],
-]);
-
-
-function getInternalAliases(engine) {
-  if (!engine._isDefault) {
-    return [];
-  }
-  for (let [name, aliases] of ENGINE_ALIASES) {
-    if (engine._shortName.startsWith(name)) {
-      return aliases;
-    }
-  }
-  return [];
-}
-
 /**
  * Creates an engineURL object, which holds the query URL and all parameters.
  *
  * @param aType
  *        A string containing the name of the MIME type of the search results
  *        returned by this URL.
  * @param aMethod
  *        The HTTP request method. Must be a case insensitive value of either
@@ -1263,18 +1233,16 @@ Engine.prototype = {
   // The number of days between update checks for new versions
   _updateInterval: null,
   // The url to check at for a new update
   _updateURL: null,
   // The url to check for a new icon
   _iconUpdateURL: null,
   /* The extension ID if added by an extension. */
   _extensionID: null,
-  /* Internal aliases for default engines only. */
-  _internalAliases: [],
 
   /**
    * Retrieves the data from the engine's file.
    * The document element is placed in the engine's data field.
    */
   _initFromFile: function SRCH_ENG_initFromFile(file) {
     if (!file || !file.exists())
       FAIL("File must exist before calling initFromFile!", Cr.NS_ERROR_UNEXPECTED);
@@ -3152,17 +3120,16 @@ SearchService.prototype = {
       notifyAction(aEngine, SEARCH_ENGINE_ADDED);
     }
 
     if (aEngine._hasUpdates) {
       // Schedule the engine's next update, if it isn't already.
       if (!aEngine.getAttr("updateexpir"))
         engineUpdateService.scheduleNextUpdate(aEngine);
     }
-    aEngine._internalAliases = getInternalAliases(aEngine);
   },
 
   _loadEnginesMetadataFromCache: function SRCH_SVC__loadEnginesMetadataFromCache(cache) {
     if (!cache.engines)
       return;
 
     for (let engine of cache.engines) {
       let name = engine._name;
@@ -3814,19 +3781,18 @@ SearchService.prototype = {
     this._ensureInitialized();
     return this._engines[aEngineName] || null;
   },
 
   getEngineByAlias: function SRCH_SVC_getEngineByAlias(aAlias) {
     this._ensureInitialized();
     for (var engineName in this._engines) {
       var engine = this._engines[engineName];
-      if (engine && (engine.alias == aAlias || engine._internalAliases.includes(aAlias))) {
+      if (engine && engine.alias == aAlias)
         return engine;
-      }
     }
     return null;
   },
 
   addEngineWithDetails: function SRCH_SVC_addEWD(aName, iconURL, alias,
                                                  description, method,
                                                  template, extensionID) {
     let isCurrent = false;