Bug 1673325 - fix cert viewer's fallback to last subject entry for tab names, r=prathiksha
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 29 Oct 2020 10:33:43 +0000
changeset 555057 eda4a274a7a27f6128e3d54f0d19000355bdf1e4
parent 555056 a5b5fdf0e7d9924a57bfca8fad6390b965c14297
child 555058 b9dcf577f517002088ad839c60de7e9e900a5ab6
push id129733
push usergijskruitbosch@gmail.com
push dateThu, 29 Oct 2020 11:02:48 +0000
treeherderautoland@eda4a274a7a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersprathiksha
bugs1673325
milestone84.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1673325 - fix cert viewer's fallback to last subject entry for tab names, r=prathiksha Differential Revision: https://phabricator.services.mozilla.com/D94717
toolkit/components/certviewer/content/certviewer.js
toolkit/components/certviewer/tests/browser/browser_checkMissingCommonName.js
--- a/toolkit/components/certviewer/content/certviewer.js
+++ b/toolkit/components/certviewer/content/certviewer.js
@@ -75,17 +75,17 @@ const getElementByPathOrFalse = (obj, pa
   return result ? result : false;
 };
 
 export const adjustCertInformation = cert => {
   let certItems = [];
   let tabName = cert?.subject?.cn || "";
   if (cert && !tabName) {
     // No common name, use the value of the last item in the cert's entries.
-    tabName = cert.subject.entries?.slice(-1)[1] || "";
+    tabName = cert.subject?.entries?.slice(-1)[0]?.[1] || "";
   }
 
   if (!cert) {
     return {
       certItems,
       tabName,
     };
   }
--- a/toolkit/components/certviewer/tests/browser/browser_checkMissingCommonName.js
+++ b/toolkit/components/certviewer/tests/browser/browser_checkMissingCommonName.js
@@ -16,16 +16,20 @@ add_task(async function test_check_missi
       let tabs = certificateSection.shadowRoot.querySelector(
         ".certificate-tabs"
       ).children;
 
       Assert.ok(tabs, "Tabs were found");
       Assert.equal(tabs.length, 4, "There should be 4 tabs");
       for (let tab of tabs) {
         Assert.ok(tab.textContent, "Tab should have non-empty label");
+        Assert.notEqual(
+          tab.dataset.l10nId,
+          "certificate-viewer-unknown-group-label"
+        );
         // If there is another tab after this one, this tab should link to the
         // next via its issuer's common name or OU, if available.
         if (tab.nextElementSibling) {
           tab.click();
           let infoGroup = certificateSection.shadowRoot.querySelector(
             ".selected info-group.issuer-name"
           );
           Assert.ok(infoGroup, "infoGroup found");