Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
/* Any copyright is dedicated to the Public Domain.
"use strict";
const validCert =
"about:certificate?cert=MIIGMDCCBRigAwIBAgIQCa2oS7Nau6nwv1WyRNIJnzANBgkqhkiG9w0BAQsFADBwMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMS8wLQYDVQQDEyZEaWdpQ2VydCBTSEEyIEhpZ2ggQXNzdXJhbmNlIFNlcnZlciBDQTAeFw0xOTA2MDYwMDAwMDBaFw0xOTA5MDQxMjAwMDBaMGExCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTETMBEGA1UEBxMKTWVubG8gUGFyazEXMBUGA1UEChMORmFjZWJvb2ssIEluYy4xFzAVBgNVBAMMDiouZmFjZWJvb2suY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEALPlfjd8gHkIMDeBOFhRt0e%2B%2F3fdm%2BZdzdM4s1WIHVbYztgmdEy20PUwDCviYKJX4GG%2BT9ivT8kJ%2FvWl1P%2FYqOCA54wggOaMB8GA1UdIwQYMBaAFFFo%2F5CvAgd1PMzZZWRiohK4WXI7MB0GA1UdDgQWBBTsQZVRTuib7KY9w3FfOYsZHvOC9zCBxwYDVR0RBIG%2FMIG8gg4qLmZhY2Vib29rLmNvbYINbWVzc2VuZ2VyLmNvbYILKi5mYmNkbi5uZXSCCCouZmIuY29tghAqLm0uZmFjZWJvb2suY29tggZmYi5jb22CDiouZmFjZWJvb2submV0gg4qLnh4LmZiY2RuLm5ldIIOKi54ei5mYmNkbi5uZXSCDyoubWVzc2VuZ2VyLmNvbYILKi5mYnNieC5jb22CDioueHkuZmJjZG4ubmV0ggxmYWNlYm9vay5jb20wDgYDVR0PAQH%2FBAQDAgeAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjB1BgNVHR8EbjBsMDSgMqAwhi5odHRwOi8vY3JsMy5ka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CkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm%2B9S75S0tMqbf5YE%2Fyc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG%2B%2BMXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx%2BmM0aBhakaHPQNAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH%2FBAQDAgGGMA8GA1UdEwEB%2FwQFMAMBAf8wHQYDVR0OBBYEFLE%2Bw2kD%2BL9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE%2Bw2kD%2BL9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe%2FEW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9%2BMpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2Yzi9RKR%2F5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2%2FS6cCZdkGCevEsXCS%2B0yx5DaMkHJ8HSXPfqIbloEpw8nL%2Be%2FIBcm2PN7EeqJSdnoDfzAIJ9VNep%2BOkuE6N36B9K";
add_task(async function test_checkForErrorSection() {
await BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, validCert);
});
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () {
let infoGroups;
let downloadLinkContainers = [];
await ContentTaskUtils.waitForCondition(() => {
infoGroups = content.document
.querySelector("certificate-section")
.shadowRoot.querySelectorAll(".miscellaneous");
for (let i = 0; i < infoGroups.length; i++) {
downloadLinkContainers.push(
infoGroups[i].shadowRoot
.querySelector(".download")
.shadowRoot.querySelector(".info")
);
}
return downloadLinkContainers.length;
}, "Found download info items.");
ok(downloadLinkContainers.length, "Download info items should exist.");
let certTabs = content.document
.querySelector("certificate-section")
.shadowRoot.querySelectorAll(".certificate-tab");
await ContentTaskUtils.waitForCondition(
() => certTabs.length,
"Certificate tabs should exist."
);
let url = new URL(content.document.documentURI);
let certs = url.searchParams.getAll("cert");
let certChain = [];
for (let i = 0; i < certs.length; i++) {
certChain.push(
`-----BEGIN CERTIFICATE-----\r\n${certs[i]}\r\n-----END CERTIFICATE-----\r\n`
);
}
certChain = certChain.join("").replace(/(\r\n|\n|\r)/gm, "");
for (let i = 0; i < certTabs.length; i++) {
let downloadLink =
downloadLinkContainers[i].querySelector(".download-link");
let downloadChainLink = downloadLinkContainers[i].querySelector(
".download-link-chain"
);
let cert = certs[i];
cert = `-----BEGIN CERTIFICATE-----\r\n${cert}\r\n-----END CERTIFICATE-----\r\n`;
cert = cert.replace(/(\r\n|\n|\r)/gm, "");
let linkCert = downloadLink.getAttribute("href");
linkCert = linkCert.replace("data:,", "");
linkCert = decodeURI(linkCert);
let certLineLength = Math.max(
...linkCert.split(/\r\n|\n|\r/m).map(x => x.length)
);
linkCert = linkCert.replace(/(\r\n|\n|\r)/gm, "");
let downloadChainCert = downloadChainLink.getAttribute("href");
downloadChainCert = downloadChainCert.replace("data:,", "");
downloadChainCert = decodeURI(downloadChainCert);
let chainLineLength = Math.max(
...downloadChainCert.split(/\r\n|\n|\r/m).map(x => x.length)
);
downloadChainCert = downloadChainCert.replace(/(\r\n|\n|\r)/gm, "");
Assert.lessOrEqual(
certLineLength,
64,
"PEM cert line length should be capped to 64"
);
Assert.lessOrEqual(
chainLineLength,
64,
"PEM chain line length should be capped to 64"
);
Assert.equal(
cert,
linkCert,
"Download link href should be equal to URL cert."
);
Assert.equal(
certChain,
downloadChainCert,
"Download chain link href should be equal to URL cert."
);
await content.document.l10n.translateElements([
downloadChainLink,
downloadLink,
]);
Assert.equal(
downloadLinkContainers[i].textContent,
"PEM (cert)PEM (chain)",
"Download should contain links to PEM cert and PEM chain."
);
if (certTabs[i + 1]) {
certTabs[i + 1].click();
await ContentTaskUtils.waitForCondition(
() => certTabs[i + 1].classList.contains("selected"),
"Cert tab should be selected"
);
}
}
});
gBrowser.removeCurrentTab(); // closes about:certificate
});