blob: 4f9a45f03c5c544eab2faf26194744c497e92093 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/ */
/* global browser */
"use strict";
let certDialogShown = false;
function onCertDialogLoaded(subject) {
certDialogShown = true;
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
setTimeout(() => {
subject.acceptDialog();
}, 0);
}
Services.obs.addObserver(onCertDialogLoaded, "cert-dialog-loaded");
function clearClientCertsDecision() {
let cars = Cc["@mozilla.org/security/clientAuthRememberService;1"].getService(
Ci.nsIClientAuthRememberService
);
cars.clearRememberedDecisions();
}
registerCleanupFunction(() => {
Services.obs.removeObserver(onCertDialogLoaded, "cert-dialog-loaded");
// Make sure we don't affect other tests.
clearClientCertsDecision();
});
add_task(async function () {
await SpecialPowers.pushPrefEnv({
set: [["security.default_personal_cert", "Ask Every Time"]],
});
clearClientCertsDecision();
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["<all_urls>"],
},
async background() {
try {
await fetch("https://requireclientcert.example.com/");
browser.test.notifyPass("cert_dialog_shown");
} catch (error) {
browser.test.fail(`${error} :: ${error.stack}`);
browser.test.notifyFail("cert_dialog_shown");
}
},
});
await extension.startup();
await extension.awaitFinish("cert_dialog_shown");
await extension.unload();
ok(certDialogShown, "Cert dialog was shown");
});
|