mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 597397: Install Updates only installs the first update in the list. r=Unfocused, a=blocks-betaN
This commit is contained in:
parent
ce648f8643
commit
86577199be
@ -2408,7 +2408,8 @@ var gUpdatesView = {
|
||||
|
||||
var self = this;
|
||||
AddonManager.getAllInstalls(function(aInstallsList) {
|
||||
if (!aIsRefresh && gViewController && aRequest != gViewController.currentViewRequest)
|
||||
if (!aIsRefresh && gViewController && aRequest &&
|
||||
aRequest != gViewController.currentViewRequest)
|
||||
return;
|
||||
|
||||
if (aIsRefresh) {
|
||||
@ -2527,16 +2528,13 @@ var gUpdatesView = {
|
||||
},
|
||||
|
||||
installSelected: function() {
|
||||
/* Starting the update of one item will refresh the list,
|
||||
which can cause problems while we're iterating over it.
|
||||
So we update only after we've finished iterating over the list. */
|
||||
var toUpgrade = [];
|
||||
for (let i = 0; i < this._listBox.childNodes.length; i++) {
|
||||
let item = this._listBox.childNodes[i];
|
||||
if (item.includeUpdate)
|
||||
toUpgrade.push(item);
|
||||
item.upgrade();
|
||||
}
|
||||
toUpgrade.forEach(function(aItem) aItem.upgrade());
|
||||
|
||||
this._updateSelected.disabled = true;
|
||||
},
|
||||
|
||||
getSelectedAddon: function() {
|
||||
@ -2579,18 +2577,6 @@ var gUpdatesView = {
|
||||
}
|
||||
},
|
||||
|
||||
onDownloadStarted: function(aInstall) {
|
||||
if (!this.isManualUpdate(aInstall))
|
||||
return;
|
||||
this.maybeRefresh();
|
||||
},
|
||||
|
||||
onInstallStarted: function(aInstall) {
|
||||
if (!this.isManualUpdate(aInstall))
|
||||
return;
|
||||
this.maybeRefresh();
|
||||
},
|
||||
|
||||
onInstallEnded: function(aAddon) {
|
||||
if (!shouldAutoUpdate(aAddon)) {
|
||||
this._numManualUpdaters++;
|
||||
@ -2598,6 +2584,12 @@ var gUpdatesView = {
|
||||
}
|
||||
},
|
||||
|
||||
onInstallCancelled: function(aInstall) {
|
||||
if (!this.isManualUpdate(aInstall))
|
||||
return;
|
||||
this.maybeRefresh();
|
||||
},
|
||||
|
||||
onPropertyChanged: function(aAddon, aProperties) {
|
||||
if (aProperties.indexOf("applyBackgroundUpdates") != -1)
|
||||
this.updateManualUpdatersCount();
|
||||
|
@ -22,6 +22,11 @@ function test() {
|
||||
name: "addon 2",
|
||||
version: "2.0",
|
||||
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE
|
||||
}, {
|
||||
id: "addon3@tests.mozilla.org",
|
||||
name: "addon 3",
|
||||
version: "3.0",
|
||||
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE
|
||||
}]);
|
||||
|
||||
|
||||
@ -56,12 +61,17 @@ add_test(function() {
|
||||
name: "addon 2",
|
||||
version: "2.1",
|
||||
existingAddon: gProvider.addons[1]
|
||||
}, {
|
||||
name: "addon 3",
|
||||
version: "3.1",
|
||||
existingAddon: gProvider.addons[2]
|
||||
}]);
|
||||
|
||||
function wait_for_refresh() {
|
||||
if (list.childNodes.length == 2 &&
|
||||
if (list.childNodes.length == 3 &&
|
||||
list.childNodes[0].mManualUpdate &&
|
||||
list.childNodes[1].mManualUpdate) {
|
||||
list.childNodes[1].mManualUpdate &&
|
||||
list.childNodes[2].mManualUpdate) {
|
||||
run_next_test();
|
||||
} else {
|
||||
info("Waiting for pane to refresh");
|
||||
@ -75,12 +85,14 @@ add_test(function() {
|
||||
|
||||
add_test(function() {
|
||||
var list = gManagerWindow.document.getElementById("updates-list");
|
||||
is(list.childNodes.length, 2, "Available updates list should have 2 items");
|
||||
is(list.childNodes.length, 3, "Available updates list should have 2 items");
|
||||
|
||||
var item1 = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
|
||||
isnot(item1, null, "Item for addon1@tests.mozilla.org should be in list");
|
||||
var item2 = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
|
||||
isnot(item2, null, "Item for addon2@tests.mozilla.org should be in list");
|
||||
var item3 = get_addon_element(gManagerWindow, "addon3@tests.mozilla.org");
|
||||
isnot(item3, null, "Item for addon3@tests.mozilla.org should be in list");
|
||||
|
||||
var emptyNotice = gManagerWindow.document.getElementById("empty-availableUpdates-msg");
|
||||
is_element_hidden(emptyNotice, "Empty notice should be hidden");
|
||||
@ -91,6 +103,7 @@ add_test(function() {
|
||||
|
||||
is(item1._includeUpdate.checked, true, "Include Update checkbox should be checked by default for addon1");
|
||||
is(item2._includeUpdate.checked, true, "Include Update checkbox should be checked by default for addon2");
|
||||
is(item3._includeUpdate.checked, true, "Include Update checkbox should be checked by default for addon3");
|
||||
|
||||
info("Unchecking Include Update checkbox for addon1");
|
||||
EventUtils.synthesizeMouse(item1._includeUpdate, 2, 2, { }, gManagerWindow);
|
||||
@ -100,6 +113,11 @@ add_test(function() {
|
||||
info("Unchecking Include Update checkbox for addon2");
|
||||
EventUtils.synthesizeMouse(item2._includeUpdate, 2, 2, { }, gManagerWindow);
|
||||
is(item2._includeUpdate.checked, false, "Include Update checkbox should now be be unchecked for addon2");
|
||||
is(updateSelected.disabled, false, "Update Selected button should still be enabled");
|
||||
|
||||
info("Unchecking Include Update checkbox for addon3");
|
||||
EventUtils.synthesizeMouse(item3._includeUpdate, 2, 2, { }, gManagerWindow);
|
||||
is(item3._includeUpdate.checked, false, "Include Update checkbox should now be be unchecked for addon3");
|
||||
is(updateSelected.disabled, true, "Update Selected button should now be disabled");
|
||||
|
||||
info("Checking Include Update checkbox for addon2");
|
||||
@ -107,46 +125,56 @@ add_test(function() {
|
||||
is(item2._includeUpdate.checked, true, "Include Update checkbox should now be be checked for addon2");
|
||||
is(updateSelected.disabled, false, "Update Selected button should now be enabled");
|
||||
|
||||
var listener = {
|
||||
onInstallEnded: function() {
|
||||
gProvider.installs[1].removeTestListener(listener);
|
||||
info("Checking Include Update checkbox for addon3");
|
||||
EventUtils.synthesizeMouse(item3._includeUpdate, 2, 2, { }, gManagerWindow);
|
||||
is(item3._includeUpdate.checked, true, "Include Update checkbox should now be be checked for addon3");
|
||||
is(updateSelected.disabled, false, "Update Selected button should now be enabled");
|
||||
|
||||
is(gProvider.installs[0].state, AddonManager.STATE_AVAILABLE, "addon1 should not have been upgraded");
|
||||
is(gProvider.installs[1].state, AddonManager.STATE_INSTALLED, "addon2 should have been upgraded");
|
||||
var installCount = 0;
|
||||
var listener = {
|
||||
onDownloadStarted: function(aInstall) {
|
||||
isnot(aInstall.existingAddon.id, "addon1@tests.mozilla.org", "Should not have seen a download start for addon1");
|
||||
},
|
||||
|
||||
onInstallEnded: function(aInstall) {
|
||||
if (++installCount < 2)
|
||||
return;
|
||||
|
||||
gProvider.installs[0].removeTestListener(listener);
|
||||
gProvider.installs[1].removeTestListener(listener);
|
||||
gProvider.installs[2].removeTestListener(listener);
|
||||
|
||||
// Installs are started synchronously so by the time an executeSoon is
|
||||
// executed all installs that are going to start will have started
|
||||
executeSoon(function() {
|
||||
is(gProvider.installs[0].state, AddonManager.STATE_AVAILABLE, "addon1 should not have been upgraded");
|
||||
is(gProvider.installs[1].state, AddonManager.STATE_INSTALLED, "addon2 should have been upgraded");
|
||||
is(gProvider.installs[2].state, AddonManager.STATE_INSTALLED, "addon3 should have been upgraded");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
}
|
||||
}
|
||||
gProvider.installs[0].addTestListener(listener);
|
||||
gProvider.installs[1].addTestListener(listener);
|
||||
gProvider.installs[2].addTestListener(listener);
|
||||
info("Clicking Update Selected button");
|
||||
EventUtils.synthesizeMouse(updateSelected, 2, 2, { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
function wait_for_refresh() {
|
||||
var item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
|
||||
if (item.mManualUpdate) {
|
||||
run_next_test();
|
||||
} else {
|
||||
info("Waiting for pane to refresh");
|
||||
setTimeout(wait_for_refresh, 10);
|
||||
}
|
||||
}
|
||||
info("Waiting for pane to refresh");
|
||||
setTimeout(wait_for_refresh, 10);
|
||||
}, true);
|
||||
EventUtils.synthesizeMouseAtCenter(updateSelected, { }, gManagerWindow);
|
||||
});
|
||||
|
||||
|
||||
add_test(function() {
|
||||
var updateSelected = gManagerWindow.document.getElementById("update-selected-btn");
|
||||
is(updateSelected.disabled, false, "Update Selected button should now be enabled");
|
||||
is(updateSelected.disabled, true, "Update Selected button should be disabled");
|
||||
|
||||
var item1 = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
|
||||
isnot(item1, null, "Item for addon1@tests.mozilla.org should be in list");
|
||||
is(item1._includeUpdate.checked, true, "Include Update checkbox should be checked by default for addon1");
|
||||
is(item1._includeUpdate.checked, false, "Include Update checkbox should not have changed");
|
||||
|
||||
info("Unchecking Include Update checkbox for addon1");
|
||||
info("Checking Include Update checkbox for addon1");
|
||||
EventUtils.synthesizeMouse(item1._includeUpdate, 2, 2, { }, gManagerWindow);
|
||||
is(item1._includeUpdate.checked, false, "Include Update checkbox should now be be unchecked for addon1");
|
||||
is(updateSelected.disabled, true, "Update Selected button should now be disabled");
|
||||
is(item1._includeUpdate.checked, true, "Include Update checkbox should now be be checked for addon1");
|
||||
is(updateSelected.disabled, false, "Update Selected button should now not be disabled");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
@ -975,12 +975,19 @@ MockInstall.prototype = {
|
||||
install: function() {
|
||||
switch (this.state) {
|
||||
case AddonManager.STATE_AVAILABLE:
|
||||
case AddonManager.STATE_DOWNLOADED:
|
||||
// Downloading to be implemented when needed
|
||||
this.state = AddonManager.STATE_DOWNLOADING;
|
||||
if (!this.callListeners("onDownloadStarted")) {
|
||||
this.state = AddonManager.STATE_CANCELLED;
|
||||
this.callListeners("onDownloadCancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
this.state = AddonManager.STATE_DOWNLOADED;
|
||||
this.callListeners("onDownloadEnded");
|
||||
|
||||
case AddonManager.STATE_DOWNLOADED:
|
||||
this.state = AddonManager.STATE_INSTALLING;
|
||||
if (!this.callListeners("onInstallStarted")) {
|
||||
// Reverting to STATE_DOWNLOADED instead to be implemented when needed
|
||||
this.state = AddonManager.STATE_CANCELLED;
|
||||
this.callListeners("onInstallCancelled");
|
||||
return;
|
||||
@ -1048,10 +1055,15 @@ MockInstall.prototype = {
|
||||
// Call test listeners after standard listeners to remove race condition
|
||||
// between standard and test listeners
|
||||
this.testListeners.forEach(function(aListener) {
|
||||
if (aMethod in aListener)
|
||||
if (aListener[aMethod].call(aListener, this, this.addon) === false)
|
||||
result = false;
|
||||
});
|
||||
try {
|
||||
if (aMethod in aListener)
|
||||
if (aListener[aMethod].call(aListener, this, this.addon) === false)
|
||||
result = false;
|
||||
}
|
||||
catch (e) {
|
||||
ok(false, "Test listener threw exception: " + e);
|
||||
}
|
||||
}, this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user