test_security-info-protocol-version.js (975B)
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.formatSecurityProtocol returns correct 6 // protocol version strings. 7 8 const TEST_CASES = [ 9 { 10 description: "TLS_VERSION_1", 11 input: 1, 12 expected: "TLSv1", 13 }, 14 { 15 description: "TLS_VERSION_1.1", 16 input: 2, 17 expected: "TLSv1.1", 18 }, 19 { 20 description: "TLS_VERSION_1.2", 21 input: 3, 22 expected: "TLSv1.2", 23 }, 24 { 25 description: "TLS_VERSION_1.3", 26 input: 4, 27 expected: "TLSv1.3", 28 }, 29 { 30 description: "invalid version", 31 input: -1, 32 expected: "Unknown", 33 }, 34 ]; 35 36 function run_test() { 37 info("Testing NetworkHelper.formatSecurityProtocol."); 38 39 for (const { description, input, expected } of TEST_CASES) { 40 info("Testing " + description); 41 42 equal( 43 NetworkHelper.formatSecurityProtocol(input), 44 expected, 45 "Got the expected protocol string." 46 ); 47 } 48 }