Bug 1646128 - Renamed SearchService.getDefaultEngines to SearchService.getAppProvidedEngines. r=harry
☠☠ backed out by 9db38d8a088c ☠ ☠
authoramy churchwell <achurchwell@mozilla.com>
Thu, 17 Dec 2020 14:40:05 +0000
changeset 561124 d5111a57ad25315ec07d0612cf95257b3a622a6d
parent 561123 bcff6178e42504ce6d83395e507b8b25b2789915
child 561125 099856a46d6b2671ab23739c35b6772059afa10e
push id133026
push userhtwyford@mozilla.com
push dateThu, 17 Dec 2020 14:59:58 +0000
treeherderautoland@d5111a57ad25 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersharry
bugs1646128
milestone86.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 1646128 - Renamed SearchService.getDefaultEngines to SearchService.getAppProvidedEngines. r=harry Differential Revision: https://phabricator.services.mozilla.com/D99941
browser/components/newtab/lib/ASRouterTargeting.jsm
browser/components/newtab/lib/SearchShortcuts.jsm
browser/components/newtab/lib/TopSitesFeed.jsm
browser/components/newtab/test/browser/browser_asrouter_targeting.js
browser/components/newtab/test/unit/lib/TopSitesFeed.test.js
browser/components/preferences/search.js
browser/components/preferences/tests/browser_searchRestoreDefaults.js
toolkit/components/search/SearchService.jsm
toolkit/components/search/nsISearchService.idl
toolkit/components/search/tests/xpcshell/test_maybereloadengine_order.js
toolkit/components/search/tests/xpcshell/test_reload_engines.js
toolkit/components/search/tests/xpcshell/test_reload_engines_experiment.js
toolkit/components/search/tests/xpcshell/test_selectedEngine.js
toolkit/components/search/tests/xpcshell/test_sort_orders-no-hints.js
toolkit/components/search/tests/xpcshell/test_sort_orders.js
toolkit/components/search/tests/xpcshell/test_webextensions_normandy_upgrade.js
--- a/browser/components/newtab/lib/ASRouterTargeting.jsm
+++ b/browser/components/newtab/lib/ASRouterTargeting.jsm
@@ -453,17 +453,17 @@ const TargetingGetters = {
         return { addons: info, isFullData: fullData };
       }
     );
   },
   get searchEngines() {
     return new Promise(resolve => {
       // Note: calling init ensures this code is only executed after Search has been initialized
       Services.search
-        .getDefaultEngines()
+        .getAppProvidedEngines()
         .then(engines => {
           resolve({
             current: Services.search.defaultEngine.identifier,
             installed: engines.map(engine => engine.identifier),
           });
         })
         .catch(() => resolve({ installed: [], current: "" }));
     });
--- a/browser/components/newtab/lib/SearchShortcuts.jsm
+++ b/browser/components/newtab/lib/SearchShortcuts.jsm
@@ -59,17 +59,17 @@ async function getSearchFormURL(keyword)
   const engine = await Services.search.getEngineByAlias(keyword);
   return engine?.wrappedJSObject._searchForm;
 }
 this.getSearchFormURL = getSearchFormURL;
 
 // Check topsite against predefined list of valid search engines
 // https://searchfox.org/mozilla-central/rev/ca869724246f4230b272ed1c8b9944596e80d920/toolkit/components/search/nsSearchService.js#939
 async function checkHasSearchEngine(keyword) {
-  return (await Services.search.getDefaultEngines()).find(e =>
+  return (await Services.search.getAppProvidedEngines()).find(e =>
     e.aliases.includes(keyword)
   );
 }
 this.checkHasSearchEngine = checkHasSearchEngine;
 
 const EXPORTED_SYMBOLS = [
   "checkHasSearchEngine",
   "getSearchProvider",
--- a/browser/components/newtab/lib/TopSitesFeed.jsm
+++ b/browser/components/newtab/lib/TopSitesFeed.jsm
@@ -777,17 +777,17 @@ this.TopSitesFeed = class TopSitesFeed {
     }
 
     if (!this._tippyTopProvider.initialized) {
       await this._tippyTopProvider.init();
     }
 
     // Populate the state with available search shortcuts
     let searchShortcuts = [];
-    for (const engine of await Services.search.getDefaultEngines()) {
+    for (const engine of await Services.search.getAppProvidedEngines()) {
       const shortcut = CUSTOM_SEARCH_SHORTCUTS.find(s =>
         engine.aliases.includes(s.keyword)
       );
       if (shortcut) {
         let clone = { ...shortcut };
         await this._attachTippyTopIconForSearchShortcut(clone, clone.keyword);
         searchShortcuts.push(clone);
       }
--- a/browser/components/newtab/test/browser/browser_asrouter_targeting.js
+++ b/browser/components/newtab/test/browser/browser_asrouter_targeting.js
@@ -301,17 +301,17 @@ add_task(async function check_needsUpdat
     await ASRouterTargeting.findMatchingMessage({ messages: [message] }),
     null,
     "Should not select message because update count == 0"
   );
 });
 
 add_task(async function checksearchEngines() {
   const result = await ASRouterTargeting.Environment.searchEngines;
-  const expectedInstalled = (await Services.search.getDefaultEngines())
+  const expectedInstalled = (await Services.search.getAppProvidedEngines())
     .map(engine => engine.identifier)
     .sort()
     .join(",");
   ok(
     result.installed.length,
     "searchEngines.installed should be a non-empty array"
   );
   is(
@@ -339,17 +339,17 @@ add_task(async function checksearchEngin
     await ASRouterTargeting.findMatchingMessage({ messages: [message] }),
     message,
     "should select correct item by searchEngines.current"
   );
 
   const message2 = {
     id: "foo",
     targeting: `searchEngines[${
-      (await Services.search.getDefaultEngines())[0].identifier
+      (await Services.search.getAppProvidedEngines())[0].identifier
     } in .installed]`,
   };
   is(
     await ASRouterTargeting.findMatchingMessage({ messages: [message2] }),
     message2,
     "should select correct item by searchEngines.installed"
   );
 });
--- a/browser/components/newtab/test/unit/lib/TopSitesFeed.test.js
+++ b/browser/components/newtab/test/unit/lib/TopSitesFeed.test.js
@@ -1480,17 +1480,17 @@ describe("Top Sites Feed", () => {
       feed.store.state.Prefs.values[SEARCH_SHORTCUTS_EXPERIMENT_PREF] = true;
       feed.store.state.Prefs.values[SEARCH_SHORTCUTS_SEARCH_ENGINES_PREF] =
         "google,amazon";
       feed.store.state.Prefs.values[SEARCH_SHORTCUTS_HAVE_PINNED_PREF] = "";
       const searchEngines = [
         { aliases: ["@google"] },
         { aliases: ["@amazon"] },
       ];
-      global.Services.search.getDefaultEngines = async () => searchEngines;
+      global.Services.search.getAppProvidedEngines = async () => searchEngines;
       fakeNewTabUtils.pinnedLinks.pin = sinon
         .stub()
         .callsFake((site, index) => {
           fakeNewTabUtils.pinnedLinks.links[index] = site;
         });
     });
 
     it("should properly disable search improvements if the pref is off", async () => {
@@ -1732,17 +1732,17 @@ describe("Top Sites Feed", () => {
           fakeNewTabUtils.pinnedLinks.links.find(
             s => s && s.url === "https://amazon.com"
           )
         );
       });
 
       it("should not pin a shortcut if the corresponding search engine is not available", async () => {
         // Make Amazon search engine unavailable
-        global.Services.search.getDefaultEngines = async () => [
+        global.Services.search.getAppProvidedEngines = async () => [
           { aliases: ["@google"] },
         ];
         fakeNewTabUtils.pinnedLinks.links.fill(null);
         await feed._maybeInsertSearchShortcuts(
           fakeNewTabUtils.pinnedLinks.links
         );
         assert.notOk(
           fakeNewTabUtils.pinnedLinks.links.find(
--- a/browser/components/preferences/search.js
+++ b/browser/components/preferences/search.js
@@ -638,17 +638,17 @@ function onDragEngineStart(event) {
 function EngineStore() {
   let pref = Preferences.get("browser.search.hiddenOneOffs").value;
   this.hiddenList = pref ? pref.split(",") : [];
 
   this._engines = [];
   this._defaultEngines = [];
   Promise.all([
     Services.search.getVisibleEngines(),
-    Services.search.getDefaultEngines(),
+    Services.search.getAppProvidedEngines(),
   ]).then(([visibleEngines, defaultEngines]) => {
     for (let engine of visibleEngines) {
       this.addEngine(engine);
       gEngineView.rowCountChanged(gEngineView.lastIndex, 1);
     }
     this._defaultEngines = defaultEngines.map(this._cloneEngine, this);
     gSearchPane.buildDefaultEngineDropDowns();
 
--- a/browser/components/preferences/tests/browser_searchRestoreDefaults.js
+++ b/browser/components/preferences/tests/browser_searchRestoreDefaults.js
@@ -4,17 +4,17 @@
 const { SearchTestUtils } = ChromeUtils.import(
   "resource://testing-common/SearchTestUtils.jsm"
 );
 const { SearchUtils } = ChromeUtils.import(
   "resource://gre/modules/SearchUtils.jsm"
 );
 add_task(async function test_restore_functionality() {
   // Ensure no engines are hidden to begin with.
-  for (let engine of await Services.search.getDefaultEngines()) {
+  for (let engine of await Services.search.getAppProvidedEngines()) {
     if (engine.hidden) {
       engine.hidden = false;
     }
   }
 
   await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
 
   let doc = gBrowser.selectedBrowser.contentDocument;
@@ -27,17 +27,17 @@ add_task(async function test_restore_fun
 
   let updatedPromise = SearchTestUtils.promiseSearchNotification(
     SearchUtils.MODIFIED_TYPE.CHANGED,
     SearchUtils.TOPIC_ENGINE_MODIFIED
   );
 
   let tree = doc.querySelector("#engineList");
   // Check for default search engines to be displayed in the engineList
-  let defaultEngines = await Services.search.getDefaultEngines();
+  let defaultEngines = await Services.search.getAppProvidedEngines();
   for (let i = 0; i < defaultEngines.length; i++) {
     let cellName = tree.view.getCellText(
       i,
       tree.columns.getNamedColumn("engineName")
     );
     if (cellName == "DuckDuckGo") {
       tree.view.selection.select(i);
       break;
--- a/toolkit/components/search/SearchService.jsm
+++ b/toolkit/components/search/SearchService.jsm
@@ -1412,17 +1412,17 @@ SearchService.prototype = {
   },
 
   async getVisibleEngines() {
     await this.init(true);
     logConsole.debug("getVisibleEngines: getting all visible engines");
     return this._getSortedEngines(false);
   },
 
-  async getDefaultEngines() {
+  async getAppProvidedEngines() {
     await this.init();
 
     return this._sortEnginesByDefaults(
       this._sortedEngines.filter(e => e.isAppProvided)
     );
   },
 
   async getEnginesByExtensionID(extensionID) {
--- a/toolkit/components/search/nsISearchService.idl
+++ b/toolkit/components/search/nsISearchService.idl
@@ -323,17 +323,17 @@ interface nsISearchService : nsISupports
    *
    * @param extension
    *        The extension to load from.
    * @returns Promise that resolves when finished.
    */
   Promise addEnginesFromExtension(in jsval extension);
 
   /**
-   * Un-hides all engines in the set of engines returned by getDefaultEngines.
+   * Un-hides all engines in the set of engines returned by getAppProvidedEngines.
    */
   void restoreDefaultEngines();
 
   /**
    * Returns an engine with the specified alias.
    *
    * @param   alias
    *          The search engine's alias.
@@ -371,17 +371,17 @@ interface nsISearchService : nsISupports
 
   /**
    * Returns an array of all default search engines. This includes all loaded
    * engines that aren't in the user's profile directory.
    * The array is sorted to the default order.
    *
    * @returns an array of nsISearchEngine objects.
    */
-  Promise getDefaultEngines();
+  Promise getAppProvidedEngines();
 
   /**
    * Returns an array of search engines installed by a given extension.
    *
    * @returns an array of nsISearchEngine objects.
    */
   Promise getEnginesByExtensionID(in AString extensionID);
 
--- a/toolkit/components/search/tests/xpcshell/test_maybereloadengine_order.js
+++ b/toolkit/components/search/tests/xpcshell/test_maybereloadengine_order.js
@@ -22,21 +22,21 @@ add_task(async function setup() {
 });
 
 add_task(async function basic_multilocale_test() {
   let resolver;
   let initPromise = new Promise(resolve => (resolver = resolve));
   useCustomGeoServer("FR", initPromise);
 
   await Services.search.init();
-  await Services.search.getDefaultEngines();
+  await Services.search.getAppProvidedEngines();
   resolver();
   await SearchTestUtils.promiseSearchNotification("engines-reloaded");
 
-  let engines = await Services.search.getDefaultEngines();
+  let engines = await Services.search.getAppProvidedEngines();
 
   Assert.deepEqual(
     engines.map(e => e._name),
     ["Special", "Plain"],
     "Special engine is default so should be first"
   );
 
   engines.forEach(engine => {
--- a/toolkit/components/search/tests/xpcshell/test_reload_engines.js
+++ b/toolkit/components/search/tests/xpcshell/test_reload_engines.js
@@ -161,17 +161,17 @@ add_task(async function setup() {
 
 // This is to verify that the loaded configuration matches what we expect for
 // the test.
 add_task(async function test_initial_config_correct() {
   Region._setHomeRegion("", false);
 
   await Services.search.init();
 
-  const installedEngines = await Services.search.getDefaultEngines();
+  const installedEngines = await Services.search.getAppProvidedEngines();
   Assert.deepEqual(
     installedEngines.map(e => e.identifier),
     [
       "engine",
       "engine-chromeicon",
       "engine-pref",
       "engine-rel-searchform-purpose",
       "engine-resourceicon",
@@ -244,17 +244,17 @@ add_task(async function test_config_upda
   );
 
   Assert.deepEqual(
     enginesRemoved,
     ["engine-rel-searchform-purpose", "engine-resourceicon"],
     "Should have removed the expected engine"
   );
 
-  const installedEngines = await Services.search.getDefaultEngines();
+  const installedEngines = await Services.search.getAppProvidedEngines();
 
   Assert.deepEqual(
     installedEngines.map(e => e.identifier),
     [
       "engine-pref",
       "engine-resourceicon-gd",
       "engine-chromeicon",
       "engine-same-name-gd",
--- a/toolkit/components/search/tests/xpcshell/test_reload_engines_experiment.js
+++ b/toolkit/components/search/tests/xpcshell/test_reload_engines_experiment.js
@@ -69,17 +69,17 @@ add_task(async function setup() {
   await AddonTestUtils.promiseStartupManager();
 });
 
 // This is to verify that the loaded configuration matches what we expect for
 // the test.
 add_task(async function test_initial_config_correct() {
   await Services.search.init();
 
-  const installedEngines = await Services.search.getDefaultEngines();
+  const installedEngines = await Services.search.getAppProvidedEngines();
   Assert.deepEqual(
     installedEngines.map(e => e.identifier),
     ["engine", "engine-same-name-en"],
     "Should have the correct list of engines installed."
   );
 
   Assert.equal(
     (await Services.search.getDefault()).identifier,
@@ -127,17 +127,17 @@ add_task(async function test_config_upda
   );
 
   Assert.deepEqual(
     enginesRemoved,
     [],
     "Should have removed the expected engine"
   );
 
-  const installedEngines = await Services.search.getDefaultEngines();
+  const installedEngines = await Services.search.getAppProvidedEngines();
 
   Assert.deepEqual(
     installedEngines.map(e => e.identifier),
     ["engine", "engine-same-name-gd"],
     "Should have the correct list of engines installed in the expected order."
   );
 
   const engineWithSameName = await Services.search.getEngineByName(
--- a/toolkit/components/search/tests/xpcshell/test_selectedEngine.js
+++ b/toolkit/components/search/tests/xpcshell/test_selectedEngine.js
@@ -95,17 +95,17 @@ add_task(async function test_resetToOrig
 
   Services.search.resetToOriginalDefaultEngine();
   Assert.equal(Services.search.defaultEngine.name, kDefaultEngineName);
   await promiseAfterSettings();
 });
 
 add_task(async function test_fallback_kept_after_restart() {
   // Set current engine to a default engine that isn't the original default.
-  let builtInEngines = await Services.search.getDefaultEngines();
+  let builtInEngines = await Services.search.getAppProvidedEngines();
   let nonDefaultBuiltInEngine;
   for (let engine of builtInEngines) {
     if (engine.name != kDefaultEngineName) {
       nonDefaultBuiltInEngine = engine;
       break;
     }
   }
   await Services.search.setDefault(nonDefaultBuiltInEngine);
--- a/toolkit/components/search/tests/xpcshell/test_sort_orders-no-hints.js
+++ b/toolkit/components/search/tests/xpcshell/test_sort_orders-no-hints.js
@@ -56,15 +56,15 @@ add_task(async function test_engine_sort
     "engine-rel-searchform-purpose",
     // Alphabetical order for the remaining engines without orderHint.
     "engine-pref",
     "engine-resourceicon",
     "Test search engine (Reordered)",
   ];
 
   // We should still have the same built-in engines listed.
-  await checkOrder("getDefaultEngines", EXPECTED_ORDER);
+  await checkOrder("getAppProvidedEngines", EXPECTED_ORDER);
 
   const expected = [...EXPECTED_ORDER];
   // This is inserted in alphabetical order for the last three.
   expected.splice(expected.length - 1, 0, "nonbuiltin1");
   await checkOrder("getEngines", expected);
 });
--- a/toolkit/components/search/tests/xpcshell/test_sort_orders.js
+++ b/toolkit/components/search/tests/xpcshell/test_sort_orders.js
@@ -49,17 +49,17 @@ async function checkOrder(type, expected
   Assert.deepEqual(
     sortedEngines.map(s => s.name),
     expectedOrder,
     `Should have the expected engine order from ${type}`
   );
 }
 
 add_task(async function test_engine_sort_only_builtins() {
-  await checkOrder("getDefaultEngines", EXPECTED_ORDER);
+  await checkOrder("getAppProvidedEngines", EXPECTED_ORDER);
   await checkOrder("getEngines", EXPECTED_ORDER);
 });
 
 add_task(async function test_engine_sort_with_non_builtins_sort() {
   await Services.search.addEngineWithDetails("nonbuiltin1", {
     method: "get",
     template: "http://example.com/?search={searchTerms}",
   });
@@ -67,17 +67,17 @@ add_task(async function test_engine_sort
   // As we've added an engine, the pref will have been set to true, but
   // we do really want to test the default sort.
   Services.search.wrappedJSObject._settings.setAttribute(
     "useSavedOrder",
     false
   );
 
   // We should still have the same built-in engines listed.
-  await checkOrder("getDefaultEngines", EXPECTED_ORDER);
+  await checkOrder("getAppProvidedEngines", EXPECTED_ORDER);
 
   const expected = [...EXPECTED_ORDER];
   expected.splice(EXPECTED_ORDER.length, 0, "nonbuiltin1");
   await checkOrder("getEngines", expected);
 });
 
 add_task(async function test_engine_sort_with_locale() {
   await promiseSetLocale("gd");
@@ -85,12 +85,12 @@ add_task(async function test_engine_sort
   const expected = [
     "engine-resourceicon-gd",
     "engine-pref",
     "engine-rel-searchform-purpose",
     "engine-chromeicon",
     "Test search engine (Reordered)",
   ];
 
-  await checkOrder("getDefaultEngines", expected);
+  await checkOrder("getAppProvidedEngines", expected);
   expected.push("nonbuiltin1");
   await checkOrder("getEngines", expected);
 });
--- a/toolkit/components/search/tests/xpcshell/test_webextensions_normandy_upgrade.js
+++ b/toolkit/components/search/tests/xpcshell/test_webextensions_normandy_upgrade.js
@@ -25,17 +25,17 @@ const CONFIG_UPDATED = [
   },
   {
     webExtension: { id: "example@search.mozilla.org" },
     appliesTo: [{ included: { everywhere: true } }],
   },
 ];
 
 async function getEngineNames() {
-  let engines = await Services.search.getDefaultEngines();
+  let engines = await Services.search.getAppProvidedEngines();
   return engines.map(engine => engine._name);
 }
 
 add_task(async function setup() {
   await SearchTestUtils.useTestEngines("test-extensions", null, CONFIG_DEFAULT);
   await AddonTestUtils.promiseStartupManager();
   registerCleanupFunction(AddonTestUtils.promiseShutdownManager);
   SearchTestUtils.useMockIdleService();