summaryrefslogtreecommitdiffstats
path: root/toolkit/components/certviewer/tests/browser/browser_certificateTabLink.js
blob: 9c88d2bb030a88256ee044e1121078b1470230d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const validCert =
  "about:certificate?cert=MIIGMDCCBRigAwIBAgIQCa2oS7Nau6nwv1WyRNIJnzANBgkqhkiG9w0BAQsFADBwMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMS8wLQYDVQQDEyZEaWdpQ2VydCBTSEEyIEhpZ2ggQXNzdXJhbmNlIFNlcnZlciBDQTAeFw0xOTA2MDYwMDAwMDBaFw0xOTA5MDQxMjAwMDBaMGExCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTETMBEGA1UEBxMKTWVubG8gUGFyazEXMBUGA1UEChMORmFjZWJvb2ssIEluYy4xFzAVBgNVBAMMDiouZmFjZWJvb2suY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEALPlfjd8gHkIMDeBOFhRt0e%2B%2F3fdm%2BZdzdM4s1WIHVbYztgmdEy20PUwDCviYKJX4GG%2BT9ivT8kJ%2FvWl1P%2FYqOCA54wggOaMB8GA1UdIwQYMBaAFFFo%2F5CvAgd1PMzZZWRiohK4WXI7MB0GA1UdDgQWBBTsQZVRTuib7KY9w3FfOYsZHvOC9zCBxwYDVR0RBIG%2FMIG8gg4qLmZhY2Vib29rLmNvbYINbWVzc2VuZ2VyLmNvbYILKi5mYmNkbi5uZXSCCCouZmIuY29tghAqLm0uZmFjZWJvb2suY29tggZmYi5jb22CDiouZmFjZWJvb2submV0gg4qLnh4LmZiY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F5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2%2FS6cCZdkGCevEsXCS%2B0yx5DaMkHJ8HSXPfqIbloEpw8nL%2Be%2FIBcm2PN7EeqJSdnoDfzAIJ9VNep%2BOkuE6N36B9K";

add_task(async function test_certificateTabLink() {
  await BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, validCert);
  });

  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () {
    let certificateTabs;
    await ContentTaskUtils.waitForCondition(() => {
      certificateTabs = content.document
        .querySelector("certificate-section")
        .shadowRoot.querySelectorAll(".certificate-tab");
      return certificateTabs.length;
    }, "Found certificate tabs.");

    ok(certificateTabs.length, "Certificate tabs should exist.");

    let issuerNameGroups = content.document
      .querySelector("certificate-section")
      .shadowRoot.querySelectorAll(".issuer-name");
    let issuerNames = [];
    for (let i = 0; i < issuerNameGroups.length; i++) {
      issuerNames.push(
        issuerNameGroups[i].shadowRoot.querySelector(".common-name")
      );
    }

    for (let i = 0; i < issuerNames.length; i++) {
      if (i < issuerNames.length - 1) {
        issuerNames[i].shadowRoot.querySelector("a").click();
        await ContentTaskUtils.waitForCondition(() => {
          return certificateTabs[i + 1].classList.contains("selected");
        }, "Clicking link should select new tab.");
        ok(
          certificateTabs[i + 1].classList.contains("selected"),
          "Clicking link should select new tab."
        );
      } else {
        await ContentTaskUtils.waitForCondition(() => {
          return certificateTabs[i].classList.contains("selected");
        }, "Clicking link should select new tab.");
        ok(
          certificateTabs[i].classList.contains("selected"),
          "Clicking link should select new tab."
        );
        ok(
          !issuerNames[i].shadowRoot.querySelector("a"),
          "Final tab's issuer name should not be link."
        );
      }
    }
  });
  gBrowser.removeCurrentTab(); // closes about:certificate
});