Bug 1548750 - Harden the search link added mechanisms and browser_tooManyEnginesOffered.js against the search service initialisation not having completed yet. r=mikedeboer
authorMark Banner <standard8@mozilla.com>
Tue, 07 May 2019 10:51:44 +0000
changeset 531690 4a3a0cf2e77aeedd4542f8f05925304d926949a6
parent 531689 b103cb0209658d6cfc248502606520fd140de56c
child 531691 09970391563cc7f319b26c9634d0c4addbb80136
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1548750
milestone68.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 1548750 - Harden the search link added mechanisms and browser_tooManyEnginesOffered.js against the search service initialisation not having completed yet. r=mikedeboer Differential Revision: https://phabricator.services.mozilla.com/D29807
browser/base/content/browser.js
browser/components/search/test/browser/browser_tooManyEnginesOffered.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -4149,16 +4149,23 @@ const BrowserSearch = {
         [name], 1);
     } else {
       placeholder = gURLBar.getAttribute("defaultPlaceholder");
     }
     gURLBar.setAttribute("placeholder", placeholder);
   },
 
   addEngine(browser, engine, uri) {
+    if (!this._searchInitComplete) {
+      // We haven't finished initialising search yet. This means we can't
+      // call getEngineByName here. Since this is only on start-up and unlikely
+      // to happen in the normal case, we'll just return early rather than
+      // trying to handle it asynchronously.
+      return;
+    }
     // Check to see whether we've already added an engine with this title
     if (browser.engines) {
       if (browser.engines.some(e => e.title == engine.title))
         return;
     }
 
     var hidden = false;
     // If this engine (identified by title) is already in the list, add it
--- a/browser/components/search/test/browser/browser_tooManyEnginesOffered.js
+++ b/browser/components/search/test/browser/browser_tooManyEnginesOffered.js
@@ -4,16 +4,18 @@
 // popup shows a submenu that lists them instead of showing them in the popup
 // itself.
 
 const searchPopup = document.getElementById("PopupSearchAutoComplete");
 const oneOffsContainer = searchPopup.searchOneOffsContainer;
 
 add_task(async function test_setup() {
   await gCUITestUtils.addSearchBar();
+
+  await Services.search.init();
   registerCleanupFunction(() => {
     gCUITestUtils.removeSearchBar();
   });
 });
 
 add_task(async function test() {
   let searchbar = BrowserSearch.searchBar;