From 91d8cf8984de7e9c79459f4511f411a9f2e91f93 Mon Sep 17 00:00:00 2001 From: Mark Goodwin Date: Thu, 30 Oct 2014 12:52:00 +0100 Subject: [PATCH] Bug 846498 - create NetError UI, implement report send functionality. r=felipc@gmail.com --- browser/base/content/aboutNetError.xhtml | 85 ++++++++++++ browser/base/content/browser.js | 123 ++++++++++++++++++ browser/base/content/content.js | 107 +++++++++++++++ .../docs/sslerrorreport/dataformat.rst | 46 +++++++ .../content/docs/sslerrorreport/index.rst | 15 +++ .../docs/sslerrorreport/preferences.rst | 23 ++++ browser/base/moz.build | 2 + .../en-US/chrome/overrides/netError.dtd | 9 ++ browser/themes/shared/aboutNetError.css | 72 ++++++++++ netwerk/base/public/security-prefs.js | 4 + 10 files changed, 486 insertions(+) create mode 100644 browser/base/content/docs/sslerrorreport/dataformat.rst create mode 100644 browser/base/content/docs/sslerrorreport/index.rst create mode 100644 browser/base/content/docs/sslerrorreport/preferences.rst diff --git a/browser/base/content/aboutNetError.xhtml b/browser/base/content/aboutNetError.xhtml index f7326af1775..4d219e17542 100644 --- a/browser/base/content/aboutNetError.xhtml +++ b/browser/base/content/aboutNetError.xhtml @@ -91,6 +91,37 @@ buttonEl.disabled = true; } + function toggleDisplay(node) { + toggle = { + '': 'block', + 'none': 'block', + 'block': 'none' + }; + node.style.display = toggle[node.style.display]; + } + + function showCertificateErrorReporting() { + // Display error reporting UI + document.getElementById('certificateErrorReporting').style.display = 'block'; + + // Get the hostname and add it to the panel + document.getElementById('hostname').textContent = document.location.hostname; + + // Register click handler for the certificateErrorReportingPanel + document.getElementById('showCertificateErrorReportingPanel') + .addEventListener('click', function togglePanelVisibility() { + var panel = document.getElementById('certificateErrorReportingPanel'); + toggleDisplay(panel); + }); + } + + + function sendErrorReport() { + var event = new CustomEvent("AboutNetErrorSendReport", {bubbles:true}); + + document.dispatchEvent(event); + } + function initPage() { var err = getErrorCode(); @@ -161,6 +192,37 @@ document.getElementById("errorTryAgain").style.display = "none"; } + window.addEventListener("AboutNetErrorOptions", function(evt) { + // Pinning errors are of type nssFailure2 (don't ask me why) + if (getErrorCode() == "nssFailure2") { + // TODO: and the pref is set... + var options = JSON.parse(evt.detail); + if (options && options.enabled) { + var checkbox = document.getElementById('automaticallyReportInFuture'); + showCertificateErrorReporting(); + if (options.automatic) { + // set the checkbox + checkbox.checked = true; + } + + checkbox.addEventListener('change', function(evt) { + var event = new CustomEvent("AboutNetErrorSetAutomatic", + {bubbles:true, detail:evt.target.checked}); + document.dispatchEvent(event); + }, false); + + var reportBtn = document.getElementById('reportCertificateError'); + var retryBtn = document.getElementById('reportCertificateErrorRetry'); + + reportBtn.addEventListener('click', sendErrorReport, false); + retryBtn.addEventListener('click', sendErrorReport, false); + } + } + }.bind(this), true, true); + + var event = new CustomEvent("AboutNetErrorLoad", {bubbles:true}); + document.dispatchEvent(event); + if (err == "nssBadCert") { // Remove the "Try again" button for security exceptions, since it's // almost certainly useless. @@ -348,6 +410,7 @@ &securityOverride.linkText; + @@ -368,6 +431,28 @@ } + +
+ &errorReporting.title; +
+ +
+

&errorReporting.longDesc;

+

+ + +

+ + &errorReporting.learnMore; + + + + &errorReporting.sending; + &errorReporting.sent; + +
+ "> + + will help us identify and block malicious sites. Thanks for helping create a safer web!"> + + + + + + +

"> diff --git a/browser/themes/shared/aboutNetError.css b/browser/themes/shared/aboutNetError.css index 71da6fbf795..b464906bc57 100644 --- a/browser/themes/shared/aboutNetError.css +++ b/browser/themes/shared/aboutNetError.css @@ -67,3 +67,75 @@ ul { button:disabled { cursor: pointer; } + +div#certificateErrorReporting { + display: none; + float:right; + /* Align with the "Try Again" button */ + margin-top:24px; + margin-right:24px; +} + +div#certificateErrorReporting a, +div#certificateErrorReportingPanel a { + color: #0095DD; +} + +div#certificateErrorReporting a { + text-decoration: none; +} + +div#certificateErrorReporting a:hover { + text-decoration: underline; +} + +span.downArrow { + font-size: 0.9em; +} + +div#certificateErrorReportingPanel { + /* Hidden until the link is clicked */ + display: none; + background-color: white; + border: 1px lightgray solid; + /* Don't use top padding because the default p style has top padding, and it + * makes the overall div look uneven */ + padding: 0 12px 12px 12px; + box-shadow: 0 0 4px #ddd; + position: relative; + width: 75%; + left: 34%; + font-size: 0.9em; + top: 8px; +} + +span#hostname { + font-weight: bold; +} + +#automaticallyReportInFuture { + cursor: pointer; +} + +#reportingState { + padding-left: 150px; +} + +#reportSendingMessage { + position: relative; + display: none; +} + +#reportSentMessage { + position: relative; + display: none; +} + +button#reportCertificateError { + position: relative; +} + +button#reportCertificateErrorRetry { + position: relative; + display: none; +} diff --git a/netwerk/base/public/security-prefs.js b/netwerk/base/public/security-prefs.js index 54ce61019e1..a2dce2034d5 100644 --- a/netwerk/base/public/security-prefs.js +++ b/netwerk/base/public/security-prefs.js @@ -50,3 +50,7 @@ pref("security.password_lifetime", 30); pref("security.OCSP.enabled", 1); pref("security.OCSP.require", false); pref("security.OCSP.GET.enabled", false); + +pref("security.ssl.errorReporting.enabled", true); +pref("security.ssl.errorReporting.url", "https://data.mozilla.com/submit/sslreports-stg"); +pref("security.ssl.errorReporting.automatic", false);