2018-05-26 03:50:22 +03:00
|
|
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2018-07-30 07:00:29 +03:00
|
|
|
var EXPORTED_SYMBOLS = ["NetErrorChild"];
|
2018-05-26 03:50:22 +03:00
|
|
|
|
2019-01-17 21:18:31 +03:00
|
|
|
const { ActorChild } = ChromeUtils.import(
|
|
|
|
"resource://gre/modules/ActorChild.jsm"
|
|
|
|
);
|
2019-07-05 10:46:28 +03:00
|
|
|
|
2018-05-26 03:50:22 +03:00
|
|
|
function getSerializedSecurityInfo(docShell) {
|
|
|
|
let serhelper = Cc["@mozilla.org/network/serialization-helper;1"].getService(
|
|
|
|
Ci.nsISerializationHelper
|
|
|
|
);
|
|
|
|
|
|
|
|
let securityInfo =
|
|
|
|
docShell.failedChannel && docShell.failedChannel.securityInfo;
|
|
|
|
if (!securityInfo) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
securityInfo
|
|
|
|
.QueryInterface(Ci.nsITransportSecurityInfo)
|
|
|
|
.QueryInterface(Ci.nsISerializable);
|
|
|
|
|
|
|
|
return serhelper.serializeToString(securityInfo);
|
|
|
|
}
|
|
|
|
|
2018-07-30 07:00:29 +03:00
|
|
|
class NetErrorChild extends ActorChild {
|
2018-05-26 03:50:22 +03:00
|
|
|
isAboutNetError(doc) {
|
|
|
|
return doc.documentURI.startsWith("about:neterror");
|
2018-07-30 07:00:29 +03:00
|
|
|
}
|
2018-05-26 03:50:22 +03:00
|
|
|
|
2018-07-30 07:00:29 +03:00
|
|
|
handleEvent(aEvent) {
|
2018-05-26 03:50:22 +03:00
|
|
|
// Documents have a null ownerDocument.
|
|
|
|
let doc = aEvent.originalTarget.ownerDocument || aEvent.originalTarget;
|
|
|
|
|
|
|
|
switch (aEvent.type) {
|
2018-07-30 07:00:29 +03:00
|
|
|
case "click":
|
2019-09-05 23:04:03 +03:00
|
|
|
let elem = aEvent.originalTarget;
|
2019-10-28 23:39:16 +03:00
|
|
|
if (elem.id == "viewCertificate") {
|
2019-09-05 23:04:03 +03:00
|
|
|
this.mm.sendAsyncMessage("Browser:CertExceptionError", {
|
|
|
|
location: doc.location.href,
|
|
|
|
elementId: elem.id,
|
|
|
|
securityInfoAsString: getSerializedSecurityInfo(
|
|
|
|
doc.defaultView.docShell
|
|
|
|
),
|
|
|
|
});
|
2018-07-30 07:00:29 +03:00
|
|
|
}
|
2018-10-17 16:10:26 +03:00
|
|
|
break;
|
2018-05-26 03:50:22 +03:00
|
|
|
}
|
2018-07-30 07:00:29 +03:00
|
|
|
}
|
|
|
|
}
|