Bug 1242966 - Make services/crypto eslintable. r?rnewman
--- a/services/crypto/modules/WeaveCrypto.js
+++ b/services/crypto/modules/WeaveCrypto.js
@@ -2,20 +2,22 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
this.EXPORTED_SYMBOLS = ["WeaveCrypto"];
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
+var Cu = Components.utils;
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/ctypes.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/ctypes.jsm");
+Cu.import('resource://gre/modules/AppConstants.jsm');
/**
* Shortcuts for some algorithm SEC OIDs. Full list available here:
* http://lxr.mozilla.org/seamonkey/source/security/nss/lib/util/secoidt.h
*/
const DES_EDE3_CBC = 156;
const AES_128_CBC = 184;
const AES_192_CBC = 186;
@@ -127,26 +129,26 @@ WeaveCrypto.prototype = {
// implicitly initialize NSS.
Cc["@mozilla.org/psm;1"].getService(Ci.nsISupports);
// Open the NSS library.
let path = ctypes.libraryName("nss3");
// XXX really want to be able to pass specific dlopen flags here.
var nsslib;
-#ifdef MOZ_NATIVE_NSS
- // Search platform-dependent library paths for system NSS.
- this.log("Trying NSS library without path");
- nsslib = ctypes.open(path);
-#else
- let file = Services.dirsvc.get("GreBinD", Ci.nsILocalFile);
- file.append(path);
- this.log("Trying NSS library with path " + file.path);
- nsslib = ctypes.open(file.path);
-#endif
+ if (AppConstants.MOZ_NATIVE_NSS) {
+ // Search platform-dependent library paths for system NSS.
+ this.log("Trying NSS library without path");
+ nsslib = ctypes.open(path);
+ } else {
+ let file = Services.dirsvc.get("GreBinD", Ci.nsILocalFile);
+ file.append(path);
+ this.log("Trying NSS library with path " + file.path);
+ nsslib = ctypes.open(file.path);
+ }
this.log("Initializing NSS types and function declarations...");
this.nss = {};
this.nss_t = {};
// nsprpub/pr/include/prtypes.h#435
// typedef PRIntn PRBool; --> int
--- a/services/crypto/moz.build
+++ b/services/crypto/moz.build
@@ -8,20 +8,14 @@ with Files('**'):
BUG_COMPONENT = ('Mozilla Services', 'Firefox Sync: Crypto')
DIRS += ['component']
XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
EXTRA_JS_MODULES['services-crypto'] += [
'modules/utils.js',
-]
-
-EXTRA_PP_JS_MODULES['services-crypto'] += [
'modules/WeaveCrypto.js',
]
EXTRA_COMPONENTS += [
'cryptoComponents.manifest',
]
-
-if CONFIG['MOZ_NATIVE_NSS']:
- DEFINES['MOZ_NATIVE_NSS'] = 1
--- a/toolkit/modules/AppConstants.jsm
+++ b/toolkit/modules/AppConstants.jsm
@@ -235,16 +235,23 @@ this.AppConstants = Object.freeze({
MOZ_GRAPHENE:
#ifdef MOZ_GRAPHENE
true,
#else
false,
#endif
+ MOZ_NATIVE_NSS:
+#ifdef MOZ_NATIVE_NSS
+ true,
+#else
+ false,
+#endif
+
MOZ_PLACES:
#ifdef MOZ_PLACES
true,
#else
false,
#endif
MOZ_REQUIRE_SIGNING:
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -113,11 +113,12 @@ for var in ('ANDROID_PACKAGE_NAME',
'DLL_PREFIX',
'DLL_SUFFIX',
'DEBUG_JS_MODULES',
'SOURCE_REV_URL'):
DEFINES[var] = CONFIG[var]
for var in ('MOZ_TOOLKIT_SEARCH',
'MOZ_REQUIRE_SIGNING',
+ 'MOZ_NATIVE_NSS',
'MOZ_UPDATER'):
if CONFIG[var]:
DEFINES[var] = True