Bug 623207 - Add-ons manager last updated date and sorting bar should be removed from list view. r=Mossop a=b
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 18 Jan 2011 14:11:22 +1300
changeset 61264 2b66675f6750bbe48262a29861e510280fbe5574
parent 61263 7252a4d4e94344553a97545b5d86c3c98ae78496
child 61265 42847b167826859cb709e38af0ee9832c0a6ad61
push id18283
push userdgottwald@mozilla.com
push dateTue, 25 Jan 2011 14:29:10 +0000
treeherdermozilla-central@2b66675f6750 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMossop, b
bugs623207
milestone2.0b10pre
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 623207 - Add-ons manager last updated date and sorting bar should be removed from list view. r=Mossop a=b
toolkit/mozapps/extensions/content/extensions.css
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/content/extensions.xul
toolkit/mozapps/extensions/test/browser/browser_recentupdates.js
toolkit/mozapps/extensions/test/browser/browser_searching.js
toolkit/mozapps/extensions/test/browser/browser_sorting.js
--- a/toolkit/mozapps/extensions/content/extensions.css
+++ b/toolkit/mozapps/extensions/content/extensions.css
@@ -128,16 +128,23 @@ xhtml|link {
 #detail-view[active="true"] .disabled-postfix,
 #detail-view[loading] .detail-view-container,
 #detail-view:not([loading]) .alert-container,
 .detail-row:not([value]),
 #search-list[remote="false"] #search-allresults-link {
   display: none;
 }
 
