Bug 1220160 - part 3: use mozDocumentURIIfNotForErrorPages for ssl error reporting, r=past
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 22 Feb 2016 20:31:10 +0000
changeset 285492 e4be65c87fcc7d04b662f90af45ca6d2f17fa59a
parent 285491 2142620090e707b024adbfd5fcc77200a57836d8
child 285493 68ae644667f2a398d10bac8941c4b7ae2193281a
push id72403
push usercbook@mozilla.com
push dateThu, 25 Feb 2016 10:59:17 +0000
treeherdermozilla-inbound@3b913f81cb98 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs1220160
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1220160 - part 3: use mozDocumentURIIfNotForErrorPages for ssl error reporting, r=past MozReview-Commit-ID: INgz40gYGwl
browser/base/content/browser.js
browser/base/content/content.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2697,18 +2697,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;
         }
@@ -2718,43 +2717,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() {