Bug 1132971 - Don't assume that the add-ons discovery pane will be available, r=mossop

--HG--
extra : rebase_source : e5b1bf8b9d405ad491ed1e0d917714c64c8c3205
This commit is contained in:
Mike Kaply 2015-04-09 11:18:31 -05:00
Родитель 394fd4eee8
Коммит ddaf3b093b
3 изменённых файлов: 27 добавлений и 7 удалений

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

@ -51,7 +51,7 @@ const UPDATES_RELEASENOTES_TRANSFORMFILE = "chrome://mozapps/content/extensions/
const XMLURI_PARSE_ERROR = "http://www.mozilla.org/newlayout/xml/parsererror.xml"
const VIEW_DEFAULT = "addons://discover/";
var gViewDefault = "addons://discover/";
var gStrings = {};
XPCOMUtils.defineLazyServiceGetter(gStrings, "bundleSvc",
@ -124,6 +124,10 @@ function initialize(event) {
gHeader.onKeyPress(event);
});
if (!isDiscoverEnabled()) {
gViewDefault = "addons://list/extension";
}
gViewController.initialize();
gCategories.initialize();
gHeader.initialize();
@ -641,12 +645,12 @@ var gViewController = {
if (gHistory.canGoBack)
gHistory.back();
else
gViewController.replaceView(VIEW_DEFAULT);
gViewController.replaceView(gViewDefault);
} else {
if (gHistory.canGoForward)
gHistory.forward();
else
gViewController.replaceView(VIEW_DEFAULT);
gViewController.replaceView(gViewDefault);
}
}
},
@ -1673,7 +1677,7 @@ var gCategories = {
// then the list will default to selecting the search category and we never
// want to show that as the first view so switch to the default category
if (!this.node.selectedItem || this.node.selectedItem == this._search)
this.node.value = VIEW_DEFAULT;
this.node.value = gViewDefault;
var self = this;
this.node.addEventListener("select", function node_onSelected() {
@ -1741,7 +1745,7 @@ var gCategories = {
// If this category is currently selected then switch to the default view
if (this.node.selectedItem == category)
gViewController.replaceView(VIEW_DEFAULT);
gViewController.replaceView(gViewDefault);
this.node.removeChild(category);
},
@ -1772,7 +1776,7 @@ var gCategories = {
// Don't load view that is becoming hidden
if (hidden && aViewId == gViewController.currentViewId)
gViewController.loadView(VIEW_DEFAULT);
gViewController.loadView(gViewDefault);
item.hidden = hidden;
Services.prefs.setBoolPref(prefName, hidden);
@ -3011,7 +3015,7 @@ var gDetailView = {
// This might happen due to session restore restoring us back to an
// add-on that doesn't exist but otherwise shouldn't normally happen.
// Either way just revert to the default view.
gViewController.replaceView(VIEW_DEFAULT);
gViewController.replaceView(gViewDefault);
});
});
},

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

@ -620,3 +620,18 @@ add_test(function() {
Services.prefs.setBoolPref(PREF_XPI_ENABLED, true);
bug_601442_test_elements(true);
});
// Test for Bug 1132971 - if extensions.getAddons.showPane is false,
// the extensions pane should show by default
add_test(function() {
Services.prefs.clearUserPref(PREF_UI_LASTCATEGORY);
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, false);
open_manager(null, function(aWindow) {
gManagerWindow = aWindow;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
is(gCategoryUtilities.selectedCategory, "extension", "Should be showing the extension view");
close_manager(gManagerWindow, run_next_test);
Services.prefs.clearUserPref(PREF_DISCOVER_ENABLED);
});
});

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

@ -33,6 +33,7 @@ const PREF_XPI_ENABLED = "xpinstall.enabled";
const PREF_UPDATEURL = "extensions.update.url";
const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
const PREF_CUSTOM_XPINSTALL_CONFIRMATION_UI = "xpinstall.customConfirmationUI";
const PREF_UI_LASTCATEGORY = "extensions.ui.lastCategory";
const MANAGER_URI = "about:addons";
const INSTALL_URI = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";