Bug 1238286 - Searchbar placed in Australis Menu doesn't detect search plugins if Menu wasn't opened in the window, r=adw.
authorFlorian Quèze <florian@queze.net>
Mon, 11 Apr 2016 15:07:27 +0200
changeset 330844 82517993e1ccf54ad179e21b35553f7c7e31be5f
parent 330843 61e7426512e5cdc825615fd0b8dcc2f14b580d20
child 330845 8606adea8d2e5133ee631d556c5e3852e5592d50
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1238286
milestone48.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 1238286 - Searchbar placed in Australis Menu doesn't detect search plugins if Menu wasn't opened in the window, r=adw.
accessible/tests/mochitest/events/test_focus_autocomplete.xul
accessible/tests/mochitest/states/test_expandable.xul
browser/base/content/browser.js
browser/components/search/content/search.xml
--- a/accessible/tests/mochitest/events/test_focus_autocomplete.xul
+++ b/accessible/tests/mochitest/events/test_focus_autocomplete.xul
@@ -30,24 +30,28 @@
   <script type="application/javascript"
           src="../autocomplete.js" />
 
   <script type="application/javascript">
   <![CDATA[
     ////////////////////////////////////////////////////////////////////////////
     // Hacky stuffs
 
-    // This is the hack needed for searchbar work outside of browser.
+    // This is the hacks needed to use a searchbar without browser.js.
     function getBrowser()
     {
       return {
         mCurrentBrowser: { engines: new Array() }
       };
     }
 
+    var BrowserSearch = {
+      updateOpenSearchBadge: function() {}
+    };
+
     ////////////////////////////////////////////////////////////////////////////
     // Invokers
 
     function loadFormAutoComplete(aIFrameID)
     {
       this.iframeNode = getNode(aIFrameID);
       this.iframe = getAccessible(aIFrameID);
 
--- a/accessible/tests/mochitest/states/test_expandable.xul
+++ b/accessible/tests/mochitest/states/test_expandable.xul
@@ -57,23 +57,26 @@
       {
         // unregister 'test-a11y-search' autocomplete search
         shutdownAutoComplete();
       }
 
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
-    // This is the hack needed for searchbar work outside of browser.
+    // This is the hacks needed to use a searchbar without browser.js.
     function getBrowser()
     {
       return {
         mCurrentBrowser: { engines: new Array() }
       };
     }
+    var BrowserSearch = {
+      updateOpenSearchBadge: function() {}
+    };
 
     SimpleTest.waitForExplicitFinish();
 
     // Register 'test-a11y-search' autocomplete search.
     // XPFE AutoComplete needs to register early.
     initAutoComplete([ "hello", "hi" ],
                      [ "Beep beep'm beep beep yeah", "Baby you can drive my car" ]);
 
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3404,19 +3404,16 @@ const DOMLinkHandler = {
       return;
 
     BrowserSearch.addEngine(aBrowser, aEngine, makeURI(aURL));
   },
 }
 
 const BrowserSearch = {
   addEngine: function(browser, engine, uri) {
-    if (!this.searchBar)
-      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
@@ -3444,21 +3441,17 @@ const BrowserSearch = {
 
   /**
    * Update the browser UI to show whether or not additional engines are
    * available when a page is loaded or the user switches tabs to a page that
    * has search engines.
    */
   updateOpenSearchBadge: function() {
     var searchBar = this.searchBar;
-
-    // The search bar binding might not be applied even though the element is
-    // in the document (e.g. when the navigation toolbar is hidden), so check
-    // for .textbox specifically.
-    if (!searchBar || !searchBar.textbox)
+    if (!searchBar)
       return;
 
     var engines = gBrowser.selectedBrowser.engines;
     if (engines && engines.length > 0)
       searchBar.setAttribute("addengines", "true");
     else
       searchBar.removeAttribute("addengines");
   },
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -76,16 +76,17 @@
         Services.search.init((function search_init_cb(aStatus) {
           // Bail out if the binding's been destroyed
           if (!this._initialized)
             return;
 
           if (Components.isSuccessCode(aStatus)) {
             // Refresh the display (updating icon, etc)
             this.updateDisplay();
+            BrowserSearch.updateOpenSearchBadge();
           } else {
             Components.utils.reportError("Cannot initialize search service, bailing out: " + aStatus);
           }
         }).bind(this));
       ]]></constructor>
 
       <destructor><![CDATA[
         this.destroy();