mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
|
/* Any copyright is dedicated to the Public Domain.
|
||
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
||
|
*/
|
||
|
|
||
|
var gPendingTests = [];
|
||
|
var gTestsRun = 0;
|
||
|
|
||
|
function add_test(test) {
|
||
|
gPendingTests.push(test);
|
||
|
}
|
||
|
|
||
|
function run_next_test() {
|
||
|
if (gPendingTests.length == 0) {
|
||
|
end_test();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
gTestsRun++;
|
||
|
info("Running test " + gTestsRun);
|
||
|
|
||
|
gPendingTests.shift()();
|
||
|
}
|
||
|
|
||
|
function CertOverrideListener(host, bits) {
|
||
|
this.host = host;
|
||
|
this.bits = bits;
|
||
|
}
|
||
|
|
||
|
CertOverrideListener.prototype = {
|
||
|
host: null,
|
||
|
bits: null,
|
||
|
|
||
|
getInterface: function (aIID) {
|
||
|
return this.QueryInterface(aIID);
|
||
|
},
|
||
|
|
||
|
QueryInterface: function(aIID) {
|
||
|
if (aIID.equals(Ci.nsIBadCertListener2) ||
|
||
|
aIID.equals(Ci.nsIInterfaceRequestor) ||
|
||
|
aIID.equals(Ci.nsISupports))
|
||
|
return this;
|
||
|
|
||
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||
|
},
|
||
|
|
||
|
notifyCertProblem: function (socketInfo, sslStatus, targetHost) {
|
||
|
cert = sslStatus.QueryInterface(Components.interfaces.nsISSLStatus)
|
||
|
.serverCert;
|
||
|
var cos = Cc["@mozilla.org/security/certoverride;1"].
|
||
|
getService(Ci.nsICertOverrideService);
|
||
|
cos.rememberValidityOverride(this.host, -1, cert, this.bits, false);
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Add overrides for the bad certificates
|
||
|
function addCertOverride(host, bits) {
|
||
|
var req = new XMLHttpRequest();
|
||
|
try {
|
||
|
req.open("GET", "https://" + host + "/", false);
|
||
|
req.channel.notificationCallbacks = new CertOverrideListener(host, bits);
|
||
|
req.send(null);
|
||
|
}
|
||
|
catch (e) {
|
||
|
// This request will fail since the SSL server is not trusted yet
|
||
|
}
|
||
|
}
|