1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
2 // Any copyright is dedicated to the Public Domain.
3 // http://creativecommons.org/publicdomain/zero/1.0/
6 // Tests that adding modules with invalid names are prevented.
8 // Ensure that the appropriate initialization has happened.
12 let libraryFile = Services.dirsvc.get("CurWorkD", Ci.nsIFile);
13 libraryFile.append("pkcs11testmodule");
14 libraryFile.append(ctypes.libraryName("pkcs11testmodule"));
15 ok(libraryFile.exists(), "The pkcs11testmodule file should exist");
17 let moduleDB = Cc["@mozilla.org/security/pkcs11moduledb;1"].getService(
21 () => moduleDB.addModule("Root Certs", libraryFile.path, 0, 0),
22 /NS_ERROR_ILLEGAL_VALUE/,
23 "Adding a module named 'Root Certs' should fail."
26 () => moduleDB.addModule("", libraryFile.path, 0, 0),
27 /NS_ERROR_ILLEGAL_VALUE/,
28 "Adding a module with an empty name should fail."
31 let bundle = Services.strings.createBundle(
32 "chrome://pipnss/locale/pipnss.properties"
34 let rootsModuleName = bundle.GetStringFromName("RootCertModuleName");
35 let foundRootsModule = false;
36 for (let module of moduleDB.listModules()) {
37 if (module.name == rootsModuleName) {
38 foundRootsModule = true;
44 "Should be able to find builtin roots module by localized name."