2010-10-28 14:03:52 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Bug 587970 - Provide ability "Update all now" within 'Available Updates' screen
|
|
|
|
|
|
|
|
var gManagerWindow;
|
|
|
|
var gProvider;
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
gProvider = new MockProvider();
|
|
|
|
|
|
|
|
gProvider.createAddons([{
|
|
|
|
id: "addon1@tests.mozilla.org",
|
|
|
|
name: "addon 1",
|
|
|
|
version: "1.0",
|
|
|
|
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE
|
|
|
|
}, {
|
|
|
|
id: "addon2@tests.mozilla.org",
|
|
|
|
name: "addon 2",
|
|
|
|
version: "2.0",
|
|
|
|
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE
|
2010-11-08 10:00:13 -08:00
|
|
|
}, {
|
|
|
|
id: "addon3@tests.mozilla.org",
|
|
|
|
name: "addon 3",
|
|
|
|
version: "3.0",
|
|
|
|
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE
|
2010-10-28 14:03:52 -07:00
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
|
|
open_manager("addons://updates/available", function(aWindow) {
|
|
|
|
gManagerWindow = aWindow;
|
|
|
|
run_next_test();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function end_test() {
|
|
|
|
close_manager(gManagerWindow, finish);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
add_test(function() {
|
|
|
|
var list = gManagerWindow.document.getElementById("updates-list");
|
|
|
|
is(list.childNodes.length, 0, "Available updates list should be empty");
|
|
|
|
|
|
|
|
var emptyNotice = gManagerWindow.document.getElementById("empty-availableUpdates-msg");
|
|
|
|
is_element_visible(emptyNotice, "Empty notice should be visible");
|
|
|
|
|
|
|
|
var updateSelected = gManagerWindow.document.getElementById("update-selected-btn");
|
|
|
|
is_element_hidden(updateSelected, "Update Selected button should be hidden");
|
|
|
|
|
|
|
|
info("Adding updates");
|
|
|
|
gProvider.createInstalls([{
|
|
|
|
name: "addon 1",
|
|
|
|
version: "1.1",
|
|
|
|
existingAddon: gProvider.addons[0]
|
|
|
|
}, {
|
|
|
|
name: "addon 2",
|
|
|
|
version: "2.1",
|
|
|
|
existingAddon: gProvider.addons[1]
|
2010-11-08 10:00:13 -08:00
|
|
|
}, {
|
|
|
|
name: "addon 3",
|
|
|
|
version: "3.1",
|
|
|
|
existingAddon: gProvider.addons[2]
|
2010-10-28 14:03:52 -07:00
|
|
|
}]);
|
|
|
|
|
|
|
|
function wait_for_refresh() {
|
2010-11-08 10:00:13 -08:00
|
|
|
if (list.childNodes.length == 3 &&
|
2010-10-28 14:03:52 -07:00
|
|
|
list.childNodes[0].mManualUpdate &&
|
2010-11-08 10:00:13 -08:00
|
|
|
list.childNodes[1].mManualUpdate &&
|
|
|
|
list.childNodes[2].mManualUpdate) {
|
2010-10-28 14:03:52 -07:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
add_test(function() {
|
|
|
|
var list = gManagerWindow.document.getElementById("updates-list");
|
2010-11-08 10:00:13 -08:00
|
|
|
is(list.childNodes.length, 3, "Available updates list should have 2 items");
|
2010-10-28 14:03:52 -07:00
|
|
|
|
|
|
|
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");
|
2010-11-08 10:00:13 -08:00
|
|
|
var item3 = get_addon_element(gManagerWindow, "addon3@tests.mozilla.org");
|
|
|
|
isnot(item3, null, "Item for addon3@tests.mozilla.org should be in list");
|
2010-10-28 14:03:52 -07:00
|
|
|
|
|
|
|
var emptyNotice = gManagerWindow.document.getElementById("empty-availableUpdates-msg");
|
|
|
|
is_element_hidden(emptyNotice, "Empty notice should be hidden");
|
|
|
|
|
|
|
|
var updateSelected = gManagerWindow.document.getElementById("update-selected-btn");
|
|
|
|
is_element_visible(updateSelected, "Update Selected button should be visible");
|
|
|
|
is(updateSelected.disabled, false, "Update Selected button should be enabled by default");
|
|
|
|
|
|
|
|
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");
|
2010-11-08 10:00:13 -08:00
|
|
|
is(item3._includeUpdate.checked, true, "Include Update checkbox should be checked by default for addon3");
|
2010-10-28 14:03:52 -07:00
|
|
|
|
|
|
|
info("Unchecking 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, false, "Update Selected button should still be enabled");
|
|
|
|
|
|
|
|
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");
|
2010-11-08 10:00:13 -08:00
|
|
|
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");
|
2010-10-28 14:03:52 -07:00
|
|
|
is(updateSelected.disabled, true, "Update Selected button should now be disabled");
|
|
|
|
|
|
|
|
info("Checking Include Update checkbox for addon2");
|
|
|
|
EventUtils.synthesizeMouse(item2._includeUpdate, 2, 2, { }, gManagerWindow);
|
|
|
|
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");
|
|
|
|
|
2010-11-08 10:00:13 -08:00
|
|
|
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");
|
|
|
|
|
|
|
|
var installCount = 0;
|
2010-10-28 14:03:52 -07:00
|
|
|
var listener = {
|
2010-11-08 10:00:13 -08:00
|
|
|
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);
|
2010-10-28 14:03:52 -07:00
|
|
|
gProvider.installs[1].removeTestListener(listener);
|
2010-11-08 10:00:13 -08:00
|
|
|
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");
|
2010-10-28 14:03:52 -07:00
|
|
|
|
2010-11-08 10:00:13 -08:00
|
|
|
run_next_test();
|
|
|
|
});
|
2010-10-28 14:03:52 -07:00
|
|
|
}
|
|
|
|
}
|
2010-11-08 10:00:13 -08:00
|
|
|
gProvider.installs[0].addTestListener(listener);
|
2010-10-28 14:03:52 -07:00
|
|
|
gProvider.installs[1].addTestListener(listener);
|
2010-11-08 10:00:13 -08:00
|
|
|
gProvider.installs[2].addTestListener(listener);
|
2010-10-28 14:03:52 -07:00
|
|
|
info("Clicking Update Selected button");
|
2010-11-08 10:00:13 -08:00
|
|
|
EventUtils.synthesizeMouseAtCenter(updateSelected, { }, gManagerWindow);
|
2010-10-28 14:03:52 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
add_test(function() {
|
|
|
|
var updateSelected = gManagerWindow.document.getElementById("update-selected-btn");
|
2010-11-08 10:00:13 -08:00
|
|
|
is(updateSelected.disabled, true, "Update Selected button should be disabled");
|
2010-10-28 14:03:52 -07:00
|
|
|
|
|
|
|
var item1 = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
|
|
|
|
isnot(item1, null, "Item for addon1@tests.mozilla.org should be in list");
|
2010-11-08 10:00:13 -08:00
|
|
|
is(item1._includeUpdate.checked, false, "Include Update checkbox should not have changed");
|
2010-10-28 14:03:52 -07:00
|
|
|
|
2010-11-08 10:00:13 -08:00
|
|
|
info("Checking Include Update checkbox for addon1");
|
2010-10-28 14:03:52 -07:00
|
|
|
EventUtils.synthesizeMouse(item1._includeUpdate, 2, 2, { }, gManagerWindow);
|
2010-11-08 10:00:13 -08:00
|
|
|
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");
|
2010-10-28 14:03:52 -07:00
|
|
|
|
|
|
|
run_next_test();
|
|
|
|
});
|