Bug 1493483 - Use nsIBrowserSearchService::defaultEngine instead of currentEngine (in production code) r=Standard8
authorSiddhant085 <dpsrkp.sid@gmail.com>
Sat, 27 Oct 2018 16:52:02 +0000
changeset 443289 408f7a1a2d0f3e601ea64aa8c0dcf9382ae7a237
parent 443288 e47c537cec07a35dcd6c1ecc08f14fe438e1aadd
child 443290 deb0260b33c1b57a0a98c409d2f839a74596985a
push id34954
push userrgurzau@mozilla.com
push dateMon, 29 Oct 2018 22:00:12 +0000
treeherdermozilla-central@b851d42e2620 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs1493483
milestone65.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 1493483 - Use nsIBrowserSearchService::defaultEngine instead of currentEngine (in production code) r=Standard8 nsIBrowserSearchService::currentEngine and nsIBrowserSearchService::defaultEngine are the same thing. The use of defaultEngine makes more sense and thus we are phasing out the use of currentEngine and replace it with defaultEngine. Differential Revision: https://phabricator.services.mozilla.com/D7972
browser/base/content/browser.js
browser/base/content/nsContextMenu.js
browser/base/content/urlbarBindings.xml
browser/components/enterprisepolicies/Policies.jsm
browser/components/extensions/parent/ext-chrome-settings-overrides.js
browser/components/extensions/parent/ext-search.js
browser/components/newtab/lib/TopSitesFeed.jsm
browser/components/nsBrowserGlue.js
browser/components/preferences/in-content/search.js
browser/components/search/content/search-one-offs.js
browser/components/search/content/search.xml
browser/components/search/content/searchReset.js
browser/components/search/content/searchbar.js
browser/modules/ContentSearch.jsm
toolkit/components/search/nsSearchService.js
toolkit/components/search/nsSearchSuggestions.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3775,17 +3775,17 @@ const BrowserSearch = {
 
   delayedStartupInit() {
     // Asynchronously initialize the search service if necessary, to get the
     // current engine for working out the placeholder.
     Services.search.init(rv => {
       if (Components.isSuccessCode(rv)) {
         // Delay the update for this until so that we don't change it while
         // the user is looking at it / isn't expecting it.
-        this._updateURLBarPlaceholder(Services.search.currentEngine, true);
+        this._updateURLBarPlaceholder(Services.search.defaultEngine, true);
         this._searchInitComplete = true;
       }
     });
   },
 
   uninit() {
     Services.obs.removeObserver(this, "browser-search-engine-modified");
   },
@@ -4067,27 +4067,21 @@ const BrowserSearch = {
    *        A string meant to indicate the context of the search request. This
    *        allows the search service to provide a different nsISearchSubmission
    *        depending on e.g. where the search is triggered in the UI.
    *
    * @return engine The search engine used to perform a search, or null if no
    *                search was performed.
    */
   _loadSearch(searchText, useNewTab, purpose, triggeringPrincipal) {
-    let engine;
     if (!triggeringPrincipal) {
       throw new Error("Required argument triggeringPrincipal missing within _loadSearch");
     }
 
-    // If the search bar is visible, use the current engine, otherwise, fall
-    // back to the default engine.
-    if (isElementVisible(this.searchBar))
-      engine = Services.search.currentEngine;
-    else
-      engine = Services.search.defaultEngine;
+    let engine = Services.search.defaultEngine;
 
     let submission = engine.getSubmission(searchText, null, purpose); // HTML response
 
     // getSubmission can return null if the engine doesn't have a URL
     // with a text/html response type.  This is unlikely (since
     // SearchService._addEngineToStore() should fail for such an engine),
     // but let's be on the safe side.
     if (!submission) {
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -1501,17 +1501,17 @@ nsContextMenu.prototype = {
       let truncLength = 15;
       let truncChar = selectedText[15].charCodeAt(0);
       if (truncChar >= 0xDC00 && truncChar <= 0xDFFF)
         truncLength++;
       selectedText = selectedText.substr(0, truncLength) + this.ellipsis;
     }
 
     // format "Search <engine> for <selection>" string to show in menu
-    let engineName = Services.search.currentEngine.name;
+    let engineName = Services.search.defaultEngine.name;
     var menuLabel = gNavigatorBundle.getFormattedString("contextMenuSearch",
                                                         [engineName,
                                                          selectedText]);
     menuItem.label = menuLabel;
     menuItem.accessKey = gNavigatorBundle.getString("contextMenuSearch.accesskey");
   },
 
   createContainerMenu(aEvent) {
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -2474,17 +2474,17 @@ file, You can obtain one at http://mozil
               if (firstStyle.includes("autofill")) {
                 let uri = this.input.mController.getFinalCompleteValueAt(0);
                 this.maybeSetupSpeculativeConnect(uri);
               } else if (firstStyle.includes("searchengine") &&
                          this.input.browserSearchSuggestEnabled &&
                          this.input.urlbarSearchSuggestEnabled) {
                 // Preconnect to the current search engine only if the search
                 // suggestions are enabled.
-                let engine = Services.search.currentEngine;
+                let engine = Services.search.defaultEngine;
                 engine.speculativeConnect({window,
                                            originAttributes: gBrowser.contentPrincipal.originAttributes});
               }
             }
 
             // When a result is present the footer should always be visible.
             this.footer.collapsed = false;
             this.input.tabScrolling = true;
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -837,17 +837,17 @@ var Policies = {
               }
             } catch (ex) {
               log.error(`Search engine lookup failed when attempting to set ` +
                         `the default engine. Requested engine was ` +
                         `"${param.Default}".`, ex);
             }
             if (defaultEngine) {
               try {
-                Services.search.currentEngine = defaultEngine;
+                Services.search.defaultEngine = defaultEngine;
               } catch (ex) {
                 log.error("Unable to set the default search engine", ex);
               }
             }
           });
         }
       });
     },
