Source code

Revision control

Other Tools

1
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
var EXPORTED_SYMBOLS = ["NetErrorChild"];
7
8
const { XPCOMUtils } = ChromeUtils.import(
10
);
11
const { ChildMessagePort } = ChromeUtils.import(
13
);
14
15
XPCOMUtils.defineLazyServiceGetter(
16
this,
17
"gSerializationHelper",
18
"@mozilla.org/network/serialization-helper;1",
19
"nsISerializationHelper"
20
);
21
22
class NetErrorChild extends JSWindowActorChild {
23
actorCreated() {
24
this.messagePort = new ChildMessagePort(this, this.contentWindow);
25
}
26
27
getSerializedSecurityInfo(docShell) {
28
let securityInfo =
29
docShell.failedChannel && docShell.failedChannel.securityInfo;
30
if (!securityInfo) {
31
return "";
32
}
33
securityInfo
34
.QueryInterface(Ci.nsITransportSecurityInfo)
35
.QueryInterface(Ci.nsISerializable);
36
37
return gSerializationHelper.serializeToString(securityInfo);
38
}
39
40
receiveMessage(aMessage) {
41
this.messagePort.handleMessage(aMessage);
42
}
43
44
handleEvent(aEvent) {
45
// Documents have a null ownerDocument.
46
let doc = aEvent.originalTarget.ownerDocument || aEvent.originalTarget;
47
48
switch (aEvent.type) {
49
case "click":
50
let elem = aEvent.originalTarget;
51
if (elem.id == "viewCertificate") {
52
this.sendAsyncMessage("Browser:CertExceptionError", {
53
location: doc.location.href,
54
elementId: elem.id,
55
securityInfoAsString: this.getSerializedSecurityInfo(
56
doc.defaultView.docShell
57
),
58
});
59
}
60
break;
61
}
62
}
63
}