mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 591024: Only show "Available Updates" pane when pending updates are available. r=Unfocused, a=blocks-final
This commit is contained in:
parent
e11a0c43ae
commit
b7de9a885d
@ -2405,7 +2405,6 @@ var gUpdatesView = {
|
||||
_updateSelected: null,
|
||||
_updatePrefs: null,
|
||||
_categoryItem: null,
|
||||
_numManualUpdaters: 0,
|
||||
|
||||
initialize: function() {
|
||||
this.node = document.getElementById("updates-view");
|
||||
@ -2424,7 +2423,6 @@ var gUpdatesView = {
|
||||
this._updatePrefs = Services.prefs.getBranch("extensions.update.");
|
||||
this._updatePrefs.QueryInterface(Ci.nsIPrefBranch2);
|
||||
this._updatePrefs.addObserver("", this, false);
|
||||
this.updateManualUpdatersCount(true);
|
||||
this.updateAvailableCount(true);
|
||||
|
||||
AddonManager.addAddonListener(this);
|
||||
@ -2455,6 +2453,8 @@ var gUpdatesView = {
|
||||
|
||||
hide: function() {
|
||||
this._updateSelected.hidden = true;
|
||||
|
||||
this._categoryItem.disabled = this._categoryItem.badgeCount == 0;
|
||||
},
|
||||
|
||||
_showRecentUpdates: function(aRequest) {
|
||||
@ -2551,45 +2551,12 @@ var gUpdatesView = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic != "nsPref:changed")
|
||||
return;
|
||||
if (aData == "autoUpdateDefault")
|
||||
this.updateManualUpdatersCount();
|
||||
},
|
||||
|
||||
maybeRefresh: function() {
|
||||
if (gViewController.currentViewId == "addons://updates/available") {
|
||||
if (gViewController.currentViewId == "addons://updates/available")
|
||||
this._showAvailableUpdates(true);
|
||||
} else {
|
||||
this.updateManualUpdatersCount();
|
||||
this.updateAvailableCount();
|
||||
}
|
||||
},
|
||||
|
||||
maybeShowCategory: function() {
|
||||
var hide = this._numManualUpdaters == 0;
|
||||
if (this._categoryItem.disabled != hide) {
|
||||
this._categoryItem.disabled = hide;
|
||||
var event = document.createEvent("Events");
|
||||
event.initEvent("CategoryVisible", true, true);
|
||||
this._categoryItem.dispatchEvent(event);
|
||||
}
|
||||
},
|
||||
|
||||
updateManualUpdatersCount: function(aInitializing) {
|
||||
if (aInitializing)
|
||||
gPendingInitializations++;
|
||||
var self = this;
|
||||
var autoUpdateDefault = AddonManager.autoUpdateDefault;
|
||||
AddonManager.getAllAddons(function(aAddonList) {
|
||||
var manualUpdaters = aAddonList.filter(function(aAddon) {
|
||||
if (!("applyBackgroundUpdates" in aAddon))
|
||||
return false;
|
||||
return !shouldAutoUpdate(aAddon, autoUpdateDefault);
|
||||
});
|
||||
self._numManualUpdaters = manualUpdaters.length;
|
||||
self.maybeShowCategory();
|
||||
if (aInitializing)
|
||||
notifyInitialized();
|
||||
});
|
||||
this.updateAvailableCount();
|
||||
},
|
||||
|
||||
updateAvailableCount: function(aInitializing) {
|
||||
@ -2600,6 +2567,8 @@ var gUpdatesView = {
|
||||
var count = aInstallsList.filter(function(aInstall) {
|
||||
return self.isManualUpdate(aInstall, true);
|
||||
}).length;
|
||||
self._categoryItem.disabled = gViewController.currentViewObj != self &&
|
||||
count == 0;
|
||||
self._categoryItem.badgeCount = count;
|
||||
if (aInitializing)
|
||||
notifyInitialized();
|
||||
@ -2654,18 +2623,8 @@ var gUpdatesView = {
|
||||
this.maybeRefresh();
|
||||
},
|
||||
|
||||
onExternalInstall: function(aAddon) {
|
||||
if (!shouldAutoUpdate(aAddon)) {
|
||||
this._numManualUpdaters++;
|
||||
this.maybeShowCategory();
|
||||
}
|
||||
},
|
||||
|
||||
onInstallEnded: function(aAddon) {
|
||||
if (!shouldAutoUpdate(aAddon)) {
|
||||
this._numManualUpdaters++;
|
||||
this.maybeShowCategory();
|
||||
}
|
||||
onInstallStarted: function(aInstall) {
|
||||
this.updateAvailableCount();
|
||||
},
|
||||
|
||||
onInstallCancelled: function(aInstall) {
|
||||
@ -2676,7 +2635,7 @@ var gUpdatesView = {
|
||||
|
||||
onPropertyChanged: function(aAddon, aProperties) {
|
||||
if (aProperties.indexOf("applyBackgroundUpdates") != -1)
|
||||
this.updateManualUpdatersCount();
|
||||
this.updateAvailableCount();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -48,25 +48,16 @@ add_test(function() {
|
||||
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE
|
||||
}]);
|
||||
|
||||
is(gCategoryUtilities.isVisible(gAvailableCategory), true, "Available Updates category should now be visible");
|
||||
|
||||
gAvailableCategory.addEventListener("CategoryVisible", function() {
|
||||
gAvailableCategory.removeEventListener("CategoryVisible", arguments.callee, false);
|
||||
is(gCategoryUtilities.isVisible(gAvailableCategory), false, "Available Updates category should not be visible");
|
||||
gAvailableCategory.addEventListener("CategoryVisible", function() {
|
||||
gAvailableCategory.removeEventListener("CategoryVisible", arguments.callee, false);
|
||||
is(gCategoryUtilities.isVisible(gAvailableCategory), true, "Available Updates category should be visible");
|
||||
run_next_test();
|
||||
}, false);
|
||||
gProvider.addons[1].applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
|
||||
}, false);
|
||||
gProvider.addons[1].applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
|
||||
is(gCategoryUtilities.isVisible(gAvailableCategory), false, "Available Updates category should still be hidden");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
|
||||
add_test(function() {
|
||||
gAvailableCategory.addEventListener("CategoryBadgeUpdated", function() {
|
||||
gAvailableCategory.removeEventListener("CategoryBadgeUpdated", arguments.callee, false);
|
||||
is(gCategoryUtilities.isVisible(gAvailableCategory), true, "Available Updates category should now be visible");
|
||||
is(gAvailableCategory.badgeCount, 1, "Badge for Available Updates should now be 1");
|
||||
run_next_test();
|
||||
}, false);
|
||||
@ -165,6 +156,17 @@ add_test(function() {
|
||||
|
||||
|
||||
add_test(function() {
|
||||
var badgeUpdated = false;
|
||||
var installCompleted = false;
|
||||
|
||||
gAvailableCategory.addEventListener("CategoryBadgeUpdated", function() {
|
||||
gAvailableCategory.removeEventListener("CategoryBadgeUpdated", arguments.callee, false);
|
||||
if (installCompleted)
|
||||
run_next_test();
|
||||
else
|
||||
badgeUpdated = true;
|
||||
}, false);
|
||||
|
||||
var list = gManagerWindow.document.getElementById("updates-list");
|
||||
var item = list.firstChild;
|
||||
var updateBtn = item._updateBtn;
|
||||
@ -178,11 +180,63 @@ add_test(function() {
|
||||
},
|
||||
onInstallEnded: function() {
|
||||
install.removeTestListener(this);
|
||||
info("install ended");
|
||||
info("Install ended");
|
||||
is_element_hidden(item._installStatus, "Install progress widget should be hidden");
|
||||
run_next_test();
|
||||
|
||||
if (badgeUpdated)
|
||||
run_next_test();
|
||||
else
|
||||
installCompleted = true;
|
||||
}
|
||||
};
|
||||
install.addTestListener(listener);
|
||||
EventUtils.synthesizeMouseAtCenter(updateBtn, { }, gManagerWindow);
|
||||
});
|
||||
|
||||
|
||||
add_test(function() {
|
||||
is(gCategoryUtilities.isVisible(gAvailableCategory), true, "Available Updates category should still be visible");
|
||||
is(gAvailableCategory.badgeCount, 0, "Badge for Available Updates should now be 0");
|
||||
|
||||
gCategoryUtilities.openType("extension", function() {
|
||||
is(gCategoryUtilities.isVisible(gAvailableCategory), false, "Available Updates category should be hidden");
|
||||
|
||||
close_manager(gManagerWindow, function() {
|
||||
open_manager(null, function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
gAvailableCategory = gManagerWindow.gCategories.get("addons://updates/available");
|
||||
|
||||
is(gCategoryUtilities.isVisible(gAvailableCategory), false, "Available Updates category should be hidden");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
gAvailableCategory.addEventListener("CategoryBadgeUpdated", function() {
|
||||
gAvailableCategory.removeEventListener("CategoryBadgeUpdated", arguments.callee, false);
|
||||
is(gCategoryUtilities.isVisible(gAvailableCategory), true, "Available Updates category should now be visible");
|
||||
is(gAvailableCategory.badgeCount, 1, "Badge for Available Updates should now be 1");
|
||||
|
||||
gAvailableCategory.addEventListener("CategoryBadgeUpdated", function() {
|
||||
gAvailableCategory.removeEventListener("CategoryBadgeUpdated", arguments.callee, false);
|
||||
is(gCategoryUtilities.isVisible(gAvailableCategory), false, "Available Updates category should now be hidden");
|
||||
|
||||
run_next_test();
|
||||
}, false);
|
||||
|
||||
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(aAddon) {
|
||||
aAddon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
|
||||
});
|
||||
}, false);
|
||||
|
||||
gProvider.createInstalls([{
|
||||
name: "manually updating addon (new and even more improved!)",
|
||||
existingAddon: gProvider.addons[1],
|
||||
version: "1.2",
|
||||
releaseNotesURI: Services.io.newURI(TESTROOT + "thereIsNoFileHere.xhtml", null, null)
|
||||
}]);
|
||||
});
|
||||
|
@ -540,6 +540,7 @@ MockProvider.prototype = {
|
||||
*/
|
||||
addInstall: function MP_addInstall(aInstall) {
|
||||
this.installs.push(aInstall);
|
||||
aInstall._provider = this;
|
||||
|
||||
if (!this.started)
|
||||
return;
|
||||
@ -547,6 +548,16 @@ MockProvider.prototype = {
|
||||
aInstall.callListeners("onNewInstall");
|
||||
},
|
||||
|
||||
removeInstall: function MP_removeInstall(aInstall) {
|
||||
var pos = this.installs.indexOf(aInstall);
|
||||
if (pos == -1) {
|
||||
ok(false, "Tried to remove an install that wasn't registered with the mock provider");
|
||||
return;
|
||||
}
|
||||
|
||||
this.installs.splice(pos, 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a set of mock add-on objects and adds them to the list of add-ons
|
||||
* managed by this provider.
|
||||
@ -1042,6 +1053,7 @@ MockInstall.prototype = {
|
||||
break;
|
||||
case AddonManager.STATE_INSTALLED:
|
||||
this.state = AddonManager.STATE_CANCELLED;
|
||||
this._provider.removeInstall(this);
|
||||
this.callListeners("onInstallCancelled");
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user