Backed out changeset 6fe388a0fb5e (Bug 581076) due to test failures. a=bustage

--HG--
extra : rebase_source : f726613cbce0938d25fd58a9547a5a25d15c1433
This commit is contained in:
Blair McBride 2010-08-30 17:35:21 +12:00
parent a6cf519b9f
commit d7ea82d234
10 changed files with 18 additions and 188 deletions

View File

@ -56,12 +56,13 @@ pref("browser.hiddenWindowChromeURL", "chrome://browser/content/hiddenWindow.xul
// Enables some extra Extension System Logging (can reduce performance)
pref("extensions.logging.enabled", false);
// Preferences for AMO integration
// Preferences for the Addon Repository
pref("extensions.getAddons.cache.enabled", true);
pref("extensions.getAddons.maxResults", 15);
pref("extensions.getAddons.get.url", "https://services.addons.mozilla.org/%LOCALE%/%APP%/api/%API_VERSION%/search/guid:%IDS%");
pref("extensions.getAddons.search.browseURL", "https://addons.mozilla.org/%LOCALE%/%APP%/search?q=%TERMS%");
pref("extensions.getAddons.search.url", "https://services.addons.mozilla.org/%LOCALE%/%APP%/api/%API_VERSION%/search/%TERMS%/all/%MAX_RESULTS%/%OS%/%VERSION%");
// Preferences for AMO integration
pref("extensions.webservice.discoverURL", "https://services.addons.mozilla.org/%LOCALE%/%APP%/discovery/%VERSION%/%OS%");
// Blocklist preferences

View File

@ -59,6 +59,3 @@ enableAddonTooltip=Enable this add-on
enableAddonRestartRequiredTooltip=Enable this add-on (restart required)
disableAddonTooltip=Disable this add-on
disableAddonRestartRequiredTooltip=Disable this add-on (restart required)
#LOCALIZATION NOTE (showAllSearchResults) #1 is the total number of search results
showAllSearchResults=See all #1 result;See all #1 results

View File

@ -100,8 +100,7 @@ xhtml|link {
.addon[active="true"] .disabled-postfix,
.addon[pending="install"] .update-postfix,
.addon[pending="install"] .disabled-postfix,
#detail-view[loading] > .detail-view-container,
#search-list[remote="false"] #search-allresults-link {
#detail-view[loading] > .detail-view-container {
display: none;
}

View File

@ -1150,9 +1150,7 @@ var gSearchView = {
_sorters: null,
_listBox: null,
_emptyNotice: null,
_allResultsLink: null,
_lastQuery: null,
_lastRemoteTotal: 0,
_pendingSearches: 0,
initialize: function() {
@ -1162,7 +1160,6 @@ var gSearchView = {
this._sorters.handler = this;
this._listBox = document.getElementById("search-list");
this._emptyNotice = document.getElementById("search-list-empty");
this._allResultsLink = document.getElementById("search-allresults-link");
var self = this;
this._listBox.addEventListener("keydown", function(aEvent) {
@ -1189,7 +1186,6 @@ var gSearchView = {
show: function(aQuery, aRequest) {
gHeader.isSearching = true;
this.showEmptyNotice(false);
this.showAllResultsLink(0);
gHeader.searchQuery = aQuery;
aQuery = aQuery.trim().toLocaleLowerCase();
@ -1203,8 +1199,8 @@ var gSearchView = {
if (AddonRepository.isSearching)
AddonRepository.cancelSearch();
while (this._listBox.firstChild.localName == "richlistitem")
this._listBox.removeChild(this._listBox.firstChild);
while (this._listBox.lastChild.localName == "richlistitem")
this._listBox.removeChild(this._listBox.lastChild);
var self = this;
gCachedAddons = {};
@ -1226,7 +1222,7 @@ var gSearchView = {
if (aIsRemote)
gCachedAddons[aObj.id] = aObj;
self._listBox.insertBefore(item, self._listBox.lastChild);
self._listBox.appendChild(item);
createdCount++;
});
@ -1268,8 +1264,6 @@ var gSearchView = {
if (gViewController && aRequest != gViewController.currentViewRequest)
return;
self._lastRemoteTotal = 0;
// XXXunf Better handling of AMO search failure. See bug 579502
finishSearch(0); // Silently fail
},
@ -1278,11 +1272,6 @@ var gSearchView = {
if (gViewController && aRequest != gViewController.currentViewRequest)
return;
if (aTotalResults > maxRemoteResults)
self._lastRemoteTotal = aTotalResults;
else
self._lastRemoteTotal = 0;
var createdCount = createSearchResults(aAddonsList, false, true);
finishSearch(createdCount);
}
@ -1307,7 +1296,6 @@ var gSearchView = {
}
this.showEmptyNotice(isEmpty);
this.showAllResultsLink(this._lastRemoteTotal);
}
gViewController.updateCommands();
@ -1368,24 +1356,9 @@ var gSearchView = {
this._emptyNotice.hidden = !aShow;
},
showAllResultsLink: function(aTotalResults) {
if (aTotalResults == 0) {
this._allResultsLink.hidden = true;
return;
}
var linkStr = gStrings.ext.GetStringFromName("showAllSearchResults");
linkStr = PluralForm.get(aTotalResults, linkStr);
linkStr = linkStr.replace("#1", aTotalResults);
this._allResultsLink.value = linkStr;
this._allResultsLink.href = AddonRepository.getSearchURL(this._lastQuery);
this._allResultsLink.hidden = false;
},
onSortChanged: function(aSortBy, aAscending) {
var footer = this._listBox.lastChild;
this._listBox.removeChild(footer);
var header = this._listBox.firstChild;
this._listBox.removeChild(header);
var hints = aAscending ? "ascending" : "descending";
if (INTEGER_FIELDS.indexOf(aSortBy) >= 0)
@ -1395,7 +1368,7 @@ var gSearchView = {
getService(Ci.nsIXULSortService);
sortService.sort(this._listBox, aSortBy, hints);
this._listBox.appendChild(footer);
this._listBox.insertBefore(header, this._listBox.firstChild);
},
getSelectedAddon: function() {

View File

@ -233,18 +233,15 @@
<hbox id="search-sorters" class="sort-controls"
showrelevance="true" sortby="relevancescore" ascending="false"/>
</hbox>
<vbox id="search-list-empty" class="empty-list-notice"
flex="1" hidden="true">
<spacer flex="1"/>
<label value="&listEmpty.search.label;"/>
<button label="&listEmpty.button.label;" class="addon-control"
command="cmd_goToDiscoverPane"/>
<spacer flex="3"/>
</vbox>
<richlistbox id="search-list" class="list" flex="1">
<hbox pack="center">
<label id="search-allresults-link" class="text-link"/>
</hbox>
<vbox id="search-list-empty" class="empty-list-notice"
flex="1" hidden="true">
<spacer flex="1"/>
<label value="&listEmpty.search.label;"/>
<button label="&listEmpty.button.label;" class="addon-control"
command="cmd_goToDiscoverPane"/>
<spacer flex="3"/>
</vbox>
</richlistbox>
</vbox>

View File

@ -60,7 +60,6 @@ _TEST_FILES = \
browser_bug567137.js \
browser_bug572561.js \
browser_bug577990.js \
browser_bug581076.js \
browser_dragdrop.js \
browser_list.js \
browser_searching.js \

View File

@ -1,121 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Bug 581076 - No "See all results" link present when searching for add-ons and not all are displayed (extensions.getAddons.maxResults)
const PREF_GETADDONS_BROWSESEARCHRESULTS = "extensions.getAddons.search.browseURL";
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
const PREF_GETADDONS_MAXRESULTS = "extensions.getAddons.maxResults";
const SEARCH_URL = TESTROOT + "browser_searching.xml";
const SEARCH_EXPECTED_TOTAL = 100;
const SEARCH_QUERY = "search";
var gManagerWindow;
function test() {
Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, SEARCH_URL);
Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
waitForExplicitFinish();
open_manager(null, function(aWindow) {
gManagerWindow = aWindow;
run_next_test();
});
}
function end_test() {
Services.prefs.clearUserPref(PREF_GETADDONS_GETSEARCHRESULTS);
close_manager(gManagerWindow, finish);
}
function search(aRemoteSearch, aCallback) {
var searchBox = gManagerWindow.document.getElementById("header-search");
searchBox.value = SEARCH_QUERY;
EventUtils.synthesizeMouse(searchBox, 2, 2, { }, gManagerWindow);
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
wait_for_view_load(gManagerWindow, function() {
if (aRemoteSearch)
var filter = gManagerWindow.document.getElementById("search-filter-remote");
else
var filter = gManagerWindow.document.getElementById("search-filter-local");
EventUtils.synthesizeMouse(filter, 2, 2, { }, gManagerWindow);
executeSoon(aCallback);
});
}
function check_allresultslink(aShouldShow) {
var list = gManagerWindow.document.getElementById("search-list");
var link = gManagerWindow.document.getElementById("search-allresults-link");
is(link.parentNode, list.lastChild, "Footer should be at the end of the richlistbox");
if (aShouldShow) {
is_element_visible(link, "All Results link should be visible");
is(link.value, "See all " + SEARCH_EXPECTED_TOTAL + " results", "All Results link should show the correct message");
var scope = {};
Components.utils.import("resource://gre/modules/AddonRepository.jsm", scope);
is(link.href, scope.AddonRepository.getSearchURL(SEARCH_QUERY), "All Results link should have the correct href");
} else {
is_element_hidden(link, "All Results link should be hidden");
}
}
add_test(function() {
info("Searching locally");
search(false, function() {
check_allresultslink(false);
restart_manager(gManagerWindow, null, function(aManager) {
gManagerWindow = aManager;
run_next_test();
});
});
});
add_test(function() {
info("Searching remotely - more results than cap");
Services.prefs.setIntPref(PREF_GETADDONS_MAXRESULTS, 3);
search(true, function() {
check_allresultslink(true);
restart_manager(gManagerWindow, null, function(aManager) {
gManagerWindow = aManager;
run_next_test();
});
});
});
add_test(function() {
info("Searching remotely - less results than cap");
Services.prefs.setIntPref(PREF_GETADDONS_MAXRESULTS, 200);
search(true, function() {
check_allresultslink(false);
restart_manager(gManagerWindow, null, function(aManager) {
gManagerWindow = aManager;
run_next_test();
});
});
});
add_test(function() {
info("Searching remotely - more results than cap");
Services.prefs.setIntPref(PREF_GETADDONS_MAXRESULTS, 3);
search(true, function() {
check_allresultslink(true);
run_next_test();
});
});
add_test(function() {
info("Switching views");
gManagerWindow.loadView("addons://list/extension");
wait_for_view_load(gManagerWindow, function() {
info("Re-loading previous search");
search(true, function() {
check_allresultslink(true);
run_next_test();
});
});
});

View File

@ -513,11 +513,6 @@
display: none;
}
#search-allresults-link {
margin-top: 1em;
margin-bottom: 2em;
}
/*** detail view ***/
#detail-view[active="false"] .fade {

View File

@ -537,11 +537,6 @@
display: none;
}
#search-allresults-link {
margin-top: 1em;
margin-bottom: 2em;
}
/*** detail view ***/
#detail-view[active="false"] .fade {

View File

@ -504,11 +504,6 @@
display: none;
}
#search-allresults-link {
margin-top: 1em;
margin-bottom: 2em;
}
/*** detail view ***/
#detail-view[active="false"] .fade {