1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 // In safe mode, PKCS#11 modules should not be loaded. This test tests this by
8 // simulating starting in safe mode and then attempting to load a module.
13 // Simulate starting in safe mode.
16 logConsoleErrors: true,
18 XPCOMABI: "noarch-spidermonkey",
19 invalidateCachesOnRestart: function invalidateCachesOnRestart() {
22 QueryInterface: ChromeUtils.generateQI(["nsIXULRuntime"]),
25 let xulRuntimeFactory = {
27 return xulRuntime.QueryInterface(iid);
31 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
32 const XULRUNTIME_CONTRACTID = "@mozilla.org/xre/runtime;1";
33 const XULRUNTIME_CID = Components.ID(
34 "{f0f0b230-5525-4127-98dc-7bca39059e70}"
36 registrar.registerFactory(
39 XULRUNTIME_CONTRACTID,
43 // When starting in safe mode, the test module should fail to load.
44 let pkcs11ModuleDB = Cc["@mozilla.org/security/pkcs11moduledb;1"].getService(
47 let libraryName = ctypes.libraryName("pkcs11testmodule");
48 let libraryFile = Services.dirsvc.get("CurWorkD", Ci.nsIFile);
49 libraryFile.append("pkcs11testmodule");
50 libraryFile.append(libraryName);
51 ok(libraryFile.exists(), "The pkcs11testmodule file should exist");
54 pkcs11ModuleDB.addModule("PKCS11 Test Module", libraryFile.path, 0, 0),
56 "addModule should throw when in safe mode"