tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_net_security-details.js (3883B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Test that Security details tab contains the expected data.
      8 */
      9 
     10 add_task(async function () {
     11  await pushPref("security.pki.certificate_transparency.mode", 1);
     12 
     13  const { tab, monitor } = await initNetMonitor(CUSTOM_GET_URL, {
     14    requestCount: 1,
     15  });
     16  const { document, store, windowRequire } = monitor.panelWin;
     17  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     18 
     19  store.dispatch(Actions.batchEnable(false));
     20 
     21  info("Performing a secure request.");
     22  const REQUESTS_URL = "https://example.com" + CORS_SJS_PATH;
     23  const wait = waitForNetworkEvents(monitor, 1);
     24  await SpecialPowers.spawn(
     25    tab.linkedBrowser,
     26    [REQUESTS_URL],
     27    async function (url) {
     28      content.wrappedJSObject.performRequests(1, url);
     29    }
     30  );
     31  await wait;
     32 
     33  info("Wait until the Security Tab is visible");
     34  const waitForSecurityTab = waitForDOM(document, "#security-tab");
     35  store.dispatch(Actions.toggleNetworkDetails());
     36  await waitForSecurityTab;
     37 
     38  info("Selecting the Security Tab");
     39  clickOnSidebarTab(document, "security");
     40  await waitUntil(() =>
     41    document.querySelector("#security-panel .security-info-value")
     42  );
     43 
     44  const tabpanel = document.querySelector("#security-panel");
     45  const textboxes = tabpanel.querySelectorAll(".security-info-value");
     46 
     47  // Connection
     48  // The protocol will be TLS but the exact version depends on which protocol
     49  // the test server example.com supports.
     50  const protocol = textboxes[0].textContent;
     51  ok(protocol.startsWith('"TLS'), "The protocol " + protocol + " seems valid.");
     52 
     53  // The cipher suite used by the test server example.com might change at any
     54  // moment but all of them should start with "TLS_".
     55  // http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml
     56  const suite = textboxes[1].textContent;
     57  ok(suite.startsWith('"TLS_'), "The suite " + suite + " seems valid.");
     58 
     59  // Host
     60  is(
     61    tabpanel.querySelectorAll(".treeLabel.objectLabel")[1].textContent,
     62    "Host example.com:",
     63    "Label has the expected value."
     64  );
     65  // These two values can change. So only check they're not empty.
     66  Assert.notStrictEqual(
     67    textboxes[2].textContent,
     68    "",
     69    "Label value is not empty."
     70  );
     71  Assert.notStrictEqual(
     72    textboxes[3].textContent,
     73    "",
     74    "Label value is not empty."
     75  );
     76  is(textboxes[4].textContent, '"Disabled"', "Label has the expected value.");
     77  is(textboxes[5].textContent, '"Disabled"', "Label has the expected value.");
     78 
     79  // Cert
     80  is(
     81    textboxes[6].textContent,
     82    '"example.com"',
     83    "Label has the expected value."
     84  );
     85  is(
     86    textboxes[7].textContent,
     87    '"<Not Available>"',
     88    "Label has the expected value."
     89  );
     90  is(
     91    textboxes[8].textContent,
     92    '"<Not Available>"',
     93    "Label has the expected value."
     94  );
     95 
     96  is(
     97    textboxes[9].textContent,
     98    '"Temporary Certificate Authority"',
     99    "Label has the expected value."
    100  );
    101  is(
    102    textboxes[10].textContent,
    103    '"Mozilla Testing"',
    104    "Label has the expected value."
    105  );
    106  is(
    107    textboxes[11].textContent,
    108    '"Profile Guided Optimization"',
    109    "Label has the expected value."
    110  );
    111 
    112  // Locale sensitive and varies between timezones. Can't compare equality or
    113  // the test fails depending on which part of the world the test is executed.
    114 
    115  // cert validity begins
    116  isnot(textboxes[12].textContent, "", "Label was not empty.");
    117  // cert validity expires
    118  isnot(textboxes[13].textContent, "", "Label was not empty.");
    119 
    120  // cert sha1 fingerprint
    121  isnot(textboxes[14].textContent, "", "Label was not empty.");
    122  // cert sha256 fingerprint
    123  isnot(textboxes[15].textContent, "", "Label was not empty.");
    124 
    125  // Certificate transparency
    126  isnot(textboxes[16].textContent, "", "Label was not empty.");
    127 
    128  await teardown(monitor);
    129 });