diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /security/manager/ssl/tests/mochitest/browser/browser_clientAuth_fetch_from_extension.js | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'security/manager/ssl/tests/mochitest/browser/browser_clientAuth_fetch_from_extension.js')
-rw-r--r-- | security/manager/ssl/tests/mochitest/browser/browser_clientAuth_fetch_from_extension.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/security/manager/ssl/tests/mochitest/browser/browser_clientAuth_fetch_from_extension.js b/security/manager/ssl/tests/mochitest/browser/browser_clientAuth_fetch_from_extension.js new file mode 100644 index 0000000000..4f9a45f03c --- /dev/null +++ b/security/manager/ssl/tests/mochitest/browser/browser_clientAuth_fetch_from_extension.js @@ -0,0 +1,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"); +}); |