diff --git a/application/basilisk/base/content/browser-addons.js b/application/basilisk/base/content/browser-addons.js index 2cbb1da864..0740c513fb 100644 --- a/application/basilisk/base/content/browser-addons.js +++ b/application/basilisk/base/content/browser-addons.js @@ -334,10 +334,27 @@ const gXPInstallObserver = { messageString = gNavigatorBundle.getFormattedString(error, args); - if (install.error == AddonManager.ERROR_CORRUPT_FILE && - install.errorDetail && - typeof install.errorDetail == "string") { - messageString += "\n" + "Details: " + install.errorDetail; + if (install.error == AddonManager.ERROR_CORRUPT_FILE) { + let detail = null; + if (install.errorDetail !== undefined && install.errorDetail !== null) { + detail = install.errorDetail; + if (typeof detail != "string") { + if (detail && typeof detail.message == "string" && detail.message) { + detail = detail.message; + } else { + detail = String(detail); + } + } + detail = detail.replace(/[\r\n\t]+/g, " ").trim(); + } + + let detailString; + if (detail) { + detailString = gNavigatorBundle.getFormattedString("addonInstallErrorDetail", [detail]); + } else { + detailString = gNavigatorBundle.getFormattedString("addonInstallErrorDetailCode", [String(install.error)]); + } + messageString += " " + detailString; } PopupNotifications.show(browser, notificationID, messageString, anchorID, diff --git a/application/basilisk/locales/en-US/chrome/browser/browser.properties b/application/basilisk/locales/en-US/chrome/browser/browser.properties index 572c976a19..8f34a10cd9 100644 --- a/application/basilisk/locales/en-US/chrome/browser/browser.properties +++ b/application/basilisk/locales/en-US/chrome/browser/browser.properties @@ -93,6 +93,8 @@ addonLocalInstallError-4=%2$S could not be installed because %1$S cannot modify addonLocalInstallError-5=This add-on could not be installed because it has not been verified. addonLocalInstallError-8=%2$S could not be installed because %1$S does not support Jetpack (SDK) extensions. addonLocalInstallError-9=%2$S could not be installed because %1$S does not support WebExtensions. +addonInstallErrorDetail=Reason: %S +addonInstallErrorDetailCode=Reason code: %S # LOCALIZATION NOTE (addonInstallErrorIncompatible): diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index c2ca8ab8a9..08b6afa528 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -4926,6 +4926,17 @@ AddonInstall.prototype = { logger.warn("Invalid XPI", e); this.error = AddonManager.ERROR_CORRUPT_FILE; } + if (e !== undefined && e !== null) { + if (typeof e == "string") { + this.errorDetail = e; + } else if (e && typeof e.message == "string" && e.message) { + this.errorDetail = e.message; + } else { + this.errorDetail = String(e); + } + } else { + this.errorDetail = null; + } aCallback(this); return; } @@ -4981,6 +4992,7 @@ AddonInstall.prototype = { this.removeTemporaryFile(); this.state = AddonManager.STATE_AVAILABLE; this.error = 0; + this.errorDetail = null; this.progress = 0; this.maxProgress = -1; this.hash = this.originalHash; @@ -5870,6 +5882,17 @@ AddonInstall.prototype = { recursiveRemove(stagedAddon); this.state = AddonManager.STATE_INSTALL_FAILED; this.error = AddonManager.ERROR_FILE_ACCESS; + if (e !== undefined && e !== null) { + if (typeof e == "string") { + this.errorDetail = e; + } else if (e && typeof e.message == "string" && e.message) { + this.errorDetail = e.message; + } else { + this.errorDetail = String(e); + } + } else { + this.errorDetail = null; + } XPIProvider.removeActiveInstall(this); AddonManagerPrivate.callAddonListeners("onOperationCancelled", createWrapper(this.addon)); diff --git a/toolkit/mozapps/webextensions/internal/XPIProvider.jsm b/toolkit/mozapps/webextensions/internal/XPIProvider.jsm index 24ea811ada..2c04522592 100644 --- a/toolkit/mozapps/webextensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/webextensions/internal/XPIProvider.jsm @@ -5735,6 +5735,17 @@ class AddonInstall { recursiveRemove(stagedAddon); this.state = AddonManager.STATE_INSTALL_FAILED; this.error = AddonManager.ERROR_FILE_ACCESS; + if (e !== undefined && e !== null) { + if (typeof e == "string") { + this.errorDetail = e; + } else if (e && typeof e.message == "string" && e.message) { + this.errorDetail = e.message; + } else { + this.errorDetail = String(e); + } + } else { + this.errorDetail = null; + } XPIProvider.removeActiveInstall(this); AddonManagerPrivate.callAddonListeners("onOperationCancelled", this.addon.wrapper); @@ -5919,6 +5930,17 @@ class LocalAddonInstall extends AddonInstall { logger.warn("Invalid XPI", message); this.state = AddonManager.STATE_DOWNLOAD_FAILED; this.error = error; + if (message !== undefined && message !== null) { + if (typeof message == "string") { + this.errorDetail = message; + } else if (message && typeof message.message == "string" && message.message) { + this.errorDetail = message.message; + } else { + this.errorDetail = String(message); + } + } else { + this.errorDetail = null; + } XPIProvider.removeActiveInstall(this); AddonManagerPrivate.callInstallListeners("onNewInstall", this.listeners, @@ -6031,6 +6053,7 @@ class DownloadAddonInstall extends AddonInstall { this.removeTemporaryFile(); this.state = AddonManager.STATE_AVAILABLE; this.error = 0; + this.errorDetail = null; this.progress = 0; this.maxProgress = -1; this.hash = this.originalHash; @@ -6102,6 +6125,17 @@ class DownloadAddonInstall extends AddonInstall { logger.warn("Failed to start download for addon " + this.sourceURI.spec, e); this.state = AddonManager.STATE_DOWNLOAD_FAILED; this.error = AddonManager.ERROR_FILE_ACCESS; + if (e !== undefined && e !== null) { + if (typeof e == "string") { + this.errorDetail = e; + } else if (e && typeof e.message == "string" && e.message) { + this.errorDetail = e.message; + } else { + this.errorDetail = String(e); + } + } else { + this.errorDetail = null; + } XPIProvider.removeActiveInstall(this); AddonManagerPrivate.callInstallListeners("onDownloadFailed", this.listeners, this.wrapper);