--- a/browser/components/extensions/parent/ext-chrome-settings-overrides.js
+++ b/browser/components/extensions/parent/ext-chrome-settings-overrides.js
@@ -81,30 +81,30 @@ async function handleInitialHomepagePopu
 
 this.chrome_settings_overrides = class extends ExtensionAPI {
   static async processDefaultSearchSetting(action, id) {
     await ExtensionSettingsStore.initialize();
     let item = ExtensionSettingsStore.getSetting(DEFAULT_SEARCH_STORE_TYPE, DEFAULT_SEARCH_SETTING_NAME);
     if (!item) {
       return;
     }
-    if (Services.search.currentEngine.name != item.value &&
-        Services.search.currentEngine.name != item.initialValue) {
+    if (Services.search.defaultEngine.name != item.value &&
+        Services.search.defaultEngine.name != item.initialValue) {
       // The current engine is not the same as the value that the ExtensionSettingsStore has.
       // This means that the user changed the engine, so we shouldn't control it anymore.
       // Do nothing and remove our entry from the ExtensionSettingsStore.
       ExtensionSettingsStore.removeSetting(id, DEFAULT_SEARCH_STORE_TYPE, DEFAULT_SEARCH_SETTING_NAME);
       return;
     }
     item = ExtensionSettingsStore[action](id, DEFAULT_SEARCH_STORE_TYPE, DEFAULT_SEARCH_SETTING_NAME);
     if (item) {
       try {
         let engine = Services.search.getEngineByName(item.value || item.initialValue);
         if (engine) {
-          Services.search.currentEngine = engine;
+          Services.search.defaultEngine = engine;
         }
       } catch (e) {
         Cu.reportError(e);
       }
     }
   }
 
   static async removeEngine(id) {
@@ -212,27 +212,27 @@ this.chrome_settings_overrides = class e
           return;
         }
       }
       await this.addSearchEngine();
       if (searchProvider.is_default) {
         if (extension.startupReason === "ADDON_INSTALL") {
           // Don't ask if it already the current engine
           let engine = Services.search.getEngineByName(engineName);
-          if (Services.search.currentEngine != engine) {
+          if (Services.search.defaultEngine != engine) {
             let allow = await new Promise(resolve => {
               let subject = {
                 wrappedJSObject: {
                   // This is a hack because we don't have the browser of
                   // the actual install. This means the popup might show
                   // in a different window. Will be addressed in a followup bug.
                   browser: windowTracker.topWindow.gBrowser.selectedBrowser,
                   name: this.extension.name,
                   icon: this.extension.iconURL,
-                  currentEngine: Services.search.currentEngine.name,
+                  currentEngine: Services.search.defaultEngine.name,
                   newEngine: engineName,
                   resolve,
                 },
               };
               Services.obs.notifyObservers(subject, "webextension-defaultsearch-prompt");
             });
             if (!allow) {
               return;
@@ -251,50 +251,50 @@ this.chrome_settings_overrides = class e
     }
   }
 
   async setDefault(engineName) {
     let {extension} = this;
     if (extension.startupReason === "ADDON_INSTALL") {
       let item = await ExtensionSettingsStore.addSetting(
         extension.id, DEFAULT_SEARCH_STORE_TYPE, DEFAULT_SEARCH_SETTING_NAME, engineName, () => {
-          return Services.search.currentEngine.name;
+          return Services.search.defaultEngine.name;
         });
-      Services.search.currentEngine = Services.search.getEngineByName(item.value);
+      Services.search.defaultEngine = Services.search.getEngineByName(item.value);
     } else if (extension.startupReason === "ADDON_ENABLE") {
       chrome_settings_overrides.processDefaultSearchSetting("enable", extension.id);
     }
   }
 
   async addSearchEngine() {
     let {extension} = this;
     let isCurrent = false;
     let index = -1;
     if (extension.startupReason === "ADDON_UPGRADE") {
       let engines = Services.search.getEnginesByExtensionID(extension.id);
       if (engines.length > 0) {
         // There can be only one engine right now
-        isCurrent = Services.search.currentEngine == engines[0];
+        isCurrent = Services.search.defaultEngine == engines[0];
         // Get position of engine and store it
         index = Services.search.getEngines().indexOf(engines[0]);
         Services.search.removeEngine(engines[0]);
       }
     }
     try {
       Services.search.addEnginesFromExtension(extension);
       // Bug 1488516.  Preparing to support multiple engines per extension so
       // multiple locales can be loaded.
       let engines = Services.search.getEnginesByExtensionID(extension.id);
       await ExtensionSettingsStore.addSetting(
         extension.id, DEFAULT_SEARCH_STORE_TYPE, ENGINE_ADDED_SETTING_NAME,
         engines[0].name);
       if (extension.startupReason === "ADDON_UPGRADE") {
         let engine = Services.search.getEngineByName(engines[0].name);
         if (isCurrent) {
-          Services.search.currentEngine = engine;
+          Services.search.defaultEngine = engine;
         }
         if (index != -1) {
           Services.search.moveEngine(engine, index);
         }
       }
     } catch (e) {
       Cu.reportError(e);
       return false;
--- a/browser/components/extensions/parent/ext-search.js
+++ b/browser/components/extensions/parent/ext-search.js
@@ -48,33 +48,33 @@ this.search = class extends ExtensionAPI
                 favIconUrl = await getDataURI(engine.iconURI.spec);
               } else {
                 favIconUrl = engine.iconURI.spec;
               }
             }
 
             return {
               name: engine.name,
-              isDefault: engine === Services.search.currentEngine,
+              isDefault: engine === Services.search.defaultEngine,
               alias: engine.alias || undefined,
               favIconUrl,
             };
           }));
         },
 
         async search(searchProperties) {
           await searchInitialized;
           let engine;
           if (searchProperties.engine) {
             engine = Services.search.getEngineByName(searchProperties.engine);
             if (!engine) {
               throw new ExtensionError(`${searchProperties.engine} was not found`);
             }
           } else {
-            engine = Services.search.currentEngine;
+            engine = Services.search.defaultEngine;
           }
           let submission = engine.getSubmission(searchProperties.query, null, "webextension");
           let options = {
             postData: submission.postData,
             triggeringPrincipal: context.principal,
           };
           if (searchProperties.tabId === null) {
             let {gBrowser} = windowTracker.topWindow;
--- a/browser/components/newtab/lib/TopSitesFeed.jsm
+++ b/browser/components/newtab/lib/TopSitesFeed.jsm
@@ -48,17 +48,17 @@ const SEARCH_FILTERS = [
   "search.yahoo",
   "yahoo",
   "bing",
   "ask",
   "duckduckgo",
 ];
 
 function getShortURLForCurrentSearch() {
-  const url = shortURL({url: Services.search.currentEngine.searchForm});
+  const url = shortURL({url: Services.search.defaultEngine.searchForm});
   return url;
 }
 
 this.TopSitesFeed = class TopSitesFeed {
   constructor() {
     this._tippyTopProvider = new TippyTopProvider();
     XPCOMUtils.defineLazyGetter(this, "_currentSearchHostname", getShortURLForCurrentSearch);
     this.dedupe = new Dedupe(this._dedupeKey);
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -2361,17 +2361,17 @@ BrowserGlue.prototype = {
           if (data != "init-complete") {
             return;
           }
           Services.obs.removeObserver(observer, SEARCH_SERVICE_TOPIC);
           resolve();
         }, SEARCH_SERVICE_TOPIC);
       });
       searchInitializedPromise.then(() => {
-        let currentEngine = Services.search.currentEngine.wrappedJSObject;
+        let currentEngine = Services.search.defaultEngine.wrappedJSObject;
         // Only reset the current engine if it wasn't set by a WebExtension
         // and it is not one of the default engines.
         // If the original default is not a default, the user has a weird
         // configuration probably involving langpacks, it's not worth
         // attempting to reset their settings.
         if (currentEngine._extensionID || currentEngine._isDefault ||
             !Services.search.originalDefaultEngine.wrappedJSObject._isDefault)
           return;
--- a/browser/components/preferences/in-content/search.js
+++ b/browser/components/preferences/in-content/search.js
@@ -144,17 +144,17 @@ var gSearchPane = {
       document.getElementById("urlBarSuggestionPermanentPBLabel");
     permanentPBLabel.hidden = urlbarSuggests.hidden || !permanentPB;
   },
 
   buildDefaultEngineDropDown() {
     // This is called each time something affects the list of engines.
     let list = document.getElementById("defaultEngine");
     // Set selection to the current default engine.
-    let currentEngine = Services.search.currentEngine.name;
+    let currentEngine = Services.search.defaultEngine.name;
 
     // If the current engine isn't in the list any more, select the first item.
     let engines = gEngineView._engineStore._engines;
     if (!engines.some(e => e.name == currentEngine))
       currentEngine = engines[0].name;
 
     // Now clean-up and rebuild the list.
     list.removeAllItems();
@@ -386,17 +386,17 @@ var gSearchPane = {
       if (!engine.shown)
         hiddenList.push(engine.name);
     }
     Preferences.get("browser.search.hiddenOneOffs").value =
       hiddenList.join(",");
   },
 
   setDefaultEngine() {
-    Services.search.currentEngine =
+    Services.search.defaultEngine =
       document.getElementById("defaultEngine").selectedItem.engine;
     ExtensionSettingsStore.setByUser(SEARCH_TYPE, SEARCH_KEY);
   },
 };
 
 function onDragEngineStart(event) {
   var selectedIndex = gEngineView.selectedIndex;
   var tree = document.getElementById("engineList");
--- a/browser/components/search/content/search-one-offs.js
+++ b/browser/components/search/content/search-one-offs.js
@@ -138,47 +138,47 @@ class MozSearchOneOffs extends MozXULEle
       }
       if (target.classList.contains("search-one-offs-context-open-in-new-tab")) {
         // Select the context-clicked button so that consumers can easily
         // tell which button was acted on.
         this.selectedButton = this._buttonForEngine(this._contextEngine);
         this.handleSearchCommand(event, this._contextEngine, true);
       }
       if (target.classList.contains("search-one-offs-context-set-default")) {
-        let currentEngine = Services.search.currentEngine;
+        let currentEngine = Services.search.defaultEngine;
 
         if (!this.getAttribute("includecurrentengine")) {
           // Make the target button of the context menu reflect the current
           // search engine first. Doing this as opposed to rebuilding all the
           // one-off buttons avoids flicker.
           let button = this._buttonForEngine(this._contextEngine);
           button.id = this._buttonIDForEngine(currentEngine);
           let uri = "chrome://browser/skin/search-engine-placeholder.png";
           if (currentEngine.iconURI) {
             uri = currentEngine.iconURI.spec;
           }
           button.setAttribute("image", uri);
           button.setAttribute("tooltiptext", currentEngine.name);
           button.engine = currentEngine;
         }
 
-        Services.search.currentEngine = this._contextEngine;
+        Services.search.defaultEngine = this._contextEngine;
       }
     });
 
     this.addEventListener("contextmenu", event => {
       let target = event.originalTarget;
       // Prevent the context menu from appearing except on the one off buttons.
       if (!target.classList.contains("searchbar-engine-one-off-item") ||
           target.classList.contains("dummy")) {
         event.preventDefault();
         return;
       }
       this.querySelector(".search-one-offs-context-set-default")
-          .setAttribute("disabled", target.engine == Services.search.currentEngine);
+          .setAttribute("disabled", target.engine == Services.search.defaultEngine);
 
       this.contextMenuPopup.openPopupAtScreen(event.screenX, event.screenY, true);
       event.preventDefault();
 
       this._contextEngine = target.engine;
     });
   }
 
