summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/webextensions/test/xpcshell/test_signed_long.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-10 02:51:36 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-10 02:51:36 -0500
commit37d5300335d81cecbecc99812747a657588c63eb (patch)
tree765efa3b6a56bb715d9813a8697473e120436278 /toolkit/mozapps/webextensions/test/xpcshell/test_signed_long.js
parentb2bdac20c02b12f2057b9ef70b0a946113a00e00 (diff)
parent4fb11cd5966461bccc3ed1599b808237be6b0de9 (diff)
downloadUXP-37d5300335d81cecbecc99812747a657588c63eb.tar
UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.gz
UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.lz
UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.xz
UXP-37d5300335d81cecbecc99812747a657588c63eb.zip
Merge branch 'ext-work'
Diffstat (limited to 'toolkit/mozapps/webextensions/test/xpcshell/test_signed_long.js')
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_signed_long.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/toolkit/mozapps/webextensions/test/xpcshell/test_signed_long.js b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_long.js
new file mode 100644
index 000000000..b74d7804a
--- /dev/null
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_signed_long.js
@@ -0,0 +1,49 @@
+// Disable update security
+Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
+
+gUseRealCertChecks = true;
+
+const DATA = "data/signing_checks/";
+
+const ID_63 = "123456789012345678901234567890123456789012345@tests.mozilla.org"
+const ID_64 = "1234567890123456789012345678901234567890123456@tests.mozilla.org"
+const ID_65 = "12345678901234567890123456789012345678901234568@tests.mozilla.org"
+
+function run_test() {
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
+ startupManager();
+
+ run_next_test();
+}
+
+// Installs the cases that should be working
+add_task(function* test_working() {
+ yield promiseInstallAllFiles([do_get_file(DATA + "long_63_plain.xpi"),
+ do_get_file(DATA + "long_64_plain.xpi"),
+ do_get_file(DATA + "long_65_hash.xpi")]);
+
+ let addons = yield promiseAddonsByIDs([ID_63, ID_64, ID_65]);
+
+ for (let addon of addons) {
+ do_check_neq(addon, null);
+ do_check_true(addon.signedState > AddonManager.SIGNEDSTATE_MISSING);
+
+ addon.uninstall();
+ }
+});
+
+// Checks the cases that should be broken
+add_task(function* test_broken() {
+ function promiseInstallForFile(file) {
+ return new Promise(resolve => AddonManager.getInstallForFile(file, resolve));
+ }
+
+ let promises = [promiseInstallForFile(do_get_file(DATA + "long_63_hash.xpi")),
+ promiseInstallForFile(do_get_file(DATA + "long_64_hash.xpi"))];
+ let installs = yield Promise.all(promises);
+
+ for (let install of installs) {
+ do_check_eq(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
+ do_check_eq(install.error, AddonManager.ERROR_CORRUPT_FILE);
+ }
+});