Bug 601442 - Support the extensions.getAddons.showPane pref again in the Add-ons Manager UI. r=bmcbride

This commit is contained in:
Martin Stransky 2013-04-10 14:13:13 +12:00
Родитель 6f063ad221
Коммит 7e7dce558a
5 изменённых файлов: 78 добавлений и 4 удалений

Просмотреть файл

@ -206,3 +206,7 @@ richlistitem:not([selected]) * {
#header-search {
width: 22em;
}
.discover-button[disabled="true"] {
display: none;
}

Просмотреть файл

@ -19,6 +19,8 @@ Cu.import("resource://gre/modules/AddonRepository.jsm");
const PREF_DISCOVERURL = "extensions.webservice.discoverURL";
const PREF_DISCOVER_ENABLED = "extensions.getAddons.showPane";
const PREF_XPI_ENABLED = "xpinstall.enabled";
const PREF_MAXRESULTS = "extensions.getAddons.maxResults";
const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
const PREF_GETADDONS_CACHE_ID_ENABLED = "extensions.%ID%.getAddons.cache.enabled";
@ -143,6 +145,23 @@ function loadView(aViewId) {
}
}
function isDiscoverEnabled() {
if (Services.prefs.getPrefType(PREF_DISCOVERURL) == Services.prefs.PREF_INVALID)
return false;
try {
if (!Services.prefs.getBoolPref(PREF_DISCOVER_ENABLED))
return false;
} catch (e) {}
try {
if (!Services.prefs.getBoolPref(PREF_XPI_ENABLED))
return false;
} catch (e) {}
return true;
}
/**
* A wrapper around the HTML5 session history service that allows the browser
* back/forward controls to work within the manager
@ -1749,8 +1768,8 @@ var gDiscoverView = {
_loadListeners: [],
initialize: function gDiscoverView_initialize() {
if (Services.prefs.getPrefType(PREF_DISCOVERURL) == Services.prefs.PREF_INVALID) {
this.enabled = false;
this.enabled = isDiscoverEnabled();
if (!this.enabled) {
gCategories.get("addons://discover/").hidden = true;
return;
}

Просмотреть файл

@ -298,7 +298,9 @@
<spacer class="alert-spacer-before"/>
<vbox class="alert">
<label value="&listEmpty.search.label;"/>
<button label="&listEmpty.button.label;"
<button class="discover-button"
id="discover-button-search"
label="&listEmpty.button.label;"
command="cmd_goToDiscoverPane"/>
</vbox>
<spacer class="alert-spacer-after"/>
@ -358,7 +360,9 @@
<spacer class="alert-spacer-before"/>
<vbox class="alert">
<label value="&listEmpty.installed.label;"/>
<button label="&listEmpty.button.label;"
<button class="discover-button"
id="discover-button-install"
label="&listEmpty.button.label;"
command="cmd_goToDiscoverPane"/>
</vbox>
<spacer class="alert-spacer-after"/>

Просмотреть файл

@ -575,3 +575,48 @@ add_test(function() {
close_manager(gManagerWindow, run_next_test);
});
});
// Test for Bug 601442 - extensions.getAddons.showPane need to be update
// for the new addon manager.
function bug_601442_test_elements(visible) {
open_manager("addons://list/extension", function(aWindow) {
gManagerWindow = aWindow;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
if(visible)
ok(gCategoryUtilities.isTypeVisible("discover"), "Discover category should be visible");
else
ok(!gCategoryUtilities.isTypeVisible("discover"), "Discover category should not be visible");
gManagerWindow.loadView("addons://list/dictionary");
wait_for_view_load(gManagerWindow, function(aManager) {
var button = aManager.document.getElementById("discover-button-install");
if(visible)
ok(!is_hidden(button), "Discover button should be visible!");
else
ok(is_hidden(button), "Discover button should not be visible!");
close_manager(gManagerWindow, run_next_test);
});
});
}
add_test(function() {
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, false);
Services.prefs.setBoolPref(PREF_XPI_ENABLED, true);
bug_601442_test_elements(false);
});
add_test(function() {
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, true);
Services.prefs.setBoolPref(PREF_XPI_ENABLED, false);
bug_601442_test_elements(false);
});
add_test(function() {
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, false);
Services.prefs.setBoolPref(PREF_XPI_ENABLED, false);
bug_601442_test_elements(false);
});
add_test(function() {
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, true);
Services.prefs.setBoolPref(PREF_XPI_ENABLED, true);
bug_601442_test_elements(true);
});

Просмотреть файл

@ -25,6 +25,8 @@ const TESTROOT = "http://example.com/" + RELATIVE_DIR;
const TESTROOT2 = "http://example.org/" + RELATIVE_DIR;
const CHROMEROOT = pathParts.join("/") + "/";
const PREF_DISCOVERURL = "extensions.webservice.discoverURL";
const PREF_DISCOVER_ENABLED = "extensions.getAddons.showPane";
const PREF_XPI_ENABLED = "xpinstall.enabled";
const PREF_UPDATEURL = "extensions.update.url";
const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";