From 85416633940d744b53dcdee7d5cbd871648159d1 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Thu, 8 Jan 2015 12:18:15 +0100 Subject: [PATCH] Backed out changeset 648fe3c2fd57 (bug 932179) for m-oth bustage on a CLOSED TREE --- toolkit/devtools/server/actors/webconsole.js | 35 --- toolkit/devtools/webconsole/client.js | 17 -- toolkit/devtools/webconsole/network-helper.js | 202 ------------------ .../devtools/webconsole/network-monitor.js | 19 +- toolkit/devtools/webconsole/test/chrome.ini | 2 - .../webconsole/test/test_network_get.html | 5 - .../test/test_network_longstring.html | 5 - .../webconsole/test/test_network_post.html | 5 - .../test/test_network_security-hpkp.html | 111 ---------- .../test/test_network_security-hsts.html | 100 --------- .../unit/test_security-info-certificate.js | 68 ------ .../test/unit/test_security-info-parser.js | 64 ------ .../test_security-info-protocol-version.js | 54 ----- .../test/unit/test_security-info-state.js | 100 --------- .../webconsole/test/unit/xpcshell.ini | 4 - 15 files changed, 2 insertions(+), 789 deletions(-) delete mode 100644 toolkit/devtools/webconsole/test/test_network_security-hpkp.html delete mode 100644 toolkit/devtools/webconsole/test/test_network_security-hsts.html delete mode 100644 toolkit/devtools/webconsole/test/unit/test_security-info-certificate.js delete mode 100644 toolkit/devtools/webconsole/test/unit/test_security-info-parser.js delete mode 100644 toolkit/devtools/webconsole/test/unit/test_security-info-protocol-version.js delete mode 100644 toolkit/devtools/webconsole/test/unit/test_security-info-state.js diff --git a/toolkit/devtools/server/actors/webconsole.js b/toolkit/devtools/server/actors/webconsole.js index 83a0995923ec..c42a667aff0c 100644 --- a/toolkit/devtools/server/actors/webconsole.js +++ b/toolkit/devtools/server/actors/webconsole.js @@ -1755,20 +1755,6 @@ NetworkEventActor.prototype = }; }, - /** - * The "getSecurityInfo" packet type handler. - * - * @return object - * The response packet - connection security information. - */ - onGetSecurityInfo: function NEA_onGetSecurityInfo() - { - return { - from: this.actorID, - securityInfo: this._securityInfo, - }; - }, - /** * The "getResponseHeaders" packet type handler. * @@ -1924,26 +1910,6 @@ NetworkEventActor.prototype = this.conn.send(packet); }, - /** - * Add connection security information. - * - * @param object info - * The object containing security information. - */ - addSecurityInfo: function NEA_addSecurityInfo(info) - { - this._securityInfo = info; - - let packet = { - from: this.actorID, - type: "networkEventUpdate", - updateType: "securityInfo", - state: info.state, - }; - - this.conn.send(packet); - }, - /** * Add network response headers. * @@ -2068,5 +2034,4 @@ NetworkEventActor.prototype.requestTypes = "getResponseCookies": NetworkEventActor.prototype.onGetResponseCookies, "getResponseContent": NetworkEventActor.prototype.onGetResponseContent, "getEventTimings": NetworkEventActor.prototype.onGetEventTimings, - "getSecurityInfo": NetworkEventActor.prototype.onGetSecurityInfo, }; diff --git a/toolkit/devtools/webconsole/client.js b/toolkit/devtools/webconsole/client.js index 3ed4e47bb65e..9b70340d9815 100644 --- a/toolkit/devtools/webconsole/client.js +++ b/toolkit/devtools/webconsole/client.js @@ -366,23 +366,6 @@ WebConsoleClient.prototype = { this._client.request(packet, aOnResponse); }, - /** - * Retrieve the security information for the given NetworkEventActor. - * - * @param string aActor - * The NetworkEventActor ID. - * @param function aOnResponse - * The function invoked when the response is received. - */ - getSecurityInfo: function WCC_getSecurityInfo(aActor, aOnResponse) - { - let packet = { - to: aActor, - type: "getSecurityInfo", - }; - this._client.request(packet, aOnResponse); - }, - /** * Send a HTTP request with the given data. * diff --git a/toolkit/devtools/webconsole/network-helper.js b/toolkit/devtools/webconsole/network-helper.js index c5be753f3a20..fb2bbd79989d 100644 --- a/toolkit/devtools/webconsole/network-helper.js +++ b/toolkit/devtools/webconsole/network-helper.js @@ -56,7 +56,6 @@ const {components, Cc, Ci, Cu} = require("chrome"); loader.lazyImporter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm"); -loader.lazyImporter(this, "DevToolsUtils", "resource://gre/modules/devtools/DevToolsUtils.jsm"); /** * Helper object for networking stuff. @@ -481,207 +480,6 @@ let NetworkHelper = { return false; } }, - - /** - * Takes a securityInfo object of nsIRequest, the nsIRequest itself and - * extracts security information from them. - * - * @param object securityInfo - * The securityInfo object of a request. If null channel is assumed - * to be insecure. - * @param nsIRequest request - * The nsIRequest object for the request used to dig more information - * about this request. - * - * @return object - * Returns an object containing following members: - * - state: The security of the connection used to fetch this - * request. Has one of following string values: - * * "insecure": the connection was not secure (only http) - * * "broken": secure connection failed (e.g. expired cert) - * * "secure": the connection was properly secured. - * If state == broken: - * - errorMessage: full error message from nsITransportSecurityInfo. - * If state == secure: - * - protocolVersion: one of SSLv3, TLSv1, TLSv1.1, TLSv1.2. - * - cipherSuite: the cipher suite used in this connection. - * - cert: information about certificate used in this connection. - * See parseCertificateInfo for the contents. - * - hsts: true if host uses Strict Transport Security, false otherwise - * - hpkp: true if host uses Public Key Pinning, false otherwise - */ - parseSecurityInfo: function NH_parseSecurityInfo(securityInfo, request) { - const info = { - state: "insecure", - }; - - // The request did not contain any security info. - if (!securityInfo) { - return info; - } - - /** - * Different scenarios to consider here and how they are handled: - * - request is HTTP, the connection is not secure - * => securityInfo is null - * => state === "insecure" - * - * - request is HTTPS, the connection is secure - * => .securityState has STATE_IS_SECURE flag - * => state === "secure" - * - * - request is HTTPS, the connection has security issues - * => .securityState has STATE_IS_INSECURE flag - * => .errorCode is an NSS error code. - * => state === "broken" - * - * - request is HTTPS, the connection was terminated before the security - * could be validated - * => .securityState has STATE_IS_INSECURE flag - * => .errorCode is NOT an NSS error code. - * => .errorMessage is not available. - * => state === "insecure" - * - * - request is HTTPS but it uses a weak cipher or old protocol, see - * http://hg.mozilla.org/mozilla-central/annotate/def6ed9d1c1a/ - * security/manager/ssl/src/nsNSSCallbacks.cpp#l1233 - * - request is mixed content (which makes no sense whatsoever) - * => .securityState has STATE_IS_BROKEN flag - * => .errorCode is NOT an NSS error code - * => .errorMessage is not available - * => state === "insecure" - */ - - securityInfo.QueryInterface(Ci.nsITransportSecurityInfo); - securityInfo.QueryInterface(Ci.nsISSLStatusProvider); - - const wpl = Ci.nsIWebProgressListener; - const NSSErrorsService = Cc['@mozilla.org/nss_errors_service;1'] - .getService(Ci.nsINSSErrorsService); - const SSLStatus = securityInfo.SSLStatus; - - if (securityInfo.securityState & wpl.STATE_IS_SECURE) { - // The connection is secure. - info.state = "secure"; - - // Cipher suite. - info.cipherSuite = SSLStatus.cipherName; - - // Protocol version. - info.protocolVersion = this.formatSecurityProtocol(SSLStatus.protocolVersion); - - // Certificate. - info.cert = this.parseCertificateInfo(SSLStatus.serverCert); - - // HSTS and HPKP if available. - if (request.URI) { - const sss = Cc["@mozilla.org/ssservice;1"] - .getService(Ci.nsISiteSecurityService); - - request.QueryInterface(Ci.nsIPrivateBrowsingChannel); - - // SiteSecurityService uses different storage if the channel is - // private. Thus we must give isSecureHost correct flags or we - // might get incorrect results. - let flags = (request.isChannelPrivate) ? - Ci.nsISocketProvider.NO_PERMANENT_STORAGE : 0; - - let host = request.URI.host; - - info.hsts = sss.isSecureHost(sss.HEADER_HSTS, host, flags); - info.hpkp = sss.isSecureHost(sss.HEADER_HPKP, host, flags); - } else { - DevToolsUtils.reportException("NetworkHelper.parseSecurityInfo", - "Could not get HSTS/HPKP status as request.URI not available."); - info.hsts = false; - info.hpkp = false; - } - - } else if (NSSErrorsService.isNSSErrorCode(securityInfo.errorCode)) { - // The connection failed. - info.state = "broken"; - info.errorMessage = securityInfo.errorMessage; - } else { - // Connection has securityInfo, it is not secure and there's no problems - // to report. Mark the request as insecure. - return info; - } - - return info; - }, - - /** - * Takes an nsIX509Cert and returns an object with certificate information. - * - * @param nsIX509Cert cert - * The certificate to extract the information from. - * @return object - * An object with following format: - * { - * subject: { commonName, organization, organizationalUnit }, - * issuer: { commonName, organization, organizationUnit }, - * validity: { start, end }, - * fingerprint: { sha1, sha256 } - * } - */ - parseCertificateInfo: function NH_parseCertifificateInfo(cert) { - let info = {}; - if (cert) { - info.subject = { - commonName: cert.commonName, - organization: cert.organization, - organizationalUnit: cert.organizationalUnit, - }; - - info.issuer = { - commonName: cert.issuerCommonName, - organization: cert.issuerOrganization, - organizationUnit: cert.issuerOrganizationUnit, - }; - - info.validity = { - start: cert.validity.notBeforeLocalDay, - end: cert.validity.notAfterLocalDay, - }; - - info.fingerprint = { - sha1: cert.sha1Fingerprint, - sha256: cert.sha256Fingerprint, - }; - } else { - DevToolsUtils.reportException("NetworkHelper.parseCertificateInfo", - "Secure connection established without certificate."); - } - - return info; - }, - - /** - * Takes protocolVersion of SSLStatus object and returns human readable - * description. - * - * @param Number version - * One of nsISSLStatus version constants. - * @return string - * One of SSLv3, TLSv1, TLSv1.1, TLSv1.2 if @param version is valid, - * Unknown otherwise. - */ - formatSecurityProtocol: function NH_formatSecurityProtocol(version) { - switch (version) { - case Ci.nsISSLStatus.SSL_VERSION_3: - return "SSLv3"; - case Ci.nsISSLStatus.TLS_VERSION_1: - return "TLSv1"; - case Ci.nsISSLStatus.TLS_VERSION_1_1: - return "TLSv1.1"; - case Ci.nsISSLStatus.TLS_VERSION_1_2: - return "TLSv1.2"; - default: - DevToolsUtils.reportException("NetworkHelper.formatSecurityProtocol", - "protocolVersion " + version + " is unknown."); - return "Unknown"; - } - }, }; for (let prop of Object.getOwnPropertyNames(NetworkHelper)) { diff --git a/toolkit/devtools/webconsole/network-monitor.js b/toolkit/devtools/webconsole/network-monitor.js index cf3fe2122d44..6a27d4e46673 100644 --- a/toolkit/devtools/webconsole/network-monitor.js +++ b/toolkit/devtools/webconsole/network-monitor.js @@ -205,26 +205,11 @@ NetworkResponseListener.prototype = { onStartRequest: function NRL_onStartRequest(aRequest) { this.request = aRequest; - this._getSecurityInfo(); this._findOpenResponse(); // Asynchronously wait for the data coming from the request. this.setAsyncListener(this.sink.inputStream, this); }, - /** - * Parse security state of this request and report it to the client. - */ - _getSecurityInfo: DevToolsUtils.makeInfallible(function NRL_getSecurityInfo() { - // Take the security information from the original nsIHTTPChannel instead of - // the nsIRequest received in onStartRequest. If response to this request - // was a redirect from http to https, the request object seems to contain - // security info for the https request after redirect. - let secinfo = this.httpActivity.channel.securityInfo; - let info = NetworkHelper.parseSecurityInfo(secinfo, this.request); - - this.httpActivity.owner.addSecurityInfo(info); - }), - /** * Handle the onStopRequest by closing the sink output stream. * @@ -1239,8 +1224,8 @@ NetworkEventActorProxy.prototype = { (function() { // Listeners for new network event data coming from the NetworkMonitor. let methods = ["addRequestHeaders", "addRequestCookies", "addRequestPostData", - "addResponseStart", "addSecurityInfo", "addResponseHeaders", - "addResponseCookies", "addResponseContent", "addEventTimings"]; + "addResponseStart", "addResponseHeaders", "addResponseCookies", + "addResponseContent", "addEventTimings"]; let factory = NetworkEventActorProxy.methodFactory; for (let method of methods) { NetworkEventActorProxy.prototype[method] = factory(method); diff --git a/toolkit/devtools/webconsole/test/chrome.ini b/toolkit/devtools/webconsole/test/chrome.ini index b8558bb27d4d..67f69c032b88 100644 --- a/toolkit/devtools/webconsole/test/chrome.ini +++ b/toolkit/devtools/webconsole/test/chrome.ini @@ -17,8 +17,6 @@ support-files = [test_network_get.html] [test_network_longstring.html] [test_network_post.html] -[test_network_security-hpkp.html] -[test_network_security-hsts.html] [test_nsiconsolemessage.html] [test_object_actor.html] [test_object_actor_native_getters.html] diff --git a/toolkit/devtools/webconsole/test/test_network_get.html b/toolkit/devtools/webconsole/test/test_network_get.html index f3a01ff02ea4..63ba2378a4cd 100644 --- a/toolkit/devtools/webconsole/test/test_network_get.html +++ b/toolkit/devtools/webconsole/test/test_network_get.html @@ -91,11 +91,6 @@ function onNetworkEventUpdate(aState, aType, aPacket) }, }; break; - case "securityInfo": - expectedPacket = { - state: "insecure", - }; - break; case "responseCookies": expectedPacket = { cookies: 0, diff --git a/toolkit/devtools/webconsole/test/test_network_longstring.html b/toolkit/devtools/webconsole/test/test_network_longstring.html index 1dc7bc7628ef..9c1cdfba2428 100644 --- a/toolkit/devtools/webconsole/test/test_network_longstring.html +++ b/toolkit/devtools/webconsole/test/test_network_longstring.html @@ -114,11 +114,6 @@ function onNetworkEventUpdate(aState, aType, aPacket) }, }; break; - case "securityInfo": - expectedPacket = { - state: "insecure", - }; - break; case "responseCookies": expectedPacket = { cookies: 0, diff --git a/toolkit/devtools/webconsole/test/test_network_post.html b/toolkit/devtools/webconsole/test/test_network_post.html index 5d8a184b0d31..b8288f8e56d8 100644 --- a/toolkit/devtools/webconsole/test/test_network_post.html +++ b/toolkit/devtools/webconsole/test/test_network_post.html @@ -107,11 +107,6 @@ function onNetworkEventUpdate(aState, aType, aPacket) }, }; break; - case "securityInfo": - expectedPacket = { - state: "insecure", - }; - break; case "responseCookies": expectedPacket = { cookies: 0, diff --git a/toolkit/devtools/webconsole/test/test_network_security-hpkp.html b/toolkit/devtools/webconsole/test/test_network_security-hpkp.html deleted file mode 100644 index ed6849cb981c..000000000000 --- a/toolkit/devtools/webconsole/test/test_network_security-hpkp.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - Test for the network actor (HPKP detection) - - - - - -

Test for the network actor (HPKP detection)

- - - - - - diff --git a/toolkit/devtools/webconsole/test/test_network_security-hsts.html b/toolkit/devtools/webconsole/test/test_network_security-hsts.html deleted file mode 100644 index 1895c9113755..000000000000 --- a/toolkit/devtools/webconsole/test/test_network_security-hsts.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - - Test for the network actor (HSTS detection) - - - - - -

Test for the network actor (HSTS detection)

- - - - - - diff --git a/toolkit/devtools/webconsole/test/unit/test_security-info-certificate.js b/toolkit/devtools/webconsole/test/unit/test_security-info-certificate.js deleted file mode 100644 index 63b95a10ca57..000000000000 --- a/toolkit/devtools/webconsole/test/unit/test_security-info-certificate.js +++ /dev/null @@ -1,68 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -// Tests that NetworkHelper.parseCertificateInfo parses certificate information -// correctly. - -const { devtools } = Components.utils.import("resource://gre/modules/devtools/Loader.jsm", {}); - -Object.defineProperty(this, "NetworkHelper", { - get: function() { - return devtools.require("devtools/toolkit/webconsole/network-helper"); - }, - configurable: true, - writeable: false, - enumerable: true -}); - -const Ci = Components.interfaces; -const DUMMY_CERT = { - commonName: "cn", - organization: "o", - organizationalUnit: "ou", - issuerCommonName: "issuerCN", - issuerOrganization: "issuerO", - issuerOrganizationUnit: "issuerOU", - sha256Fingerprint: "qwertyuiopoiuytrewq", - sha1Fingerprint: "qwertyuiop", - validity: { - notBeforeLocalDay: "yesterday", - notAfterLocalDay: "tomorrow", - } -}; - -function run_test() { - do_print("Testing NetworkHelper.parseCertificateInfo."); - - let result = NetworkHelper.parseCertificateInfo(DUMMY_CERT); - - // Subject - equal(result.subject.commonName, DUMMY_CERT.commonName, - "Common name is correct."); - equal(result.subject.organization, DUMMY_CERT.organization, - "Organization is correct."); - equal(result.subject.organizationalUnit, DUMMY_CERT.organizationalUnit, - "Organizational unit is correct."); - - // Issuer - equal(result.issuer.commonName, DUMMY_CERT.issuerCommonName, - "Common name of the issuer is correct."); - equal(result.issuer.organization, DUMMY_CERT.issuerOrganization, - "Organization of the issuer is correct."); - equal(result.issuer.organizationalUnit, DUMMY_CERT.issuerOrganizationalUnit, - "Organizational unit of the issuer is correct."); - - // Validity - equal(result.validity.start, DUMMY_CERT.validity.notBeforeLocalDay, - "Start of the validity period is correct."); - equal(result.validity.end, DUMMY_CERT.validity.notAfterLocalDay, - "End of the validity period is correct."); - - // Fingerprints - equal(result.fingerprint.sha1, DUMMY_CERT.sha1Fingerprint, - "Certificate SHA1 fingerprint is correct."); - equal(result.fingerprint.sha256, DUMMY_CERT.sha256Fingerprint, - "Certificate SHA256 fingerprint is correct."); -} diff --git a/toolkit/devtools/webconsole/test/unit/test_security-info-parser.js b/toolkit/devtools/webconsole/test/unit/test_security-info-parser.js deleted file mode 100644 index 379d3b0e5d80..000000000000 --- a/toolkit/devtools/webconsole/test/unit/test_security-info-parser.js +++ /dev/null @@ -1,64 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -// Test that NetworkHelper.parseSecurityInfo returns correctly formatted object. - -const { devtools } = Components.utils.import("resource://gre/modules/devtools/Loader.jsm", {}); -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); - -Object.defineProperty(this, "NetworkHelper", { - get: function() { - return devtools.require("devtools/toolkit/webconsole/network-helper"); - }, - configurable: true, - writeable: false, - enumerable: true -}); - -const Ci = Components.interfaces; -const wpl = Ci.nsIWebProgressListener; -const MockCertificate = { - commonName: "cn", - organization: "o", - organizationalUnit: "ou", - issuerCommonName: "issuerCN", - issuerOrganization: "issuerO", - issuerOrganizationUnit: "issuerOU", - sha256Fingerprint: "qwertyuiopoiuytrewq", - sha1Fingerprint: "qwertyuiop", - validity: { - notBeforeLocalDay: "yesterday", - notAfterLocalDay: "tomorrow", - } -}; - -const MockSecurityInfo = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsITransportSecurityInfo, - Ci.nsISSLStatusProvider]), - securityState: wpl.STATE_IS_SECURE, - errorCode: 0, - SSLStatus: { - cipherSuite: "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", - protocolVersion: 3, // TLS_VERSION_1_2 - serverCert: MockCertificate, - } -}; - -function run_test() { - let result = NetworkHelper.parseSecurityInfo(MockSecurityInfo, {}); - - equal(result.state, "secure", "State is correct."); - - equal(result.cipherSuite, MockSecurityInfo.cipherSuite, - "Cipher suite is correct."); - - equal(result.protocolVersion, "TLSv1.2", "Protocol version is correct."); - - deepEqual(result.cert, NetworkHelper.parseCertificateInfo(MockCertificate), - "Certificate information is correct."); - - equal(result.hpkp, false, "HPKP is false when URI is not available."); - equal(result.hsts, false, "HSTS is false when URI is not available."); -} diff --git a/toolkit/devtools/webconsole/test/unit/test_security-info-protocol-version.js b/toolkit/devtools/webconsole/test/unit/test_security-info-protocol-version.js deleted file mode 100644 index 9283e4ddb662..000000000000 --- a/toolkit/devtools/webconsole/test/unit/test_security-info-protocol-version.js +++ /dev/null @@ -1,54 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -// Tests that NetworkHelper.formatSecurityProtocol returns correct -// protocol version strings. - -const { devtools } = Components.utils.import("resource://gre/modules/devtools/Loader.jsm", {}); - -Object.defineProperty(this, "NetworkHelper", { - get: function() { - return devtools.require("devtools/toolkit/webconsole/network-helper"); - }, - configurable: true, - writeable: false, - enumerable: true -}); - -const Ci = Components.interfaces; -const TEST_CASES = [ - { - description: "SSL_VERSION_3", - input: 0, - expected: "SSLv3" - }, { - description: "TLS_VERSION_1", - input: 1, - expected: "TLSv1" - }, { - description: "TLS_VERSION_1.1", - input: 2, - expected: "TLSv1.1" - }, { - description: "TLS_VERSION_1.2", - input: 3, - expected: "TLSv1.2" - }, { - description: "invalid version", - input: -1, - expected: "Unknown" - }, -]; - -function run_test() { - do_print("Testing NetworkHelper.formatSecurityProtocol."); - - for (let {description, input, expected} of TEST_CASES) { - do_print("Testing " + description); - - equal(NetworkHelper.formatSecurityProtocol(input), expected, - "Got the expected protocol string."); - } -} diff --git a/toolkit/devtools/webconsole/test/unit/test_security-info-state.js b/toolkit/devtools/webconsole/test/unit/test_security-info-state.js deleted file mode 100644 index dd6177aa0635..000000000000 --- a/toolkit/devtools/webconsole/test/unit/test_security-info-state.js +++ /dev/null @@ -1,100 +0,0 @@ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -// Tests that security info parser gives correct general security state for -// different cases. - -const { devtools } = Components.utils.import("resource://gre/modules/devtools/Loader.jsm", {}); -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); - -Object.defineProperty(this, "NetworkHelper", { - get: function() { - return devtools.require("devtools/toolkit/webconsole/network-helper"); - }, - configurable: true, - writeable: false, - enumerable: true -}); - -const Ci = Components.interfaces; -const wpl = Ci.nsIWebProgressListener; -const MockSecurityInfo = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsITransportSecurityInfo, - Ci.nsISSLStatusProvider]), - securityState: wpl.STATE_IS_BROKEN, - errorCode: 0, - SSLStatus: { - protocolVersion: 3, // nsISSLStatus.TLS_VERSION_1_2 - cipherSuite: "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", - } -}; - -function run_test() { - test_nullSecurityInfo(); - test_insecureSecurityInfoWithNSSError(); - test_insecureSecurityInfoWithoutNSSError(); - test_brokenSecurityInfo(); - test_secureSecurityInfo(); -} - -/** - * Test that undefined security information is returns "insecure". - */ -function test_nullSecurityInfo() { - let result = NetworkHelper.parseSecurityInfo(null, {}); - equal(result.state, "insecure", - "state == 'insecure' when securityInfo was undefined"); -} - -/** - * Test that STATE_IS_INSECURE with NSSError returns "broken" - */ -function test_insecureSecurityInfoWithNSSError() { - MockSecurityInfo.securityState = wpl.STATE_IS_INSECURE; - - // Taken from security/manager/ssl/tests/unit/head_psm.js. - MockSecurityInfo.errorCode = -8180; - - let result = NetworkHelper.parseSecurityInfo(MockSecurityInfo, {}); - equal(result.state, "broken", - "state == 'broken' if securityState contains STATE_IS_INSECURE flag AND " + - "errorCode is NSS error."); - - MockSecurityInfo.errorCode = 0; -} - -/** - * Test that STATE_IS_INSECURE without NSSError returns "insecure" - */ -function test_insecureSecurityInfoWithoutNSSError() { - MockSecurityInfo.securityState = wpl.STATE_IS_INSECURE; - - let result = NetworkHelper.parseSecurityInfo(MockSecurityInfo, {}); - equal(result.state, "insecure", - "state == 'insecure' if securityState contains STATE_IS_INSECURE flag BUT " + - "errorCode is not NSS error."); -} - -/** - * Test that STATE_IS_SECURE returns "secure" - */ -function test_secureSecurityInfo() { - MockSecurityInfo.securityState = wpl.STATE_IS_SECURE; - - let result = NetworkHelper.parseSecurityInfo(MockSecurityInfo, {}); - equal(result.state, "secure", - "state == 'secure' if securityState contains STATE_IS_SECURE flag"); -} - -/** - * Test that STATE_IS_BROKEN returns "insecure" - */ -function test_brokenSecurityInfo() { - MockSecurityInfo.securityState = wpl.STATE_IS_BROKEN; - - let result = NetworkHelper.parseSecurityInfo(MockSecurityInfo, {}); - equal(result.state, "insecure", - "state == 'insecure' if securityState contains STATE_IS_BROKEN flag"); -} diff --git a/toolkit/devtools/webconsole/test/unit/xpcshell.ini b/toolkit/devtools/webconsole/test/unit/xpcshell.ini index 7e4cdad93875..3ef474926c4e 100644 --- a/toolkit/devtools/webconsole/test/unit/xpcshell.ini +++ b/toolkit/devtools/webconsole/test/unit/xpcshell.ini @@ -6,7 +6,3 @@ support-files = [test_js_property_provider.js] [test_network_helper.js] -[test_security-info-certificate.js] -[test_security-info-parser.js] -[test_security-info-protocol-version.js] -[test_security-info-state.js]