diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /toolkit/components/certviewer/tests/chrome/test_kebabCaseInAdjustCertInformation.html | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/certviewer/tests/chrome/test_kebabCaseInAdjustCertInformation.html')
-rw-r--r-- | toolkit/components/certviewer/tests/chrome/test_kebabCaseInAdjustCertInformation.html | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/toolkit/components/certviewer/tests/chrome/test_kebabCaseInAdjustCertInformation.html b/toolkit/components/certviewer/tests/chrome/test_kebabCaseInAdjustCertInformation.html new file mode 100644 index 0000000000..663cc2baae --- /dev/null +++ b/toolkit/components/certviewer/tests/chrome/test_kebabCaseInAdjustCertInformation.html @@ -0,0 +1,110 @@ +<!DOCTYPE html> +<html> + <head> + <title>certviewer adjustCertInformation test</title> + <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <script src="chrome://global/content/certviewer/pvutils_bundle.js"></script> + <script src="chrome://global/content/certviewer/asn1js_bundle.js"></script> + <script src="chrome://global/content/certviewer/pkijs_bundle.js"></script> + + <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> + </head> +<body> + <script type="module"> + import { adjustCertInformation } from "chrome://global/content/certviewer/certviewer.js"; + import { parseOutput } from "./parseOutput.js"; + + function isKebabCase(str) { + if (str === "") return true; + return /^([a-z][a-z0-9]*)(-[a-z0-9]+)*$/.test(str); + } + + function validateIsKebabCase() { + let tests = [ + { + input: "", + expected: true + }, + { + input: "A", + expected: false + }, + { + input: "Ab", + expected: false + }, + { + input: "Ab-ad", + expected: false + }, + { + input: "ad-Az", + expected: false + }, + { + input: "ad- z", + expected: false + }, + { + input: "ad-z ", + expected: false + }, + { + input: "ad z", + expected: false + }, + { + input: "ad--fz", + expected: false + }, + { + input: "-a-b-c", + expected: false + }, + { + input: "ad-fz", + expected: true + }, + { + input: "ad", + expected: true + }, + { + input: "a-b-c", + expected: true + }, + ]; + + for (let test of tests) { + let result = isKebabCase(test.input); + is(result, test.expected, `${test.input} should${test.expected === false ? "n't" : ""} be a kebab-case string`); + } + } + + async function doTest() { + ok(adjustCertInformation, "adjustCertInformation should be available in this context"); + ok(parseOutput, "parseOutput should be available in this context"); + is(typeof(parseOutput), 'object', "parseOutput must be an object"); + + validateIsKebabCase(); + + for (let cert of parseOutput) { + let adjustedCerts = adjustCertInformation(cert); + adjustedCerts.certItems.forEach(item => { + ok(isKebabCase(item.sectionId), `${item.sectionId} should be a valid kebab-case string`); + item.sectionItems.forEach(element => { + ok(isKebabCase(element.label), `${element.label} should be a valid kebab-case string`); + }); + }); + } + + SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + doTest(); + + </script> +</body> +</html> |