Bug 1277695 Skip tests that need signing if necessary r?kmag draft
authorAndrew Swan <aswan@mozilla.com>
Fri, 03 Jun 2016 12:11:50 -0700
changeset 375282 83de02bc6c4112b4e7d81082b37922a8106109f6
parent 375281 facbccc53e0d2ec58240de5a1942166816c0599e
child 522801 d6ef1082d29194f53a8ea792911c85ecb91fe852
push id20205
push useraswan@mozilla.com
push dateFri, 03 Jun 2016 19:12:20 +0000
reviewerskmag
bugs1277695
milestone49.0a1
Bug 1277695 Skip tests that need signing if necessary r?kmag MozReview-Commit-ID: ENfAEw5WSKg
toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
@@ -1,44 +1,64 @@
+
+const {ADDON_SIGNING} = AM_Cu.import("resource://gre/modules/addons/AddonConstants.jsm", {});
+
 function run_test() {
   run_next_test();
 }
 
 let profileDir;
 add_task(function* setup() {
   profileDir = gProfD.clone();
   profileDir.append("extensions");
 
+  if (!profileDir.exists())
+    profileDir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
   startupManager();
 });
 
 const IMPLICIT_ID_XPI = "data/webext-implicit-id.xpi";
 const IMPLICIT_ID_ID = "webext_implicit_id@tests.mozilla.org";
 
 // webext-implicit-id.xpi has a minimal manifest with no
 // applications or browser_specific_settings, so its id comes
 // from its signature, which should be the ID constant defined below.
 add_task(function* test_implicit_id() {
+  // This test needs to read the xpi certificate which only works
+  // if signing is enabled.  If it is not, skip the test...
+  if (!ADDON_SIGNING) {
+    do_print("Skipped implicit_id test since ADDON_SIGNING is disabled");
+    return;
+  }
+
   let addon = yield promiseAddonByID(IMPLICIT_ID_ID);
   do_check_eq(addon, null);
 
   let xpifile = do_get_file(IMPLICIT_ID_XPI);
   yield promiseInstallAllFiles([xpifile]);
 
   addon = yield promiseAddonByID(IMPLICIT_ID_ID);
   do_check_neq(addon, null);
 
   addon.uninstall();
 });
 
 // We should also be able to install webext-implicit-id.xpi temporarily
 // and it should look just like the regular install (ie, the ID should
 // come from the signature)
 add_task(function* test_implicit_id_temp() {
+  // This test needs to read the xpi certificate which only works
+  // if signing is enabled.  If it is not, skip the test...
+  if (!ADDON_SIGNING) {
+    do_print("Skipped implicit_id_temp test since ADDON_SIGNING is disabled");
+    return;
+  }
+
   let addon = yield promiseAddonByID(IMPLICIT_ID_ID);
   do_check_eq(addon, null);
 
   let xpifile = do_get_file(IMPLICIT_ID_XPI);
   yield AddonManager.installTemporaryAddon(xpifile);
 
   addon = yield promiseAddonByID(IMPLICIT_ID_ID);
   do_check_neq(addon, null);