+#addons-page:not([warning]) #list-view > .global-warning-container {
+  display: none;
+}
+#addon-list .date-updated {
+  display: none;
+}
+
 .view-pane:not(#updates-view) .addon .relnotes-toggle,
 .view-pane:not(#updates-view) .addon .include-update,
 #updates-view:not([updatetype="available"]) .addon .include-update,
 #updates-view[updatetype="available"] .addon .update-available-notice {
   display: none;
 }
 
 #addons-page:not([warning]) .global-warning,
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -2020,23 +2020,20 @@ var gSearchView = {
   }
 };
 
 
 var gListView = {
   node: null,
   _listBox: null,
   _emptyNotice: null,
-  _sorters: null,
   _type: null,
 
   initialize: function() {
     this.node = document.getElementById("list-view");
-    this._sorters = document.getElementById("list-sorters");
-    this._sorters.handler = this;
     this._listBox = document.getElementById("addon-list");
     this._emptyNotice = document.getElementById("addon-list-empty");
 
     var self = this;
     this._listBox.addEventListener("keydown", function(aEvent) {
       if (aEvent.keyCode == aEvent.DOM_VK_ENTER ||
           aEvent.keyCode == aEvent.DOM_VK_RETURN) {
         var item = self._listBox.selectedItem;
@@ -2064,17 +2061,17 @@ var gListView = {
       for (let i = 0; i < aAddonsList.length; i++)
         elements.push(createItem(aAddonsList[i]));
 
       for (let i = 0; i < aInstallsList.length; i++)
         elements.push(createItem(aInstallsList[i], true));
 
       self.showEmptyNotice(elements.length == 0);
       if (elements.length > 0) {
-        sortElements(elements, self._sorters.sortBy, self._sorters.ascending);
+        sortElements(elements, "name", true);
         elements.forEach(function(aElement) {
           self._listBox.appendChild(aElement);
         });
       }
 
       gEventManager.registerInstallListener(self);
       gViewController.updateCommands();
       gViewController.notifyViewChanged();
--- a/toolkit/mozapps/extensions/content/extensions.xul
+++ b/toolkit/mozapps/extensions/content/extensions.xul
@@ -388,19 +388,16 @@
                        value="&warning.updatesecurity.label;"/>
               </hbox>
               <button class="button-link global-warning-updatesecurity"
                       label="&warning.updatesecurity.enable.label;"
                       tooltiptext="&warning.updatesecurity.enable.tooltip;"
                       command="cmd_enableUpdateSecurity"/>
               <spacer flex="5000"/> <!-- Necessary to allow the message to wrap -->
             </hbox>
-            <spacer flex="1"/>
-            <hbox id="list-sorters" class="sort-controls" sortby="name"
-                  ascending="true"/>
           </hbox>
           <vbox id="addon-list-empty" class="alert-container"
                 flex="1" hidden="true">
             <spacer class="alert-spacer-before"/>
             <vbox class="alert">
               <label value="&listEmpty.installed.label;"/>
               <button label="&listEmpty.button.label;" class="addon-control"
                       command="cmd_goToDiscoverPane"/>
--- a/toolkit/mozapps/extensions/test/browser/browser_recentupdates.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_recentupdates.js
@@ -62,31 +62,55 @@ add_test(function() {
     EventUtils.synthesizeMouse(menuitem, 2, 2, { }, gManagerWindow);
   }, false);
   EventUtils.synthesizeMouse(utilsBtn, 2, 2, { }, gManagerWindow);
 });
 
 
 add_test(function() {
   var updatesList = gManagerWindow.document.getElementById("updates-list");
-  var items = updatesList.getElementsByTagName("richlistitem");
-  var possible = ["addon1@tests.mozilla.org", "addon2@tests.mozilla.org", "addon3@tests.mozilla.org"];
-  var expected = ["addon2@tests.mozilla.org", "addon1@tests.mozilla.org"];
-  for (let i = 0; i < items.length; i++) {
-    let item = items[i];
-    let itemId = item.mAddon.id;
-    if (possible.indexOf(itemId) == -1)
-      continue; // skip over any other addons, such as shipped addons that would update on every build
-    isnot(expected.length, 0, "Should be expecting more items");
-    is(itemId, expected.shift(), "Should get expected item based on recentness of update");
-    if (itemId == "addon1@tests.mozilla.org")
-      is_element_visible(item._relNotesToggle, "Release notes toggle should be visible for addon with release notes");
-    else
-      is_element_hidden(item._relNotesToggle, "Release notes toggle should be hidden for addon with no release notes");
+  var sorters = gManagerWindow.document.getElementById("updates-sorters");
+  var dateSorter = gManagerWindow.document.getAnonymousElementByAttribute(sorters, "anonid", "date-btn");
+  var nameSorter = gManagerWindow.document.getAnonymousElementByAttribute(sorters, "anonid", "name-btn");
+
+  function check_order(expected) {
+    var items = updatesList.getElementsByTagName("richlistitem");
+    var possible = ["addon1@tests.mozilla.org", "addon2@tests.mozilla.org", "addon3@tests.mozilla.org"];
+    for (let i = 0; i < items.length; i++) {
+      let item = items[i];
+      let itemId = item.mAddon.id;
+      if (possible.indexOf(itemId) == -1)
+        continue; // skip over any other addons, such as shipped addons that would update on every build
+      isnot(expected.length, 0, "Should be expecting more items");
+      is(itemId, expected.shift(), "Should get expected item based on sort order");
+      if (itemId == "addon1@tests.mozilla.org")
+        is_element_visible(item._relNotesToggle, "Release notes toggle should be visible for addon with release notes");
+      else
+        is_element_hidden(item._relNotesToggle, "Release notes toggle should be hidden for addon with no release notes");
+    }
   }
+
+  is_element_visible(dateSorter);
+  is_element_visible(nameSorter);
+
+  // sorted by date, descending
+  check_order(["addon2@tests.mozilla.org", "addon1@tests.mozilla.org"]);
+
+  // sorted by date, ascending
+  EventUtils.synthesizeMouseAtCenter(dateSorter, { }, gManagerWindow);
+  check_order(["addon1@tests.mozilla.org", "addon2@tests.mozilla.org"]);
+
+  // sorted by name, ascending
+  EventUtils.synthesizeMouseAtCenter(nameSorter, { }, gManagerWindow);
+  check_order(["addon2@tests.mozilla.org", "addon1@tests.mozilla.org"]);
+
+  // sorted by name, descending
+  EventUtils.synthesizeMouseAtCenter(nameSorter, { }, gManagerWindow);
+  check_order(["addon1@tests.mozilla.org", "addon2@tests.mozilla.org"]);
+
   run_next_test();
 });
 
 
 add_test(function() {
   close_manager(gManagerWindow, function() {
     open_manager(null, function(aWindow) {
       gManagerWindow = aWindow;
--- a/toolkit/mozapps/extensions/test/browser/browser_searching.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_searching.js
@@ -474,21 +474,23 @@ add_test(function() {
   var buttonIds = ["name-btn", "date-btn"];
   var currentIndex = 0;
   var currentReversed = false;
 
   function run_sort_test() {
     if (currentIndex >= sorterNames.length) {
       sorters.handler = originalHandler;
       run_next_test();
+      return;
     }
 
     // Simulate clicking on a specific sorter
     var buttonId = buttonIds[currentIndex];
     var sorter = getAnonymousElementByAttribute(sorters, "anonid", buttonId);
+    is_element_visible(sorter);
     EventUtils.synthesizeMouseAtCenter(sorter, { }, gManagerWindow);
   }
 
   sorters.handler = {
     onSortChanged: function(aSortBy, aAscending) {
       if (originalHandler && "onSortChanged" in originalHandler)
         originalHandler.onSortChanged(aSortBy, aAscending);
 
--- a/toolkit/mozapps/extensions/test/browser/browser_sorting.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_sorting.js
@@ -1,13 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-// Tests that sorting of add-ons in the list views works correctly
+// Tests that sorting of add-ons works correctly
+// (this test uses the list view, even though it no longer has sort buttons - see bug 623207)
 
 var gManagerWindow;
 var gProvider;
 
 function test() {
   waitForExplicitFinish();
 
   gProvider = new MockProvider();
@@ -49,16 +50,30 @@ function test() {
 }
 
 function end_test() {
   close_manager(gManagerWindow, function() {
     finish();
   });
 }
 
+function set_order(aSortBy, aAscending) {
+  var list = gManagerWindow.document.getElementById("addon-list");
+  var elements = [];
+  var node = list.firstChild;
+  while (node) {
+    elements.push(node);
+    node = node.nextSibling;
+  }
+  gManagerWindow.sortElements(elements, aSortBy, aAscending);
+  elements.forEach(function(aElement) {
+    list.appendChild(aElement);
+  });
+}
+
 function check_order(aExpectedOrder) {
   var order = [];
   var list = gManagerWindow.document.getElementById("addon-list");
   var node = list.firstChild;
   while (node) {
     var id = node.getAttribute("value");
     if (id && id.substring(id.length - 18) == "@tests.mozilla.org")
       order.push(node.getAttribute("value"));
@@ -76,41 +91,57 @@ add_test(function() {
     "test3@tests.mozilla.org",
     "test5@tests.mozilla.org",
     "test1@tests.mozilla.org"
   ]);
 
   run_next_test();
 });
 
-// Tests that switching to date ordering works and defaults to descending
+// Tests that switching to date ordering works
 add_test(function() {
-  var sorters = gManagerWindow.document.getElementById("list-sorters");
-  var nameSorter = gManagerWindow.document.getAnonymousElementByAttribute(sorters, "anonid", "date-btn");
-  EventUtils.synthesizeMouseAtCenter(nameSorter, { }, gManagerWindow);
+  set_order("updateDate", false);
 
   check_order([
     "test5@tests.mozilla.org",
     "test3@tests.mozilla.org",
     "test1@tests.mozilla.org",
     "test2@tests.mozilla.org",
     "test4@tests.mozilla.org"
   ]);
 
+  set_order("updateDate", true);
+
+  check_order([
+    "test4@tests.mozilla.org",
+    "test2@tests.mozilla.org",
+    "test1@tests.mozilla.org",
+    "test3@tests.mozilla.org",
+    "test5@tests.mozilla.org"
+  ]);
+
   run_next_test();
 });
 
-// Tests that switching to name ordering works and defaults to ascending
+// Tests that switching to name ordering works
 add_test(function() {
-  var sorters = gManagerWindow.document.getElementById("list-sorters");
-  var nameSorter = gManagerWindow.document.getAnonymousElementByAttribute(sorters, "anonid", "name-btn");
-  EventUtils.synthesizeMouseAtCenter(nameSorter, { }, gManagerWindow);
+  set_order("name", true);
 
   check_order([
     "test2@tests.mozilla.org",
     "test4@tests.mozilla.org",
     "test3@tests.mozilla.org",
     "test5@tests.mozilla.org",
     "test1@tests.mozilla.org"
   ]);
 
+  set_order("name", false);
+
+  check_order([
+    "test1@tests.mozilla.org",
+    "test5@tests.mozilla.org",
+    "test3@tests.mozilla.org",
+    "test4@tests.mozilla.org",
+    "test2@tests.mozilla.org"
+  ]);
+
   run_next_test();
 });