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/chrome/test_kebabCaseInAdjustCertInformation.html | |
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/chrome/test_kebabCaseInAdjustCertInformation.html')
-rw-r--r-- | toolkit/components/certviewer/tests/chrome/test_kebabCaseInAdjustCertInformation.html | 106 |
1 files changed, 106 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..b9f7b98d89 --- /dev/null +++ b/toolkit/components/certviewer/tests/chrome/test_kebabCaseInAdjustCertInformation.html @@ -0,0 +1,106 @@ +<!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> + <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> + </head> +<body> + <script type="module"> + 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() { + const { adjustCertInformation } = await import("chrome://global/content/certviewer/certviewer.mjs"); + const { parseOutput } = await import("./parseOutput.mjs"); + + 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> |