Bug 1327212 - undo a line removal done in bug 935521 that causes regressions. r?Gijs draft
authorMike de Boer <mdeboer@mozilla.com>
Sat, 07 Jan 2017 01:05:33 +0100
changeset 457167 0742ce47b11713b20df713b6e80b94664b1d9bc3
parent 456716 a14094edbad78fc1d16e8d4c57902537cf286fd1
child 541414 47129fda3ed7b0361af1cccff987528a88394de6
push id40702
push usermdeboer@mozilla.com
push dateSat, 07 Jan 2017 00:06:34 +0000
reviewersGijs
bugs1327212, 935521
milestone53.0a1
Bug 1327212 - undo a line removal done in bug 935521 that causes regressions. r?Gijs MozReview-Commit-ID: HaUEOSpEsXs
browser/base/content/test/general/browser_bug537013.js
toolkit/content/tests/chrome/findbar_window.xul
toolkit/content/widgets/findbar.xml
--- a/browser/base/content/test/general/browser_bug537013.js
+++ b/browser/base/content/test/general/browser_bug537013.js
@@ -122,14 +122,14 @@ function continueTests3() {
 
 // Test that findbar gets restored when a tab is moved to a new window.
 function checkNewWindow() {
   ok(!newWindow.gFindBar.hidden, "New window shows find bar!");
   // Disabled the following assertion due to intermittent failure on OSX 10.6 Debug.
   if (!HasFindClipboard) {
     is(newWindow.gFindBar._findField.value, texts[1],
        "New window find bar has correct find value!");
+    ok(!newWindow.gFindBar.getElement("find-next").disabled,
+       "New window findbar has disabled buttons!");
   }
-  ok(newWindow.gFindBar.getElement("find-next").disabled,
-     "New window findbar has disabled buttons!");
   newWindow.close();
   finish();
 }
--- a/toolkit/content/tests/chrome/findbar_window.xul
+++ b/toolkit/content/tests/chrome/findbar_window.xul
@@ -150,17 +150,21 @@
       yield testQuickFindClose();
       // TODO: This doesn't seem to work when the findbar is connected to a
       //       remote browser element.
       if (!gBrowser.hasAttribute("remote"))
         yield testFindAgainNotFound();
       yield testToggleEntireWord();
     }
 
-    function testFindButtonsState(enabled = true) {
+    function testFindButtonsState(enabled = null) {
+      // If `enabled` is not explicitly passed in, we set it to its most logical
+      // value.
+      if (enabled === null)
+        enabled = !!gFindBar._findField.value;
       is(gFindBar.getElement("find-next").disabled, !enabled,
         `Expected the 'next' button to be ${enabled ? 'enabled' : 'disabled'}`);
       is(gFindBar.getElement("find-previous").disabled, !enabled,
         `Expected the 'previous' button to be ${enabled ? 'enabled' : 'disabled'}`);
     }
 
     function* testFindbarSelection() {
       function checkFindbarState(aTestName, aExpSelection) {
--- a/toolkit/content/widgets/findbar.xml
+++ b/toolkit/content/widgets/findbar.xml
@@ -1092,17 +1092,18 @@
         ]]></body>
       </method>
 
       <method name="updateControlState">
         <parameter name="aResult"/>
         <parameter name="aFindPrevious"/>
         <body><![CDATA[
           this._updateStatusUI(aResult, aFindPrevious);
-          this._enableFindButtons(aResult !== this.nsITypeAheadFind.FIND_NOTFOUND);
+          this._enableFindButtons(aResult !== this.nsITypeAheadFind.FIND_NOTFOUND &&
+            !!this._findField.value);
         ]]></body>
       </method>
 
       <method name="_dispatchFindEvent">
         <parameter name="aType"/>
         <parameter name="aFindPrevious"/>
         <body><![CDATA[
           let event = document.createEvent("CustomEvent");
@@ -1341,16 +1342,17 @@
             if (clipboardSearchString)
               aSelectionString = clipboardSearchString;
           }
 
           if (aSelectionString)
             this._findField.value = aSelectionString;
 
           if (aIsInitialSelection) {
+            this._enableFindButtons(!!this._findField.value);
             this._findField.select();
             this._findField.focus();
 
             this._startFindDeferred.resolve();
             this._startFindDeferred = null;
           }
         ]]></body>
       </method>