Bug 495511 - Remove All Cookies button is enabled when no cookies are present. r=jwein
authorJavi Rueda <leofigueres@yahoo.com>
Wed, 19 Oct 2011 11:18:29 -0400
changeset 78888 4d5244c0a0def3475d55a137a7c86ed07c1f4e4c
parent 78887 7b05a3d1f56e054d21716fabaebd6076756020b0
child 78935 832ee3b6ca1fa2f23d2197969a59b13c75f298cc
push id238
push userjwein@mozilla.com
push dateWed, 19 Oct 2011 15:20:27 +0000
treeherderfx-team@4d5244c0a0de [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwein
bugs495511
milestone10.0a1
Bug 495511 - Remove All Cookies button is enabled when no cookies are present. r=jwein
browser/components/preferences/cookies.js
--- a/browser/components/preferences/cookies.js
+++ b/browser/components/preferences/cookies.js
@@ -84,16 +84,18 @@ var gCookiesWindow = {
           window.arguments[0].filterString)
         this.setFilter(window.arguments[0].filterString);
     }
     else {
       if (document.getElementById("filter").value != "")
         this.filter();
     }
 
+    document.getElementById("removeAllCookies").disabled = this._view._rowCount == 0;
+
     this._saveState();
   },
 
   _cookieEquals: function (aCookieA, aCookieB, aStrippedHost) {
     return aCookieA.rawHost == aStrippedHost &&
            aCookieA.name == aCookieB.name &&
            aCookieA.path == aCookieB.path;
   },
@@ -112,16 +114,17 @@ var gCookiesWindow = {
     else if (aData == "cleared") {
       this._hosts = {};
       this._hostOrder = [];
 
       var oldRowCount = this._view._rowCount;
       this._view._rowCount = 0;
       this._tree.treeBoxObject.rowCountChanged(0, -oldRowCount);
       this._view.selection.clearSelection();
+      document.getElementById("removeAllCookies").disabled = true;
     }
     else if (aData == "reload") {
       // first, clear any existing entries
       this.observe(aCookie, aTopic, "cleared");
 
       // then, reload the list
       this._populateList(false);
     }
@@ -202,17 +205,20 @@ var gCookiesWindow = {
       }
     }
     // Now update the tree display at the end (we could/should re run the sort
     // if any to get the position correct.)
     var oldRowCount = this._rowCount;
     this._view._rowCount += rowCountImpact;
     this._tree.treeBoxObject.rowCountChanged(oldRowCount - 1, rowCountImpact);
 
-    document.getElementById("removeAllCookies").disabled = this._view._filtered;
+    if (this._view._rowCount > 0 && !this._view._filtered)
+      document.getElementById("removeAllCookies").disabled = false;
+    else
+      document.getElementById("removeAllCookies").disabled = true;
   },
 
   _view: {
     _filtered   : false,
     _filterSet  : [],
     _filterValue: "",
     _rowCount   : 0,
     _cacheValid : 0,