tor-browser

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

test_security-info-weakness-reasons.js (942B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 // Tests that NetworkHelper.getReasonsForWeakness returns correct reasons for
      6 // weak requests.
      7 
      8 const wpl = Ci.nsIWebProgressListener;
      9 const TEST_CASES = [
     10  {
     11    description: "weak cipher",
     12    input: wpl.STATE_IS_BROKEN | wpl.STATE_USES_WEAK_CRYPTO,
     13    expected: ["cipher"],
     14  },
     15  {
     16    description: "only STATE_IS_BROKEN flag",
     17    input: wpl.STATE_IS_BROKEN,
     18    expected: [],
     19  },
     20  {
     21    description: "only STATE_IS_SECURE flag",
     22    input: wpl.STATE_IS_SECURE,
     23    expected: [],
     24  },
     25 ];
     26 
     27 function run_test() {
     28  info("Testing NetworkHelper.getReasonsForWeakness.");
     29 
     30  for (const { description, input, expected } of TEST_CASES) {
     31    info("Testing " + description);
     32 
     33    deepEqual(
     34      NetworkHelper.getReasonsForWeakness(input),
     35      expected,
     36      "Got the expected reasons for weakness."
     37    );
     38  }
     39 }