Bug 1492475 - Part 11: Repair incorrect usage of the `identifier` property of nsISearchEngine instances. r=florian
authorMike de Boer <mdeboer@mozilla.com>
Tue, 20 Nov 2018 18:23:09 +0100
changeset 452873 ce5ba6901957903ade31888cdc6a52e2b828dac0
parent 452872 21b3aa17ee43dd0efd3c08564bbc7d747d4628b9
child 453219 75e096381ce04a472ff14a0344e0b5f70b165939
push id2
push usermdeboer@mozilla.com
push dateTue, 08 Jan 2019 17:01:21 +0000
reviewersflorian
bugs1492475
milestone66.0a1
Bug 1492475 - Part 11: Repair incorrect usage of the `identifier` property of nsISearchEngine instances. r=florian Differential Revision: https://phabricator.services.mozilla.com/D12451
browser/components/urlbar/tests/unit/head.js
toolkit/components/utils/ClientEnvironment.jsm
--- a/browser/components/urlbar/tests/unit/head.js
+++ b/browser/components/urlbar/tests/unit/head.js
@@ -151,17 +151,16 @@ function makeTestServer(port = -1) {
  */
 async function addTestEngine(basename, httpServer = undefined) {
   httpServer = httpServer || makeTestServer();
   httpServer.registerDirectory("/", do_get_cwd());
   let dataUrl =
     "http://localhost:" + httpServer.identity.primaryPort + "/data/";
 
   info("Adding engine: " + basename);
-  await new Promise(resolve => Services.search.init(resolve));
   return new Promise(resolve => {
     Services.obs.addObserver(function obs(subject, topic, data) {
       let engine = subject.QueryInterface(Ci.nsISearchEngine);
       info("Observed " + data + " for " + engine.name);
       if (data != "engine-added" || engine.name != basename) {
         return;
       }
 
--- a/toolkit/components/utils/ClientEnvironment.jsm
+++ b/toolkit/components/utils/ClientEnvironment.jsm
@@ -65,21 +65,18 @@ class ClientEnvironmentBase {
   }
 
   static get isDefaultBrowser() {
     return ShellService.isDefaultBrowser();
   }
 
   static get searchEngine() {
     return (async () => {
-      const searchInitialized = await Services.search.init();
-      if (Components.isSuccessCode(searchInitialized)) {
-        return Services.search.defaultEngine.identifier;
-      }
-      return null;
+      await TelemetryEnvironment.onInitialized();
+      return TelemetryEnvironment.currentEnvironment.settings.defaultSearchEngine;
     })();
   }
 
   static get syncSetup() {
     return Services.prefs.prefHasUserValue("services.sync.username");
   }
 
   static get syncDesktopDevices() {