зеркало из https://github.com/mozilla/gecko-dev.git
Bug 598923 - add-on bar should be made visible if there are any add-ons installed (r=dao, a=blocking)
This commit is contained in:
Родитель
2d9ebd719d
Коммит
c808951de9
|
@ -1378,6 +1378,7 @@ function delayedStartup(isLoadingBlank, mustLoadSidebar) {
|
|||
OfflineApps.init();
|
||||
IndexedDBPromptHelper.init();
|
||||
gFormSubmitObserver.init();
|
||||
AddonManager.addAddonListener(AddonsMgrListener);
|
||||
|
||||
gBrowser.addEventListener("pageshow", function(evt) { setTimeout(pageShowEventHandlers, 0, evt); }, true);
|
||||
|
||||
|
@ -1641,6 +1642,7 @@ function BrowserShutdown()
|
|||
OfflineApps.uninit();
|
||||
gPrivateBrowsingUI.uninit();
|
||||
IndexedDBPromptHelper.uninit();
|
||||
AddonManager.removeAddonListener(AddonsMgrListener);
|
||||
|
||||
var enumerator = Services.wm.getEnumerator(null);
|
||||
enumerator.getNext();
|
||||
|
@ -8050,3 +8052,33 @@ function duplicateTabIn(aTab, where, historyIndex) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* When addons are installed/uninstalled, check and see if the number of items
|
||||
* on the add-on bar changed:
|
||||
* - If an add-on was installed, incrementing the count, show the bar.
|
||||
* - If an add-on was uninstalled, and no more items are left, hide the bar.
|
||||
*/
|
||||
let AddonsMgrListener = {
|
||||
get addonBar() document.getElementById("addon-bar"),
|
||||
get statusBar() document.getElementById("status-bar"),
|
||||
getAddonBarItemCount: function() {
|
||||
// Take into account the contents of the status bar shim for the count.
|
||||
return this.addonBar.childNodes.length - 1 +
|
||||
this.statusBar.childNodes.length;
|
||||
},
|
||||
onInstalling: function(aAddon) {
|
||||
this.lastAddonBarCount = this.getAddonBarItemCount();
|
||||
},
|
||||
onInstalled: function(aAddon) {
|
||||
if (this.getAddonBarItemCount() > this.lastAddonBarCount)
|
||||
setToolbarVisibility(this.addonBar, true);
|
||||
},
|
||||
onUninstalling: function(aAddon) {
|
||||
this.lastAddonBarCount = this.getAddonBarItemCount();
|
||||
},
|
||||
onUninstalled: function(aAddon) {
|
||||
if (this.lastAddonBarCount > 0 && this.getAddonBarItemCount() == 0)
|
||||
setToolbarVisibility(this.addonBar, false);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -160,6 +160,7 @@ _BROWSER_FILES = \
|
|||
browser_bug595507.js \
|
||||
browser_bug596687.js \
|
||||
browser_bug597218.js \
|
||||
browser_bug598923.js \
|
||||
browser_bug599325.js \
|
||||
browser_bug609700.js \
|
||||
browser_contextSearchTabPosition.js \
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Test:
|
||||
// * if add-on is installed to the add-on bar, the bar is made visible.
|
||||
// * if add-on is uninstalled from the add-on bar, and no more add-ons there,
|
||||
// the bar is hidden.
|
||||
|
||||
function test() {
|
||||
let aml = AddonsMgrListener;
|
||||
ok(aml, "AddonsMgrListener exists");
|
||||
// check is hidden
|
||||
is(aml.addonBar.collapsed, true, "aob is hidden");
|
||||
// aob gets the count
|
||||
AddonsMgrListener.onInstalling();
|
||||
// add an item
|
||||
let element = document.createElement("toolbaritem");
|
||||
aml.addonBar.appendChild(element);
|
||||
// aob checks the count, makes visible
|
||||
AddonsMgrListener.onInstalled();
|
||||
// check is visible
|
||||
is(aml.addonBar.collapsed, false, "aob is visible");
|
||||
// aob gets the count
|
||||
AddonsMgrListener.onUninstalling();
|
||||
// remove an item
|
||||
aml.addonBar.removeChild(element);
|
||||
// aob checks the count, makes hidden
|
||||
AddonsMgrListener.onUninstalled();
|
||||
// check is hidden
|
||||
is(aml.addonBar.collapsed, true, "aob is hidden");
|
||||
}
|
Загрузка…
Ссылка в новой задаче