diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /toolkit/components/certviewer/tests/browser/browser_checkStandAlonePage.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/certviewer/tests/browser/browser_checkStandAlonePage.js')
-rw-r--r-- | toolkit/components/certviewer/tests/browser/browser_checkStandAlonePage.js | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/toolkit/components/certviewer/tests/browser/browser_checkStandAlonePage.js b/toolkit/components/certviewer/tests/browser/browser_checkStandAlonePage.js new file mode 100644 index 0000000000..02d8fdc250 --- /dev/null +++ b/toolkit/components/certviewer/tests/browser/browser_checkStandAlonePage.js @@ -0,0 +1,86 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const TYPE_CA = 1; +const TYPE_USER = 2; +const TYPE_EMAIL = 4; +const TYPE_SERVER = 8; + +add_task(async function test_dbItemDisplayed() { + await BrowserTestUtils.openNewForegroundTab(gBrowser, () => { + gBrowser.selectedTab = BrowserTestUtils.addTab( + gBrowser, + "about:certificate" + ); + }); + + let categories = [ + { + type: TYPE_CA, + tabName: "Authorities", + id: "ca", + }, + { + type: TYPE_USER, + tabName: "Your Certificates", + id: "mine", + }, + { + type: TYPE_EMAIL, + tabName: "People", + id: "people", + }, + { + type: TYPE_SERVER, + tabName: "Servers", + id: "servers", + }, + ]; + + let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService( + Ci.nsIX509CertDB + ); + Assert.ok(certdb, "certdb not null"); + let certcache = certdb.getCerts(); + Assert.ok(certcache, "certcache not null"); + + for (let cert of certcache) { + let category = categories.find(({ type }) => type & cert.certType); + + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [cert.displayName, category], + async function (displayName, category) { + let aboutCertificateSection = await ContentTaskUtils.waitForCondition( + () => { + return content.document.querySelector("about-certificate-section"); + }, + "Found aboutCertificateSection." + ); + + let tab = aboutCertificateSection.shadowRoot.querySelector( + `.certificate-tabs #certificate-viewer-tab-${category.id}` + ); + Assert.ok(tab, `${category.tabName} tab should exist.`); + tab.click(); + + let certificateItems = aboutCertificateSection.shadowRoot.querySelector( + `.info-groups #certificate-viewer-tab-${category.id}` + ); + + let listItems = + certificateItems.shadowRoot.querySelectorAll("list-item"); + + let item = Array.from(listItems).find( + i => + i.shadowRoot.querySelector(".item-name").textContent == displayName + ); + Assert.ok(item, `${displayName} should be listed`); + } + ); + } + + gBrowser.removeCurrentTab(); // closes about:certificate +}); |