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 the platform can load the osclientcerts module.
8 // Ensure that the appropriate initialization has happened.
9 Services.prefs.setBoolPref("security.osclientcerts.autoload", false);
12 const { TestUtils } = ChromeUtils.importESModule(
13 "resource://testing-common/TestUtils.sys.mjs"
16 async function check_osclientcerts_module_loaded() {
17 // Loading happens asynchronously, so we have to wait for the notification.
18 await TestUtils.topicObserved("psm:load-os-client-certs-module-task-ran");
19 let testModule = checkPKCS11ModuleExists(
20 "OS Client Cert Module",
24 // Check that listing the slots for the osclientcerts module works.
25 let testModuleSlotNames = Array.from(
26 testModule.listSlots(),
29 testModuleSlotNames.sort();
30 const expectedSlotNames = ["OS Client Cert Slot"];
34 "Actual and expected slot names should be equal"
38 add_task(async function run_test() {
39 // Check that if we haven't loaded the osclientcerts module, we don't find it
40 // in the module list.
41 checkPKCS11ModuleNotPresent("OS Client Cert Module", "osclientcerts");
43 // Check that enabling the pref that loads the osclientcerts module makes it
44 // appear in the module list.
45 Services.prefs.setBoolPref("security.osclientcerts.autoload", true);
46 await check_osclientcerts_module_loaded();
48 // Check that disabling the pref that loads the osclientcerts module (thus
49 // unloading the module) makes it disappear from the module list.
50 Services.prefs.setBoolPref("security.osclientcerts.autoload", false);
51 checkPKCS11ModuleNotPresent("OS Client Cert Module", "osclientcerts");
53 // Check that loading the module again succeeds.
54 Services.prefs.setBoolPref("security.osclientcerts.autoload", true);
55 await check_osclientcerts_module_loaded();
57 // And once more check that unloading succeeds.
58 Services.prefs.setBoolPref("security.osclientcerts.autoload", false);
59 checkPKCS11ModuleNotPresent("OS Client Cert Module", "osclientcerts");