Bug 1390561 - Add a new param "buttonAutoFocus" for appUpdater object to focus the button automatically because we need auto focus in about dialog but do not need it in preferences page.
MozReview-Commit-ID: KcQVPguaP1o
--- a/browser/base/content/aboutDialog-appUpdater.js
+++ b/browser/base/content/aboutDialog-appUpdater.js
@@ -22,27 +22,28 @@ function onUnload(aEvent) {
if (gAppUpdater.isChecking)
gAppUpdater.checker.stopChecking(Components.interfaces.nsIUpdateChecker.CURRENT_CHECK);
// Safe to call even when there isn't a download in progress.
gAppUpdater.removeDownloadListener();
gAppUpdater = null;
}
-function appUpdater() {
+function appUpdater(options = {}) {
XPCOMUtils.defineLazyServiceGetter(this, "aus",
"@mozilla.org/updates/update-service;1",
"nsIApplicationUpdateService");
XPCOMUtils.defineLazyServiceGetter(this, "checker",
"@mozilla.org/updates/update-checker;1",
"nsIUpdateChecker");
XPCOMUtils.defineLazyServiceGetter(this, "um",
"@mozilla.org/updates/update-manager;1",
"nsIUpdateManager");
+ this.options = options;
this.updateDeck = document.getElementById("updateDeck");
// Hide the update deck when the update window is already open and it's not
// already applied, to avoid syncing issues between them. Applied updates
// don't have any information to sync between the windows as they both just
// show the "Restart to continue"-type button.
if (Services.wm.getMostRecentWindow("Update:Wizard") &&
!this.isApplied) {
@@ -181,19 +182,25 @@ appUpdater.prototype =
let year = buildID.slice(0, 4);
let month = buildID.slice(4, 6);
let day = buildID.slice(6, 8);
updateVersion += ` (${year}-${month}-${day})`;
}
button.label = this.bundle.formatStringFromName("update.downloadAndInstallButton.label", [updateVersion], 1);
button.accessKey = this.bundle.GetStringFromName("update.downloadAndInstallButton.accesskey");
}
+ this.updateDeck.selectedPanel = panel;
+ if (this.options.buttonAutoFocus &&
+ (!document.commandDispatcher.focusedElement || // don't steal the focus
+ document.commandDispatcher.focusedElement.localName == "button")) { // except from the other buttons
+ button.focus();
+ }
+ } else {
+ this.updateDeck.selectedPanel = panel;
}
-
- this.updateDeck.selectedPanel = panel;
},
/**
* Check for updates
*/
checkForUpdates() {
// Clear prefs that could prevent a user from discovering available updates.
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CANCELATIONS_OSX)) {
--- a/browser/base/content/aboutDialog.js
+++ b/browser/base/content/aboutDialog.js
@@ -59,23 +59,17 @@ function init(aEvent) {
let relNotesURL = Services.urlFormatter.formatURLPref("app.releaseNotesURL");
if (relNotesURL != "about:blank") {
relNotesLink.href = relNotesURL;
relNotesLink.hidden = false;
}
}
if (AppConstants.MOZ_UPDATER) {
- gAppUpdater = new appUpdater();
-
- let button = gAppUpdater.updateDeck.selectedPanel.querySelector("button");
- if (button && (!document.commandDispatcher.focusedElement || // don't steal the focus
- document.commandDispatcher.focusedElement.localName == "button")) { // except from the other buttons
- button.focus();
- }
+ gAppUpdater = new appUpdater({ buttonAutoFocus: true });
let channelLabel = document.getElementById("currentChannel");
let currentChannelText = document.getElementById("currentChannelText");
channelLabel.value = UpdateUtils.UpdateChannel;
if (/^release($|\-)/.test(channelLabel.value))
currentChannelText.hidden = true;
}