Bug 1561994 - Fix test_enterprise_roots.js so it passes when security.enterprise_roots.enabled is enabled by default. r=keeler, a=test-only
Avoid race between off-main-thread loading of roots and flipping the
pref by making sure initialization is done.
Differential Revision:
https://phabricator.services.mozilla.com/D36348
--- a/security/manager/ssl/tests/unit/test_enterprise_roots.js
+++ b/security/manager/ssl/tests/unit/test_enterprise_roots.js
@@ -55,16 +55,17 @@ async function check_some_enterprise_roo
}
ok(foundNonBuiltIn, "should have found non-built-in root");
return savedDBKey;
}
add_task(async function run_test() {
let nssComponent = Cc["@mozilla.org/psm;1"].getService(Ci.nsINSSComponent);
let certDB = Cc["@mozilla.org/security/x509certdb;1"].getService(Ci.nsIX509CertDB);
+ nssComponent.getEnterpriseRoots(); // blocks until roots are loaded
Services.prefs.setBoolPref("security.enterprise_roots.enabled", false);
await check_no_enterprise_roots_imported(nssComponent, certDB);
Services.prefs.setBoolPref("security.enterprise_roots.enabled", true);
await TestUtils.topicObserved("psm:enterprise-certs-imported");
let savedDBKey = await check_some_enterprise_roots_imported(nssComponent, certDB);
Services.prefs.setBoolPref("security.enterprise_roots.enabled", false);
await check_no_enterprise_roots_imported(nssComponent, certDB, savedDBKey);
});