Bug 1564221 - Remove QueryInterface parameter from MockSecurityInfo in devtools tests r=ochameau,nchevobbe

The `MockSecurityInfo` instances in the patched devtools tests are not actually
being used as `nsITransportSecurityInfo` instances; while `QueryInterface`
methods were generated for the them, these were never called. Additionally, the
methods they are being passed to are not XPCOM-defined and therefore do not
strictly require `nsITransportSecurityInfo`.

In addition `NetworkHelper#parseSecurityInfo` now requires its `securityInfo`
to be `QueryInterface`d to a `nsITransportSecurityInfo` before calling the
function (except in the case of `MockSecurityInfo`, which is structurally
similar).

Differential Revision: https://phabricator.services.mozilla.com/D40521

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Barret Rennie 2019-08-19 07:01:56 +00:00
parent 244c61a02f
commit 67fc7c04a4
5 changed files with 13 additions and 6 deletions

View File

@ -323,7 +323,9 @@ NetworkResponseListener.prototype = {
// 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.
const secinfo = this.httpActivity.channel.securityInfo;
const secinfo = this.httpActivity.channel.securityInfo.QueryInterface(
Ci.nsITransportSecurityInfo
);
const info = NetworkHelper.parseSecurityInfo(secinfo, this.httpActivity);
let isRacing = false;

View File

@ -594,8 +594,6 @@ var NetworkHelper = {
* => state === "weak"
*/
securityInfo.QueryInterface(Ci.nsITransportSecurityInfo);
const wpl = Ci.nsIWebProgressListener;
const NSSErrorsService = Cc["@mozilla.org/nss_errors_service;1"].getService(
Ci.nsINSSErrorsService

View File

@ -31,8 +31,10 @@ const MockCertificate = {
},
};
// This *cannot* be used as an nsITransportSecurityInfo (since that interface is
// builtinclass) but the methods being tested aren't defined by XPCOM and aren't
// calling QueryInterface, so this usage is fine.
const MockSecurityInfo = {
QueryInterface: ChromeUtils.generateQI([Ci.nsITransportSecurityInfo]),
securityState: wpl.STATE_IS_SECURE,
errorCode: 0,
cipherName: "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",

View File

@ -17,8 +17,11 @@ Object.defineProperty(this, "NetworkHelper", {
});
const wpl = Ci.nsIWebProgressListener;
// This *cannot* be used as an nsITransportSecurityInfo (since that interface is
// builtinclass) but the methods being tested aren't defined by XPCOM and aren't
// calling QueryInterface, so this usage is fine.
const MockSecurityInfo = {
QueryInterface: ChromeUtils.generateQI([Ci.nsITransportSecurityInfo]),
securityState: wpl.STATE_IS_BROKEN,
errorCode: 0,
// nsISSLStatus.TLS_VERSION_1_2

View File

@ -18,8 +18,10 @@ Object.defineProperty(this, "NetworkHelper", {
const wpl = Ci.nsIWebProgressListener;
// This *cannot* be used as an nsITransportSecurityInfo (since that interface is
// builtinclass) but the methods being tested aren't defined by XPCOM and aren't
// calling QueryInterface, so this usage is fine.
const MockSecurityInfo = {
QueryInterface: ChromeUtils.generateQI([Ci.nsITransportSecurityInfo]),
securityState: wpl.STATE_IS_SECURE,
errorCode: 0,
cipherName: "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",