Bug 1561994 - Fix test_enterprise_roots.js so it passes when security.enterprise_roots.enabled is enabled by default. r=keeler, a=test-only
authorJulien Cristau <jcristau@mozilla.com>
Fri, 28 Jun 2019 17:21:15 +0200
changeset 534092 e1fc478056d6b08a5c74c4ba94bf45ad9a00daa6
parent 534091 736e0cd202d566907831f240ab0c434b0a2b21ca
child 534093 c406e385f95d1451a36fba34f80733a663ee45d1
push id11517
push userryanvm@gmail.com
push dateFri, 28 Jun 2019 21:36:12 +0000
treeherdermozilla-beta@6d5726d82182 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskeeler, test-only
bugs1561994
milestone68.0
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
security/manager/ssl/tests/unit/test_enterprise_roots.js
--- 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);
 });