tor-browser

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

browser_webconsole_certificate_messages.js (1470B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Tests that the Web Console shows weak crypto warnings (SHA-1 Certificate)
      5 
      6 "use strict";
      7 
      8 const TEST_URI =
      9  "data:text/html;charset=utf8,<!DOCTYPE html>Web Console weak crypto warnings test";
     10 const TEST_URI_PATH =
     11  "/browser/devtools/client/webconsole/test/" +
     12  "browser/test-certificate-messages.html";
     13 
     14 const TRIGGER_MSG = "If you haven't seen ssl warnings yet, you won't";
     15 const TLS_1_0_URL = "https://tls1.example.com" + TEST_URI_PATH;
     16 
     17 const TLS_expected_message =
     18  "This site uses a deprecated version of TLS. " +
     19  "Please upgrade to TLS 1.2 or 1.3.";
     20 
     21 registerCleanupFunction(function () {
     22  // Set preferences back to their original values
     23  Services.prefs.clearUserPref("security.tls.version.min");
     24  Services.prefs.clearUserPref("security.tls.version.max");
     25 });
     26 
     27 add_task(async function () {
     28  const hud = await openNewTabAndConsole(TEST_URI);
     29 
     30  info("Test TLS warnings");
     31  // Run with all versions enabled for this test.
     32  Services.prefs.setIntPref("security.tls.version.min", 1);
     33  Services.prefs.setIntPref("security.tls.version.max", 4);
     34  const onContentLog = waitForMessageByType(hud, TRIGGER_MSG, ".console-api");
     35  await navigateTo(TLS_1_0_URL);
     36  await onContentLog;
     37 
     38  const textContent = hud.ui.outputNode.textContent;
     39  ok(textContent.includes(TLS_expected_message), "TLS warning message found");
     40 
     41  Services.cache2.clear();
     42 });