Bug 611459 - Search should default to searching for available add-ons. r=dtownsend a=blocking-final
authorMehdi Mulani <mars.martian+bugmail@gmail.com>
Fri, 07 Jan 2011 14:21:38 -0800
changeset 60314 08babae55fb42852772e6ac0b383d58b283e3a73
parent 60313 3ce1c7e22e856f439960f63f7bdf798fe229155a
child 60315 14752eafce65b2c01f7ca246b56fbd846d233217
push idunknown
push userunknown
push dateunknown
reviewersdtownsend, blocking-final
bugs611459
milestone2.0b10pre
Bug 611459 - Search should default to searching for available add-ons. r=dtownsend a=blocking-final
toolkit/mozapps/extensions/content/extensions.xul
toolkit/mozapps/extensions/test/browser/browser_bug562797.js
--- a/toolkit/mozapps/extensions/content/extensions.xul
+++ b/toolkit/mozapps/extensions/content/extensions.xul
@@ -319,17 +319,17 @@
             </hbox>
             <spacer flex="1"/>
             <hbox id="search-sorters" class="sort-controls"
                   showrelevance="true" sortby="relevancescore" ascending="false"/>
           </hbox>
           <hbox id="search-filter" align="center">
             <label id="search-filter-label" value="&search.filter2.label;"/>
             <radiogroup id="search-filter-radiogroup" orient="horizontal"
-                        align="center" persist="value" value="local">
+                        align="center" persist="value" value="remote">
               <radio id="search-filter-local" class="search-filter-radio"
                      label="&search.filter2.installed.label;" value="local"
                      tooltiptext="&search.filter2.installed.tooltip;"/>
               <radio id="search-filter-remote" class="search-filter-radio"
                      label="&search.filter2.available.label;" value="remote"
                      tooltiptext="&search.filter2.available.tooltip;"/>
             </radiogroup>
           </hbox>
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
@@ -335,26 +335,56 @@ add_test(function() {
         }, false);
       });
     }, false);
   });
 });
 
 // Tests that going back to search results works
 add_test(function() {
+  // Before we open the add-ons manager, we should make sure that no filter
+  // has been set. If one is set, we remove it.
+  // This is for the check below, from bug 611459.
+  let RDF = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
+  let store = RDF.GetDataSource("rdf:local-store");
+  let filterResource = RDF.GetResource("about:addons#search-filter-radiogroup");
+  let filterProperty = RDF.GetResource("value");
+  let filterTarget = store.GetTarget(filterResource, filterProperty, true);
+
+  if (filterTarget) {
+    is(filterTarget instanceof Ci.nsIRDFLiteral, true,
+       "Filter should be a value");
+    store.Unassert(filterResource, filterProperty, filterTarget);
+  }
+
   open_manager("addons://list/extension", function(aManager) {
     info("Part 1");
     is_in_list(aManager, "addons://list/extension", false, false);
 
     var search = aManager.document.getElementById("header-search");
     search.focus();
     search.value = "bar";
     EventUtils.synthesizeKey("VK_RETURN", {}, aManager);
 
     wait_for_view_load(aManager, function(aManager) {
+      // Remote search is meant to be checked by default (bug 611459), so we
+      // confirm that and then switch to a local search.
+      var localFilter = aManager.document.getElementById("search-filter-local");
+      var remoteFilter = aManager.document.getElementById("search-filter-remote");
+
+      is(remoteFilter.selected, true, "Remote filter should be set by default");
+
+      var list = aManager.document.getElementById("search-list");
+      list.ensureElementIsVisible(localFilter);
+      EventUtils.synthesizeMouseAtCenter(localFilter, { }, aManager);
+
+      is(localFilter.selected, true, "Should have changed to local filter");
+
+      // Now we continue with the normal test.
+
       info("Part 2");
       is_in_search(aManager, "bar", true, false);
       check_all_in_list(aManager, ["test2@tests.mozilla.org", "test3@tests.mozilla.org"]);
 
       double_click_addon_element(aManager, "test2@tests.mozilla.org");
 
       wait_for_view_load(aManager, function(aManager) {
         info("Part 3");