/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

async function checkLongHex(url, itemClass) {
  await BrowserTestUtils.withNewTab(url, async function(browser) {
    await SpecialPowers.spawn(browser, [itemClass], async function(itemClass) {
      let certificateSection = await ContentTaskUtils.waitForCondition(() => {
        return content.document.querySelector("certificate-section");
      }, "Certificate section found");
      let publicKeyInfoSection = certificateSection.shadowRoot.querySelector(
        ".public-key-info"
      );
      Assert.ok(publicKeyInfoSection, "publicKeyInfoSection found");

      let item = publicKeyInfoSection.shadowRoot.querySelector(`.${itemClass}`);
      Assert.ok(item, `item ${itemClass} found`);

      let longHex = item.shadowRoot.querySelector(".long-hex");
      Assert.ok(longHex, "longHex class name found");
    });
  });
}

add_task(async function test() {
  let tests = [
    {
      url:
        "about:certificate?cert=MIIHQjCCBiqgAwIBAgIQCgYwQn9bvO1pVzllk7ZFHzANBgkqhkiG9w0BAQsFADB1MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMTQwMgYDVQQDEytEaWdpQ2VydCBTSEEyIEV4dGVuZGVkIFZhbGlkYXRpb24gU2VydmVyIENBMB4XDTE4MDUwODAwMDAwMFoXDTIwMDYwMzEyMDAwMFowgccxHTAbBgNVBA8MFFByaXZhdGUgT3JnYW5pemF0aW9uMRMwEQYLKwYBBAGCNzwCAQMTAlVTMRkwFwYLKwYBBAGCNzwCAQITCERlbGF3YXJlMRAwDgYDVQQFEwc1MTU3NTUwMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEVMBMGA1UEChMMR2l0SHViLCBJbmMuMRMwEQYDVQQDEwpnaXRodWIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxjyq8jyXDDrBTyitcnB90865tWBzpHSbindG%2FXqYQkzFMBlXmqkzC%2BF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9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9%2BE7gUJTb0o2HLO02JQZR7rkpeDMdmztcpHWD9f",
      itemClass: "public-value",
    },
  ];

  for (let test of tests) {
    await checkLongHex(test.url, test.itemClass);
  }
});
