summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustOff <Off.Just.Off@gmail.com>2017-10-04 15:54:28 +0300
committerJustOff <Off.Just.Off@gmail.com>2017-10-04 15:54:28 +0300
commitbd7848fd1b9bfd5afdbaf4889c1ae2b026f98b21 (patch)
tree43dd4dc650157e371773f16f2696145363d1df8c
parentd41b54081d296de88f465045673ff61030d3b2a5 (diff)
downloadpalemoon-gre-bd7848fd1b9bfd5afdbaf4889c1ae2b026f98b21.tar.gz
Display "not supported" error when trying to install WebExtension
-rw-r--r--browser/locales/en-US/chrome/browser/browser.properties2
-rw-r--r--toolkit/mozapps/extensions/AddonManager.jsm2
-rw-r--r--toolkit/mozapps/extensions/internal/XPIProvider.jsm28
3 files changed, 28 insertions, 4 deletions
diff --git a/browser/locales/en-US/chrome/browser/browser.properties b/browser/locales/en-US/chrome/browser/browser.properties
index 2de941b6c..85c50b193 100644
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -58,6 +58,7 @@ addonError-1=The add-on could not be downloaded because of a connection failure
addonError-2=The add-on from #2 could not be installed because it does not match the add-on #3 expected.
addonError-3=The add-on downloaded from #2 could not be installed because it appears to be corrupt.
addonError-4=#1 could not be installed because #3 cannot modify the needed file.
+addonError-5=The add-on downloaded from #2 could not be installed because #3 does not support WebExtensions.
# LOCALIZATION NOTE (addonLocalError-1, addonLocalError-2, addonLocalError-3, addonLocalError-4, addonErrorIncompatible, addonErrorBlocklisted):
# #1 is the add-on name, #3 is the application name, #4 is the application version
@@ -65,6 +66,7 @@ addonLocalError-1=This add-on could not be installed because of a filesystem err
addonLocalError-2=This add-on could not be installed because it does not match the add-on #3 expected.
addonLocalError-3=This add-on could not be installed because it appears to be corrupt.
addonLocalError-4=#1 could not be installed because #3 cannot modify the needed file.
+addonLocalError-5=This add-on could not be installed because #3 does not support WebExtensions.
addonErrorIncompatible=#1 could not be installed because it is not compatible with #3 #4.
addonErrorBlocklisted=#1 could not be installed because it has a high risk of causing stability or security problems.
addonErrorJetSDK=#1 could not be installed because it is a Jetpack/SDK extension which are not supported in #3 #4.
diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm
index 814fbd3e4..eacc0fd7c 100644
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -2678,6 +2678,8 @@ this.AddonManager = {
ERROR_CORRUPT_FILE: -3,
// An error occured trying to write to the filesystem.
ERROR_FILE_ACCESS: -4,
+ // The downloaded file seems to be WebExtension.
+ ERROR_WEBEXT_FILE: -5,
// These must be kept in sync with AddonUpdateChecker.
// No error was encountered.
diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
index 96bcbf869..ef9b016ef 100644
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -106,6 +106,7 @@ const DIR_TRASH = "trash";
const FILE_DATABASE = "extensions.json";
const FILE_OLD_CACHE = "extensions.cache";
const FILE_INSTALL_MANIFEST = "install.rdf";
+const FILE_WEBEXT_MANIFEST = "manifest.json";
const FILE_XPI_ADDONS_LIST = "extensions.ini";
const KEY_PROFILEDIR = "ProfD";
@@ -1065,7 +1066,17 @@ function loadManifestFromDir(aDir) {
* @throws if the XPI file does not contain a valid install manifest
*/
function loadManifestFromZipReader(aZipReader) {
- let zis = aZipReader.getInputStream(FILE_INSTALL_MANIFEST);
+ let zis;
+ try {
+ zis = aZipReader.getInputStream(FILE_INSTALL_MANIFEST);
+ } catch (e) {
+ let zws = aZipReader.getInputStream(FILE_WEBEXT_MANIFEST);
+ throw {
+ name: e.name,
+ message: e.message,
+ webext: true
+ };
+ }
let bis = Cc["@mozilla.org/network/buffered-input-stream;1"].
createInstance(Ci.nsIBufferedInputStream);
bis.init(zis, 4096);
@@ -4979,9 +4990,14 @@ AddonInstall.prototype = {
});
}
catch (e) {
- logger.warn("Invalid XPI", e);
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
- this.error = AddonManager.ERROR_CORRUPT_FILE;
+ if (e.webext) {
+ logger.warn("WebExtension XPI", e);
+ this.error = AddonManager.ERROR_WEBEXT_FILE;
+ } else {
+ logger.warn("Invalid XPI", e);
+ this.error = AddonManager.ERROR_CORRUPT_FILE;
+ }
aCallback(this);
return;
}
@@ -5621,7 +5637,11 @@ AddonInstall.prototype = {
});
}
catch (e) {
- this.downloadFailed(AddonManager.ERROR_CORRUPT_FILE, e);
+ if (e.webext) {
+ this.downloadFailed(AddonManager.ERROR_WEBEXT_FILE, e);
+ } else {
+ this.downloadFailed(AddonManager.ERROR_CORRUPT_FILE, e);
+ }
}
}
else {