1 /* Any copyright is dedicated to the Public Domain.
2 * https://creativecommons.org/publicdomain/zero/1.0/ */
8 let certDialogShown = false;
9 function onCertDialogLoaded(subject) {
10 certDialogShown = true;
11 // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
13 subject.acceptDialog();
17 Services.obs.addObserver(onCertDialogLoaded, "cert-dialog-loaded");
19 function clearClientCertsDecision() {
20 let cars = Cc["@mozilla.org/security/clientAuthRememberService;1"].getService(
21 Ci.nsIClientAuthRememberService
23 cars.clearRememberedDecisions();
26 registerCleanupFunction(() => {
27 Services.obs.removeObserver(onCertDialogLoaded, "cert-dialog-loaded");
28 // Make sure we don't affect other tests.
29 clearClientCertsDecision();
32 add_task(async function () {
33 await SpecialPowers.pushPrefEnv({
34 set: [["security.default_personal_cert", "Ask Every Time"]],
37 clearClientCertsDecision();
39 let extension = ExtensionTestUtils.loadExtension({
41 permissions: ["<all_urls>"],
46 await fetch("https://requireclientcert.example.com/");
47 browser.test.notifyPass("cert_dialog_shown");
49 browser.test.fail(`${error} :: ${error.stack}`);
50 browser.test.notifyFail("cert_dialog_shown");
55 await extension.startup();
56 await extension.awaitFinish("cert_dialog_shown");
57 await extension.unload();
58 ok(certDialogShown, "Cert dialog was shown");