Bug 1220160 - part 3: use mozDocumentURIIfNotForErrorPages for ssl error reporting, r?past
MozReview-Commit-ID: INgz40gYGwl
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2692,18 +2692,17 @@ var BrowserOnClick = {
if (Services.io.offline) {
// Reset network state and refresh the page.
Services.io.offline = false;
msg.target.reload();
}
break;
case "Browser:SendSSLErrorReport":
this.onSSLErrorReport(msg.target,
- msg.data.documentURI,
- msg.data.location,
+ msg.data.uri,
msg.data.securityInfo);
break;
case "Browser:SetSSLErrorReportAuto":
Services.prefs.setBoolPref("security.ssl.errorReporting.automatic", msg.json.automatic);
let bin = TLS_ERROR_REPORT_TELEMETRY_AUTO_UNCHECKED;
if (msg.json.automatic) {
bin = TLS_ERROR_REPORT_TELEMETRY_AUTO_CHECKED;
}
@@ -2713,43 +2712,40 @@ var BrowserOnClick = {
let reportStatus = msg.data.reportStatus;
Services.telemetry.getHistogramById("TLS_ERROR_REPORT_UI")
.add(reportStatus);
break;
case "Browser:OverrideWeakCrypto":
let weakCryptoOverride = Cc["@mozilla.org/security/weakcryptooverride;1"]
.getService(Ci.nsIWeakCryptoOverride);
weakCryptoOverride.addWeakCryptoOverride(
- msg.data.location.hostname,
+ msg.data.uri.host,
PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser));
break;
case "Browser:SSLErrorGoBack":
goBackFromErrorPage();
break;
}
},
- onSSLErrorReport: function(browser, documentURI, location, securityInfo) {
+ onSSLErrorReport: function(browser, uri, securityInfo) {
if (!Services.prefs.getBoolPref("security.ssl.errorReporting.enabled")) {
Cu.reportError("User requested certificate error report sending, but certificate error reporting is disabled");
return;
}
let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
.getService(Ci.nsISerializationHelper);
let transportSecurityInfo = serhelper.deserializeObject(securityInfo);
transportSecurityInfo.QueryInterface(Ci.nsITransportSecurityInfo)
let errorReporter = Cc["@mozilla.org/securityreporter;1"]
.getService(Ci.nsISecurityReporter);
- // if location.port is the empty string, set to -1 (for consistency with
- // port values from nsIURI)
- let port = location.port === "" ? -1 : location.port;
errorReporter.reportTLSError(transportSecurityInfo,
- location.hostname, port);
+ uri.host, uri.port);
},
onAboutCertError: function (browser, elementId, isTopFrame, location, securityInfoAsString) {
let secHistogram = Services.telemetry.getHistogramById("SECURITY_UI");
switch (elementId) {
case "exceptionDialogButton":
if (isTopFrame) {
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -271,30 +271,28 @@ var AboutCertErrorListener = {
onSetAutomatic(event) {
sendAsyncMessage("Browser:SetSSLErrorReportAuto", {
automatic: event.detail
});
// if we're enabling reports, send a report for this failure
if (event.detail) {
- let doc = content.document;
-
let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
.getService(Ci.nsISerializationHelper);
let serializable = docShell.failedChannel.securityInfo
.QueryInterface(Ci.nsITransportSecurityInfo)
.QueryInterface(Ci.nsISerializable);
let serializedSecurityInfo = serhelper.serializeToString(serializable);
+ let {host, port} = content.document.mozDocumentURIIfNotForErrorPages;
sendAsyncMessage("Browser:SendSSLErrorReport", {
- documentURI: doc.documentURI,
- location: {hostname: doc.location.hostname, port: doc.location.port},
+ uri: { host, port },
securityInfo: serializedSecurityInfo
});
}
},
};
AboutCertErrorListener.init(this);
@@ -343,47 +341,37 @@ var AboutNetErrorListener = {
onSetAutomatic: function(evt) {
sendAsyncMessage("Browser:SetSSLErrorReportAuto", {
automatic: evt.detail
});
// if we're enabling reports, send a report for this failure
if (evt.detail) {
- let contentDoc = content.document;
-
let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
.getService(Ci.nsISerializationHelper);
let serializable = docShell.failedChannel.securityInfo
.QueryInterface(Ci.nsITransportSecurityInfo)
.QueryInterface(Ci.nsISerializable);
let serializedSecurityInfo = serhelper.serializeToString(serializable);
+ let {host, port} = content.document.mozDocumentURIIfNotForErrorPages;
sendAsyncMessage("Browser:SendSSLErrorReport", {
- documentURI: contentDoc.documentURI,
- location: {
- hostname: contentDoc.location.hostname,
- port: contentDoc.location.port
- },
+ uri: { host, port },
securityInfo: serializedSecurityInfo
});
}
},
onOverride: function(evt) {
- let contentDoc = content.document;
- let location = contentDoc.location;
-
- sendAsyncMessage("Browser:OverrideWeakCrypto", {
- documentURI: contentDoc.documentURI,
- location: {hostname: location.hostname, port: location.port}
- });
+ let {host, port} = content.document.mozDocumentURIIfNotForErrorPages;
+ sendAsyncMessage("Browser:OverrideWeakCrypto", { uri: {host, port} });
}
}
AboutNetErrorListener.init(this);
var ClickEventHandler = {
init: function init() {