mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 710064: Make the 'Update Add-ons Automatically' checkbox state depend on the extensions.update.enabled pref, in addition to the existing extensions.update.autoUpdateDefault pref. r=mossop
This commit is contained in:
parent
591fb05e38
commit
1e882100fe
@ -348,6 +348,7 @@ var gEventManager = {
|
||||
|
||||
Services.prefs.addObserver(PREF_CHECK_COMPATIBILITY, this, false);
|
||||
Services.prefs.addObserver(PREF_CHECK_UPDATE_SECURITY, this, false);
|
||||
Services.prefs.addObserver(PREF_UPDATE_ENABLED, this, false);
|
||||
Services.prefs.addObserver(PREF_AUTOUPDATE_DEFAULT, this, false);
|
||||
|
||||
this.refreshGlobalWarning();
|
||||
@ -481,27 +482,34 @@ var gEventManager = {
|
||||
page.setAttribute("warning", "checkcompatibility");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
page.removeAttribute("warning");
|
||||
},
|
||||
|
||||
|
||||
refreshAutoUpdateDefault: function() {
|
||||
var defaultEnable = true;
|
||||
var updateEnabled = true;
|
||||
var autoUpdateDefault = true;
|
||||
try {
|
||||
defaultEnable = Services.prefs.getBoolPref(PREF_AUTOUPDATE_DEFAULT);
|
||||
updateEnabled = Services.prefs.getBoolPref(PREF_UPDATE_ENABLED);
|
||||
autoUpdateDefault = Services.prefs.getBoolPref(PREF_AUTOUPDATE_DEFAULT);
|
||||
} catch(e) { }
|
||||
document.getElementById("utils-autoUpdateDefault").setAttribute("checked",
|
||||
defaultEnable);
|
||||
document.getElementById("utils-resetAddonUpdatesToAutomatic").hidden = !defaultEnable;
|
||||
document.getElementById("utils-resetAddonUpdatesToManual").hidden = defaultEnable;
|
||||
|
||||
// The checkbox needs to reflect that both prefs need to be true
|
||||
// for updates to be checked for and applied automatically
|
||||
document.getElementById("utils-autoUpdateDefault")
|
||||
.setAttribute("checked", updateEnabled && autoUpdateDefault);
|
||||
|
||||
document.getElementById("utils-resetAddonUpdatesToAutomatic").hidden = !autoUpdateDefault;
|
||||
document.getElementById("utils-resetAddonUpdatesToManual").hidden = autoUpdateDefault;
|
||||
},
|
||||
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
switch (aData) {
|
||||
case PREF_CHECK_COMPATIBILITY:
|
||||
case PREF_CHECK_UPDATE_SECURITY:
|
||||
this.refreshGlobalWarning();
|
||||
break;
|
||||
case PREF_UPDATE_ENABLED:
|
||||
case PREF_AUTOUPDATE_DEFAULT:
|
||||
this.refreshAutoUpdateDefault();
|
||||
break;
|
||||
@ -754,17 +762,24 @@ var gViewController = {
|
||||
cmd_toggleAutoUpdateDefault: {
|
||||
isEnabled: function() true,
|
||||
doCommand: function() {
|
||||
var oldValue = true;
|
||||
var updateEnabled = true;
|
||||
var autoUpdateDefault = true;
|
||||
try {
|
||||
oldValue = Services.prefs.getBoolPref(PREF_AUTOUPDATE_DEFAULT);
|
||||
updateEnabled = Services.prefs.getBoolPref(PREF_UPDATE_ENABLED);
|
||||
autoUpdateDefault = Services.prefs.getBoolPref(PREF_AUTOUPDATE_DEFAULT);
|
||||
} catch(e) { }
|
||||
var newValue = !oldValue; // toggle
|
||||
Services.prefs.setBoolPref(PREF_AUTOUPDATE_DEFAULT, newValue);
|
||||
|
||||
// If the user wants us to auto-update add-ons, we also need to
|
||||
// auto-check for updates.
|
||||
if (newValue) // i.e. new value is true
|
||||
if (!updateEnabled || !autoUpdateDefault) {
|
||||
// One or both of the prefs is false, i.e. the checkbox is not checked.
|
||||
// Now toggle both to true. If the user wants us to auto-update
|
||||
// add-ons, we also need to auto-check for updates.
|
||||
Services.prefs.setBoolPref(PREF_UPDATE_ENABLED, true);
|
||||
Services.prefs.setBoolPref(PREF_AUTOUPDATE_DEFAULT, true);
|
||||
} else {
|
||||
// Both prefs are true, i.e. the checkbox is checked.
|
||||
// Toggle the auto pref to false, but don't touch the enabled check.
|
||||
Services.prefs.setBoolPref(PREF_AUTOUPDATE_DEFAULT, false);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -3,7 +3,12 @@
|
||||
*/
|
||||
|
||||
// Bug 586574 - Provide way to set a default for automatic updates
|
||||
// Bug 710064 - Make the "Update Add-ons Automatically" checkbox state
|
||||
// also depend on the extensions.update.enabled pref
|
||||
|
||||
// TEST_PATH=toolkit/mozapps/extensions/test/browser/browser_bug586574.js make -C obj-ff mochitest-browser-chrome
|
||||
|
||||
const PREF_UPDATE_ENABLED = "extensions.update.enabled";
|
||||
const PREF_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault";
|
||||
|
||||
var gManagerWindow;
|
||||
@ -75,16 +80,17 @@ add_test(function() {
|
||||
gResetToAutomatic = gManagerWindow.document.getElementById("utils-resetAddonUpdatesToAutomatic");
|
||||
gResetToManual = gManagerWindow.document.getElementById("utils-resetAddonUpdatesToManual");
|
||||
|
||||
info("Ensuring default is set to true");
|
||||
info("Ensuring default prefs are set to true");
|
||||
Services.prefs.setBoolPref(PREF_UPDATE_ENABLED, true);
|
||||
Services.prefs.setBoolPref(PREF_AUTOUPDATE_DEFAULT, true);
|
||||
|
||||
wait_for_popup(function() {
|
||||
is(gSetDefault.getAttribute("checked"), "true",
|
||||
"Set Default menuitem should be checked");
|
||||
"#1 Set Default menuitem should be checked");
|
||||
is_element_visible(gResetToAutomatic,
|
||||
"Reset to Automatic menuitem should be visible");
|
||||
"#1 Reset to Automatic menuitem should be visible");
|
||||
is_element_hidden(gResetToManual,
|
||||
"Reset to Manual menuitem should be hidden");
|
||||
"#1 Reset to Manual menuitem should be hidden");
|
||||
|
||||
var listener = {
|
||||
onPropertyChanged: function(aAddon, aProperties) {
|
||||
@ -114,17 +120,20 @@ add_test(function() {
|
||||
|
||||
|
||||
add_test(function() {
|
||||
info("Disabling extensions.update.enabled");
|
||||
Services.prefs.setBoolPref(PREF_UPDATE_ENABLED, false);
|
||||
|
||||
wait_for_popup(function() {
|
||||
is(gSetDefault.getAttribute("checked"), "true",
|
||||
"Set Default menuitem should be checked");
|
||||
isnot(gSetDefault.getAttribute("checked"), "true",
|
||||
"#2 Set Default menuitem should not be checked");
|
||||
is_element_visible(gResetToAutomatic,
|
||||
"Reset to Automatic menuitem should be visible");
|
||||
"#2 Reset to Automatic menuitem should be visible");
|
||||
is_element_hidden(gResetToManual,
|
||||
"Reset to Manual menuitem should be hidden");
|
||||
"#2 Reset to Manual menuitem should be hidden");
|
||||
|
||||
wait_for_hide(run_next_test);
|
||||
|
||||
info("Clicking Set Default menuitem");
|
||||
info("Clicking Set Default menuitem to reenable");
|
||||
EventUtils.synthesizeMouseAtCenter(gSetDefault, { }, gManagerWindow);
|
||||
});
|
||||
|
||||
@ -134,13 +143,73 @@ add_test(function() {
|
||||
|
||||
|
||||
add_test(function() {
|
||||
ok(Services.prefs.getBoolPref(PREF_UPDATE_ENABLED),
|
||||
"extensions.update.enabled should be true after the previous test");
|
||||
ok(Services.prefs.getBoolPref(PREF_AUTOUPDATE_DEFAULT),
|
||||
"extensions.update.autoUpdateDefault should be true after the previous test");
|
||||
|
||||
info("Disabling both extensions.update.enabled and extensions.update.autoUpdateDefault");
|
||||
Services.prefs.setBoolPref(PREF_UPDATE_ENABLED, false);
|
||||
Services.prefs.setBoolPref(PREF_AUTOUPDATE_DEFAULT, false);
|
||||
|
||||
wait_for_popup(function() {
|
||||
isnot(gSetDefault.getAttribute("checked"), "true",
|
||||
"Set Default menuitem should not be checked");
|
||||
"#3 Set Default menuitem should not be checked");
|
||||
is_element_hidden(gResetToAutomatic,
|
||||
"Reset to automatic menuitem should be hidden");
|
||||
"#3 Reset to automatic menuitem should be hidden");
|
||||
is_element_visible(gResetToManual,
|
||||
"Reset to manual menuitem should be visible");
|
||||
"#3 Reset to manual menuitem should be visible");
|
||||
|
||||
wait_for_hide(run_next_test);
|
||||
|
||||
info("Clicking Set Default menuitem to reenable");
|
||||
EventUtils.synthesizeMouseAtCenter(gSetDefault, { }, gManagerWindow);
|
||||
});
|
||||
|
||||
info("Opening utilities menu");
|
||||
EventUtils.synthesizeMouseAtCenter(gUtilsBtn, { }, gManagerWindow);
|
||||
});
|
||||
|
||||
|
||||
add_test(function() {
|
||||
ok(Services.prefs.getBoolPref(PREF_UPDATE_ENABLED),
|
||||
"extensions.update.enabled should be true after the previous test");
|
||||
ok(Services.prefs.getBoolPref(PREF_AUTOUPDATE_DEFAULT),
|
||||
"extensions.update.autoUpdateDefault should be true after the previous test");
|
||||
|
||||
info("clicking the button to disable extensions.update.autoUpdateDefault");
|
||||
wait_for_popup(function() {
|
||||
is(gSetDefault.getAttribute("checked"), "true",
|
||||
"#4 Set Default menuitem should be checked");
|
||||
is_element_visible(gResetToAutomatic,
|
||||
"#4 Reset to Automatic menuitem should be visible");
|
||||
is_element_hidden(gResetToManual,
|
||||
"#4 Reset to Manual menuitem should be hidden");
|
||||
|
||||
wait_for_hide(run_next_test);
|
||||
|
||||
info("Clicking Set Default menuitem to disable");
|
||||
EventUtils.synthesizeMouseAtCenter(gSetDefault, { }, gManagerWindow);
|
||||
});
|
||||
|
||||
info("Opening utilities menu");
|
||||
EventUtils.synthesizeMouseAtCenter(gUtilsBtn, { }, gManagerWindow);
|
||||
});
|
||||
|
||||
|
||||
add_test(function() {
|
||||
ok(Services.prefs.getBoolPref(PREF_UPDATE_ENABLED),
|
||||
"extensions.update.enabled should be true after the previous test");
|
||||
is(Services.prefs.getBoolPref(PREF_AUTOUPDATE_DEFAULT), false,
|
||||
"extensions.update.autoUpdateDefault should be false after the previous test");
|
||||
|
||||
wait_for_popup(function() {
|
||||
isnot(gSetDefault.getAttribute("checked"), "true",
|
||||
"#5 Set Default menuitem should not be checked");
|
||||
is_element_hidden(gResetToAutomatic,
|
||||
"#5 Reset to automatic menuitem should be hidden");
|
||||
is_element_visible(gResetToManual,
|
||||
"#5 Reset to manual menuitem should be visible");
|
||||
|
||||
var listener = {
|
||||
onPropertyChanged: function(aAddon, aProperties) {
|
||||
@ -173,11 +242,11 @@ add_test(function() {
|
||||
add_test(function() {
|
||||
wait_for_popup(function() {
|
||||
isnot(gSetDefault.getAttribute("checked"), "true",
|
||||
"Set Default menuitem should not be checked");
|
||||
"#6 Set Default menuitem should not be checked");
|
||||
is_element_hidden(gResetToAutomatic,
|
||||
"Reset to automatic menuitem should be hidden");
|
||||
"#6 Reset to automatic menuitem should be hidden");
|
||||
is_element_visible(gResetToManual,
|
||||
"Reset to manual menuitem should be visible");
|
||||
"#6 Reset to manual menuitem should be visible");
|
||||
|
||||
wait_for_hide(run_next_test);
|
||||
|
||||
@ -193,11 +262,11 @@ add_test(function() {
|
||||
add_test(function() {
|
||||
wait_for_popup(function() {
|
||||
is(gSetDefault.getAttribute("checked"), "true",
|
||||
"Set Default menuitem should be checked");
|
||||
"#7 Set Default menuitem should be checked");
|
||||
is_element_visible(gResetToAutomatic,
|
||||
"Reset to Automatic menuitem should be visible");
|
||||
"#7 Reset to Automatic menuitem should be visible");
|
||||
is_element_hidden(gResetToManual,
|
||||
"Reset to Manual menuitem should be hidden");
|
||||
"#7 Reset to Manual menuitem should be hidden");
|
||||
|
||||
wait_for_hide(run_next_test);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user