@@ -435,17 +435,17 @@ class MozSearchOneOffs extends MozXULEle
   }
 
   get engines() {
     if (this._engines) {
       return this._engines;
     }
     let currentEngineNameToIgnore;
     if (!this.getAttribute("includecurrentengine"))
-      currentEngineNameToIgnore = Services.search.currentEngine.name;
+      currentEngineNameToIgnore = Services.search.defaultEngine.name;
 
     let pref = Services.prefs.getStringPref("browser.search.hiddenOneOffs");
     let hiddenList = pref ? pref.split(",") : [];
 
     this._engines = Services.search.getVisibleEngines().filter(e => {
       let name = e.name;
       return (!currentEngineNameToIgnore ||
               name != currentEngineNameToIgnore) &&
@@ -563,17 +563,17 @@ class MozSearchOneOffs extends MozXULEle
     // content markup above.
     if (this.settingsButtonCompact.nextElementSibling) {
       this.settingsButtonCompact.nextElementSibling.remove();
     }
 
     let engines = this.engines;
     let oneOffCount = engines.length;
     let collapsed = !oneOffCount ||
-                    (oneOffCount == 1 && engines[0].name == Services.search.currentEngine.name);
+                    (oneOffCount == 1 && engines[0].name == Services.search.defaultEngine.name);
 
     // header is a xul:deck so collapsed doesn't work on it, see bug 589569.
     this.header.hidden = this.buttons.collapsed = collapsed;
 
     if (collapsed) {
       return;
     }
 
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -474,17 +474,17 @@
 
       <field name="oneOffButtons" readonly="true">
         document.getAnonymousElementByAttribute(this, "anonid",
                                                 "search-one-off-buttons");
       </field>
 
       <method name="updateHeader">
         <body><![CDATA[
-          let currentEngine = Services.search.currentEngine;
+          let currentEngine = Services.search.defaultEngine;
           let uri = currentEngine.iconURI;
           if (uri) {
             this.setAttribute("src", uri.spec);
           } else {
             // If the default has just been changed to a provider without icon,
             // avoid showing the icon of the previous default provider.
             this.removeAttribute("src");
           }
--- a/browser/components/search/content/searchReset.js
+++ b/browser/components/search/content/searchReset.js
@@ -36,17 +36,17 @@ function doSearch() {
     for (let param of params) {
       if (param.startsWith("data="))
         queryString = decodeURIComponent(param.slice(5));
       else if (param.startsWith("purpose="))
         purpose = param.slice(8);
     }
   }
 
-  let engine = Services.search.currentEngine;
+  let engine = Services.search.defaultEngine;
   let submission = engine.getSubmission(queryString, null, purpose);
 
   window.removeEventListener("unload", recordPageClosed);
 
   let win = window.docShell.rootTreeItem.domWindow;
   win.openTrustedLinkIn(submission.uri.spec, "current", {
     allowThirdPartyFixup: false,
     postData: submission.postData,
@@ -65,30 +65,30 @@ function savePref(value) {
     Services.prefs.setCharPref(statusPref, value);
 }
 
 function record(result) {
   Services.telemetry.getHistogramById("SEARCH_RESET_RESULT").add(result);
 }
 
 function keepCurrentEngine() {
-  // Calling the currentEngine setter will force a correct loadPathHash to be
+  // Calling the defaultEngine setter will force a correct loadPathHash to be
   // written for this engine, so that we don't prompt the user again.
   // eslint-disable-next-line no-self-assign
-  Services.search.currentEngine = Services.search.currentEngine;
+  Services.search.defaultEngine = Services.search.defaultEngine;
   record(TELEMETRY_RESULT_ENUM.KEPT_CURRENT);
   savePref("declined");
   doSearch();
 }
 
 function changeSearchEngine() {
   let engine = Services.search.originalDefaultEngine;
   if (engine.hidden)
     engine.hidden = false;
-  Services.search.currentEngine = engine;
+  Services.search.defaultEngine = engine;
 
   record(TELEMETRY_RESULT_ENUM.RESTORED_DEFAULT);
   savePref("accepted");
 
   doSearch();
 }
 
 function recordPageClosed() {
--- a/browser/components/search/content/searchbar.js
+++ b/browser/components/search/content/searchbar.js
@@ -153,22 +153,22 @@ class MozSearchbar extends MozXULElement
 
   get engines() {
     if (!this._engines)
       this._engines = Services.search.getVisibleEngines();
     return this._engines;
   }
 
   set currentEngine(val) {
-    Services.search.currentEngine = val;
+    Services.search.defaultEngine = val;
     return val;
   }
 
   get currentEngine() {
-    var currentEngine = Services.search.currentEngine;
+    var currentEngine = Services.search.defaultEngine;
     // Return a dummy engine if there is no currentEngine
     return currentEngine || { name: "", uri: null };
   }
   /**
    * textbox is used by sanitize.js to clear the undo history when
    * clearing form information.
    */
   get textbox() {
--- a/browser/modules/ContentSearch.jsm
+++ b/browser/modules/ContentSearch.jsm
@@ -329,17 +329,17 @@ var ContentSearch = {
   },
 
   async currentStateObj(uriFlag = false) {
     let state = {
       engines: [],
       currentEngine: await this._currentEngineObj(),
     };
     if (uriFlag) {
-      state.currentEngine.iconBuffer = Services.search.currentEngine.getIconURLBySize(16, 16);
+      state.currentEngine.iconBuffer = Services.search.defaultEngine.getIconURLBySize(16, 16);
     }
     let pref = Services.prefs.getCharPref("browser.search.hiddenOneOffs");
     let hiddenList = pref ? pref.split(",") : [];
     for (let engine of Services.search.getVisibleEngines()) {
       let uri = engine.getIconURLBySize(16, 16);
       let iconBuffer = uri;
       if (!uriFlag) {
         iconBuffer = await this._arrayBufferFromDataURI(uri);
@@ -415,17 +415,17 @@ var ContentSearch = {
     this._reply(msg, "Strings", this.searchSuggestionUIStrings);
   },
 
   _onMessageSearch(msg, data) {
     this.performSearch(msg, data);
   },
 
   _onMessageSetCurrentEngine(msg, data) {
-    Services.search.currentEngine = Services.search.getEngineByName(data);
+    Services.search.defaultEngine = Services.search.getEngineByName(data);
   },
 
   _onMessageManageEngines(msg) {
     msg.target.ownerGlobal.openPreferences("paneSearch", { origin: "contentSearch" });
   },
 
   async _onMessageGetSuggestions(msg, data) {
     this._ensureDataHasProperties(data, [
@@ -505,17 +505,17 @@ var ContentSearch = {
   _msgArgs(type, data) {
     return [OUTBOUND_MESSAGE, {
       type,
       data,
     }];
   },
 
   async _currentEngineObj() {
-    let engine = Services.search.currentEngine;
+    let engine = Services.search.defaultEngine;
     let favicon = engine.getIconURLBySize(16, 16);
     let placeholder = this._stringBundle.formatStringFromName(
       "searchWithEngine", [engine.name], 1);
     let obj = {
       name: engine.name,
       placeholder,
       iconBuffer: await this._arrayBufferFromDataURI(favicon),
     };
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -2411,17 +2411,17 @@ Engine.prototype = {
       aResponseType = AppConstants.platform == "android" ? this._defaultMobileResponseType :
                                                            URLTYPE_SEARCH_HTML;
     }
 
     let resetPending;
     if (aResponseType == URLTYPE_SEARCH_HTML &&
         ((resetPending = resetStatus == "pending") ||
          resetEnabled) &&
-        this.name == Services.search.currentEngine.name &&
+        this.name == Services.search.defaultEngine.name &&
         !this._isDefault &&
         this.name != Services.search.originalDefaultEngine.name &&
         (resetPending || !this.getAttr("loadPathHash") ||
          this.getAttr("loadPathHash") != getVerificationHash(this._loadPath)) &&
         !this._isWhiteListed) {
       let url = "about:searchreset";
       let data = [];
       if (aData)
--- a/toolkit/components/search/nsSearchSuggestions.js
+++ b/toolkit/components/search/nsSearchSuggestions.js
@@ -146,17 +146,17 @@ SuggestAutoComplete.prototype = {
 
   /**
    * Actual implementation of search.
    */
   _triggerSearch(searchString, searchParam, listener, privacyMode) {
     this._listener = listener;
     this._suggestionController.fetch(searchString,
                                      privacyMode,
-                                     Services.search.currentEngine);
+                                     Services.search.defaultEngine);
   },
 
   /**
    * Ends the search result gathering process. Part of nsIAutoCompleteSearch
    * implementation.
    */
   stopSearch() {
     this._suggestionController.stop();