Bug 1240594 - Merge about:neterror and about:certerror UI code. r=Gijs
authorNihanth Subramanya <nhnt11@gmail.com>
Tue, 01 Mar 2016 18:06:20 -0800
changeset 292115 1839dee776400ef389063c87707ae40596ec77dc
parent 292114 04e4fbe0584e4c8d4cfb773875d60b74eeec7543
child 292116 11e583eaf726a4065a65642cdfb5583b65d6065f
push id74762
push usercbook@mozilla.com
push dateThu, 07 Apr 2016 09:56:20 +0000
treeherdermozilla-inbound@772253c53374 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1240594
milestone48.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 1240594 - Merge about:neterror and about:certerror UI code. r=Gijs MozReview-Commit-ID: 8BjT6sKD4KL
browser/base/content/aboutNetError.xhtml
browser/base/content/aboutcerterror/aboutCertError.css
browser/base/content/aboutcerterror/aboutCertError.xhtml
browser/base/jar.mn
browser/components/about/AboutRedirector.cpp
browser/themes/shared/aboutCertError.css
browser/themes/shared/aboutNetError.css
browser/themes/shared/jar.inc.mn
--- a/browser/base/content/aboutNetError.xhtml
+++ b/browser/base/content/aboutNetError.xhtml
@@ -43,16 +43,19 @@
       function getErrorCode()
       {
         var url = document.documentURI;
         var error = url.search(/e\=/);
         var duffUrl = url.search(/\&u\=/);
         return decodeURIComponent(url.slice(error + 2, duffUrl));
       }
 
+      // Set to true on init if the error code is nssBadCert.
+      var gIsCertError;
+
       function getCSSClass()
       {
         var url = document.documentURI;
         var matches = url.match(/s\=([^&]+)\&/);
         // s is optional, if no match just return nothing
         if (!matches || matches.length < 2)
           return "";
 
@@ -98,60 +101,129 @@
       }
 
       function toggleDisplay(node) {
         toggle = {
           '': 'block',
           'none': 'block',
           'block': 'none'
         };
-        node.style.display = toggle[node.style.display];
+        return (node.style.display = toggle[node.style.display]);
       }
 
       function showCertificateErrorReporting() {
         // Display error reporting UI
         document.getElementById('certificateErrorReporting').style.display = 'block';
       }
 
       function showAdvancedButton(allowOverride) {
         // Display weak crypto advanced UI
         document.getElementById("buttonContainer").style.display = "flex";
         document.getElementById("advancedButton").style.display = "block";
         document.getElementById("errorTryAgain").style.display = "none";
 
         // Get the hostname and add it to the panel
-        var panel = document.getElementById("weakCryptoAdvancedPanel");
+        var panelId = gIsCertError ? "badCertAdvancedPanel" : "weakCryptoAdvancedPanel";
+        var panel = document.getElementById(panelId);
         for (var span of panel.querySelectorAll("span.hostname")) {
           span.textContent = document.location.hostname;
         }
-        panel.replaceChild(document.getElementById("errorLongDesc"),
-                           document.getElementById("advancedLongDesc"));
+        if (!gIsCertError) {
+          panel.replaceChild(document.getElementById("errorLongDesc"),
+                             document.getElementById("advancedLongDesc"));
+        }
 
         // Register click handler for the weakCryptoAdvancedPanel
         document.getElementById("advancedButton")
                 .addEventListener("click", function togglePanelVisibility() {
           toggleDisplay(panel);
+          if (gIsCertError) {
+            // Toggling the advanced panel must ensure that the debugging
+            // information panel is hidden as well, since it's opened by the
+            // error code link in the advanced panel.
+            var div = document.getElementById("certificateErrorDebugInformation");
+            div.style.display = "none";
+          }
 
           if (panel.style.display == "block") {
             // send event to trigger telemetry ping
             var event = new CustomEvent("AboutNetErrorUIExpanded", {bubbles:true});
             document.dispatchEvent(event);
           }
         });
 
         if (allowOverride) {
           document.getElementById("overrideWeakCryptoPanel").style.display = "flex";
           var overrideLink = document.getElementById("overrideWeakCrypto");
           overrideLink.addEventListener("click", () => doOverride(overrideLink), false);
         }
       }
 
+      function initPageCertError() {
+        document.body.className = "certerror";
+        document.title = document.getElementById("certErrorPageTitle").textContent;
+        for (let host of document.querySelectorAll(".hostname")) {
+          host.textContent = document.location.hostname;
+        }
+
+        showAdvancedButton(true);
+
+        var cssClass = getCSSClass();
+        if (cssClass == "expertBadCert") {
+          toggleDisplay(document.getElementById("badCertAdvancedPanel"));
+          // Toggling the advanced panel must ensure that the debugging
+          // information panel is hidden as well, since it's opened by the
+          // error code link in the advanced panel.
+          var div = document.getElementById("certificateErrorDebugInformation");
+          div.style.display = "none";
+        }
+
+        document.getElementById("learnMoreContainer").style.display = "block";
+
+        var checkbox = document.getElementById("automaticallyReportInFuture");
+        checkbox.addEventListener("change", function ({target: {checked}}) {
+          document.dispatchEvent(new CustomEvent("AboutNetErrorSetAutomatic", {
+            detail: checked,
+            bubbles: true
+          }));
+        });
+
+        addEventListener("AboutNetErrorOptions", function (event) {
+          var options = JSON.parse(event.detail);
+          if (options && options.enabled) {
+            // Display error reporting UI
+            document.getElementById("certificateErrorReporting").style.display = "block";
+
+            // set the checkbox
+            checkbox.checked = !!options.automatic;
+          }
+        }, true, true);
+
+        // Disallow overrides if this is a Strict-Transport-Security
+        // host and the cert is bad (STS Spec section 7.3) or if the
+        // certerror is in a frame (bug 633691).
+        if (cssClass == "badStsCert" || window != top) {
+          document.getElementById("exceptionDialogButton").setAttribute("hidden", "true");
+        }
+        if (cssClass == "badStsCert") {
+          document.getElementById("badStsCertExplanation").removeAttribute("hidden");
+        }
+
+        document.getElementById("badCertTechnicalInfo").textContent = getDescription();
+
+        var event = new CustomEvent("AboutNetErrorLoad", {bubbles:true});
+        document.getElementById("advancedButton").dispatchEvent(event);
+
+        addDomainErrorLinks();
+      }
+
       function initPage()
       {
         var err = getErrorCode();
+        gIsCertError = (err == "nssBadCert");
 
         // if it's an unknown error or there's no title or description
         // defined, get the generic message
         var errTitle = document.getElementById("et_" + err);
         var errDesc  = document.getElementById("ed_" + err);
         if (!errTitle || !errDesc)
         {
           errTitle = document.getElementById("et_generic");
@@ -162,18 +234,28 @@
         if (title)
         {
           title.parentNode.replaceChild(errTitle, title);
           // change id to the replaced child's id so styling works
           errTitle.id = "errorTitleText";
         }
 
         var sd = document.getElementById("errorShortDescText");
-        if (sd)
-          sd.textContent = getDescription();
+        if (sd) {
+          if (gIsCertError) {
+            sd.textContent = document.getElementById("ed_nssBadCert").textContent;
+          }
+          else {
+            sd.textContent = getDescription();
+          }
+        }
+        if (gIsCertError) {
+          initPageCertError();
+          return;
+        }
 
         var ld = document.getElementById("errorLongDesc");
         if (ld)
         {
           ld.parentNode.replaceChild(errDesc, ld);
           // change id to the replaced child's id so styling works
           errDesc.id = "errorLongDesc";
         }
@@ -206,19 +288,16 @@
           // favicon.  In order to trigger the browser to repaint though, we
           // need to remove/add the link element.
           var favicon = document.getElementById("favicon");
           var faviconParent = favicon.parentNode;
           faviconParent.removeChild(favicon);
           favicon.setAttribute("href", "chrome://global/skin/icons/" + className + "_favicon.png");
           faviconParent.appendChild(favicon);
         }
-        if (className == "expertBadCert") {
-          showSecuritySection();
-        }
 
         if (err == "remoteXUL") {
           // Remove the "Try again" button for remote XUL errors given that
           // it is useless.
           document.getElementById("errorTryAgain").style.display = "none";
         }
 
         if (err == "cspBlocked") {
@@ -260,49 +339,32 @@
           if (getErrorCode() == "weakCryptoUsed" || getErrorCode() == "sslv3Used") {
             showAdvancedButton(getErrorCode() == "weakCryptoUsed");
           }
         }.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.
-          document.getElementById("errorTryAgain").style.display = "none";
-          document.getElementById("errorPageContainer").setAttribute("class", "certerror");
-        }
-        else {
-          // Remove the override block for non-certificate errors.  CSS-hiding
-          // isn't good enough here, because of bug 39098
-          var secOverride = document.getElementById("securityOverrideDiv");
-          secOverride.parentNode.removeChild(secOverride);
-        }
         addDomainErrorLinks();
       }
 
-      function showSecuritySection() {
-        // Swap link out, content in
-        document.getElementById('securityOverrideContent').style.display = '';
-        document.getElementById('securityOverrideLink').style.display = 'none';
-      }
-
       /* Try to preserve the links contained in the error description, like
          the error code.
 
          Also, in the case of SSL error pages about domain mismatch, see if
          we can hyperlink the user to the correct site.  We don't want
          to do this generically since it allows MitM attacks to redirect
          users to a site under attacker control, but in certain cases
          it is safe (and helpful!) to do so.  Bug 402210
       */
       function addDomainErrorLinks() {
         // Rather than textContent, we need to treat description as HTML
-        var sd = document.getElementById("errorShortDescText");
+        var sdid = gIsCertError ? "badCertTechnicalInfo" : "errorShortDescText";
+        var sd = document.getElementById(sdid);
         if (sd) {
           var desc = getDescription();
 
           // sanitize description text - see bug 441169
 
           // First, find the index of the <a> tags we care about, being
           // careful not to use an over-greedy regex.
           var codeRe = /<a id="errorCode" title="([^"]+)">/;
@@ -330,16 +392,31 @@
             sd.appendChild(document.createTextNode(desc.slice(desc.indexOf("</a>") + "</a>".length, codeResult.index)));
           }
           createLink(sd, "errorCode", codeResult[1])
 
           // Finally, append text for anything after the last closing </a>.
           sd.appendChild(document.createTextNode(desc.slice(desc.lastIndexOf("</a>") + "</a>".length)));
         }
 
+        if (gIsCertError) {
+          // Initialize the error code link embedded in the error message to
+          // display debug information about the cert error.
+          var errorCode = document.getElementById("errorCode");
+          if (errorCode) {
+            errorCode.href = "#technicalInformation";
+            errorCode.addEventListener("click", () => {
+              var div = document.getElementById("certificateErrorDebugInformation");
+              if (toggleDisplay(div) == "block") {
+                div.scrollIntoView({block: "start", behavior: "smooth"});
+              }
+            }, false);
+          }
+        }
+
         // Initialize the cert domain link.
         var link = document.getElementById('cert_domain_link');
         if (!link)
           return;
 
         var okHost = link.getAttribute("title");
         var thisHost = document.location.hostname;
         var proto = document.location.protocol;
@@ -370,31 +447,42 @@
          *
          * The certificate is only valid for garage.maemo.org
          */
         if (thisHost.endsWith("." + okHost))
           link.href = proto + okHost;
 
         // If we set a link, meaning there's something helpful for
         // the user here, expand the section by default
-        if (link.href && getCSSClass() != "expertBadCert")
-          toggleVisibility("advancedPanel");
+        if (link.href && getCSSClass() != "expertBadCert") {
+          var panelId = gIsCertError ? "badCertAdvancedPanel" : "weakCryptoAdvancedPanel"
+          toggleDisplay(document.getElementById(panelId));
+          if (gIsCertError) {
+            // Toggling the advanced panel must ensure that the debugging
+            // information panel is hidden as well, since it's opened by the
+            // error code link in the advanced panel.
+            var div = document.getElementById("certificateErrorDebugInformation");
+            div.style.display = "none";
+          }
+        }
       }
 
       function createLink(el, id, text) {
         var anchorEl = document.createElement("a");
         anchorEl.setAttribute("id", id);
         anchorEl.setAttribute("title", text);
         anchorEl.appendChild(document.createTextNode(text));
         el.appendChild(anchorEl);
       }
     ]]></script>
   </head>
 
   <body dir="&locale.dir;">
+    <!-- Contains an alternate page title set on page init for cert errors. -->
+    <div id="certErrorPageTitle" style="display: none;">&certerror.pagetitle1;</div>
 
     <!-- ERROR ITEM CONTAINER (removed during loading to avoid bug 39098) -->
     <div id="errorContainer">
       <div id="errorTitlesContainer">
         <h1 id="et_generic">&generic.title;</h1>
         <h1 id="et_dnsNotFound">&dnsNotFound.title;</h1>
         <h1 id="et_fileNotFound">&fileNotFound.title;</h1>
         <h1 id="et_malformedURI">&malformedURI.title;</h1>
@@ -408,17 +496,17 @@
         <h1 id="et_netOffline">&netOffline.title;</h1>
         <h1 id="et_netInterrupt">&netInterrupt.title;</h1>
         <h1 id="et_deniedPortAccess">&deniedPortAccess.title;</h1>
         <h1 id="et_proxyResolveFailure">&proxyResolveFailure.title;</h1>
         <h1 id="et_proxyConnectFailure">&proxyConnectFailure.title;</h1>
         <h1 id="et_contentEncodingError">&contentEncodingError.title;</h1>
         <h1 id="et_unsafeContentType">&unsafeContentType.title;</h1>
         <h1 id="et_nssFailure2">&nssFailure2.title;</h1>
-        <h1 id="et_nssBadCert">&nssBadCert.title;</h1>
+        <h1 id="et_nssBadCert">&certerror.longpagetitle1;</h1>
         <h1 id="et_cspBlocked">&cspBlocked.title;</h1>
         <h1 id="et_remoteXUL">&remoteXUL.title;</h1>
         <h1 id="et_corruptedContentError">&corruptedContentError.title;</h1>
         <h1 id="et_sslv3Used">&sslv3Used.title;</h1>
         <h1 id="et_weakCryptoUsed">&weakCryptoUsed.title;</h1>
       </div>
       <div id="errorDescriptionsContainer">
         <div id="ed_generic">&generic.longDesc;</div>
@@ -435,17 +523,17 @@
         <div id="ed_netOffline">&netOffline.longDesc2;</div>
         <div id="ed_netInterrupt">&netInterrupt.longDesc;</div>
         <div id="ed_deniedPortAccess">&deniedPortAccess.longDesc;</div>
         <div id="ed_proxyResolveFailure">&proxyResolveFailure.longDesc;</div>
         <div id="ed_proxyConnectFailure">&proxyConnectFailure.longDesc;</div>
         <div id="ed_contentEncodingError">&contentEncodingError.longDesc;</div>
         <div id="ed_unsafeContentType">&unsafeContentType.longDesc;</div>
         <div id="ed_nssFailure2">&nssFailure2.longDesc2;</div>
-        <div id="ed_nssBadCert">&nssBadCert.longDesc2;</div>
+        <div id="ed_nssBadCert">&certerror.introPara;</div>
         <div id="ed_cspBlocked">&cspBlocked.longDesc;</div>
         <div id="ed_remoteXUL">&remoteXUL.longDesc;</div>
         <div id="ed_corruptedContentError">&corruptedContentError.longDesc;</div>
         <div id="ed_sslv3Used">&sslv3Used.longDesc2;</div>
         <div id="ed_weakCryptoUsed">&weakCryptoUsed.longDesc2;</div>
       </div>
     </div>
 
@@ -459,27 +547,21 @@
 
       <!-- LONG CONTENT (the section most likely to require scrolling) -->
       <div id="errorLongContent">
 
         <!-- Short Description -->
         <div id="errorShortDesc">
           <p id="errorShortDescText" />
         </div>
+        <p id="badStsCertExplanation" hidden="true">&certerror.whatShouldIDo.badStsCertExplanation;</p>
 
         <!-- Long Description (Note: See netError.dtd for used XHTML tags) -->
         <div id="errorLongDesc" />
 
-        <!-- Override section - For ssl errors only.  Removed on init for other
-             error types.  -->
-        <div id="securityOverrideDiv">
-          <a id="securityOverrideLink" href="javascript:showSecuritySection();" >&securityOverride.linkText;</a>
-          <div id="securityOverrideContent" style="display: none;">&securityOverride.warningContent;</div>
-        </div>
-
         <div id="learnMoreContainer">
           <p><a href="https://support.mozilla.org/kb/what-does-your-connection-is-not-secure-mean" id="learnMoreLink" target="new">&errorReporting.learnMore;</a></p>
         </div>
 
         <div id="buttonContainer">
           <button id="returnButton" autocomplete="off" autofocus="true">&returnToPreviousPage.label;</button>
           <div id="buttonSpacer"></div>
           <button id="advancedButton" autocomplete="off" autofocus="true">&advanced.label;</button>
@@ -517,16 +599,28 @@
           <p>&weakCryptoAdvanced.longDesc;</p>
         </div>
         <div id="advancedLongDesc" />
         <div id="overrideWeakCryptoPanel">
           <a id="overrideWeakCrypto" href="#">&weakCryptoAdvanced.override;</a>
         </div>
       </div>
 
+      <div id="badCertAdvancedPanel">
+        <p id="badCertTechnicalInfo"/>
+        <button id="exceptionDialogButton">&securityOverride.exceptionButtonLabel;</button>
+      </div>
+
+    </div>
+
+    <div id="certificateErrorDebugInformation">
+      <a name="technicalInformation"></a>
+      <button id="copyToClipboard">&certerror.copyToClipboard.label;</button>
+      <div id="certificateErrorText"/>
+      <button id="copyToClipboard">&certerror.copyToClipboard.label;</button>
     </div>
 
     <!--
     - Note: It is important to run the script this way, instead of using
     - an onload handler. This is because error pages are loaded as
     - LOAD_BACKGROUND, which means that onload handlers will not be executed.
     -->
     <script type="application/javascript">initPage();</script>
deleted file mode 100644
--- a/browser/base/content/aboutcerterror/aboutCertError.css
+++ /dev/null
@@ -1,17 +0,0 @@
-/* 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/. */
-
-/* Logical CSS rules belong here, but presentation & theming rules
-   should live in the CSS of the appropriate theme */
-
-#technicalContentText {
-  overflow: auto;
-  white-space: pre-wrap;
-}
-
-.expander[hidden],
-.expander[hidden] + *,
-.expander[collapsed] + * {
-  display: none;
-}
deleted file mode 100644
--- a/browser/base/content/aboutcerterror/aboutCertError.xhtml
+++ /dev/null
@@ -1,308 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!DOCTYPE html [
-  <!ENTITY % htmlDTD
-    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-    "DTD/xhtml1-strict.dtd">
-  %htmlDTD;
-  <!ENTITY % globalDTD
-    SYSTEM "chrome://global/locale/global.dtd">
-  %globalDTD;
-  <!ENTITY % certerrorDTD
-    SYSTEM "chrome://browser/locale/aboutCertError.dtd">
-  %certerrorDTD;
-]>
-
-<!-- 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/. -->
-<html xmlns="http://www.w3.org/1999/xhtml">
-  <head>
-    <title>&certerror.pagetitle1;</title>
-    <link rel="stylesheet" href="chrome://browser/skin/aboutCertError.css" type="text/css" media="all" />
-    <link rel="stylesheet" href="chrome://browser/content/certerror/aboutCertError.css" type="text/css" media="all" />
-    <!-- This page currently uses the same favicon as neterror.xhtml.
-         If the location of the favicon is changed for both pages, the
-         FAVICON_ERRORPAGE_URL symbol in toolkit/components/places/src/nsFaviconService.h
-         should be updated. If this page starts using a different favicon
-         than neterror.xhtml nsFaviconService->SetAndLoadFaviconForPage
-         should be updated to ignore this one as well. -->
-    <link rel="icon" type="image/png" id="favicon" href="chrome://global/skin/icons/warning-16.png"/>
-
-    <script type="application/javascript"><![CDATA[
-      // Error url MUST be formatted like this:
-      //   about:certerror?e=error&u=url&d=desc
-
-      // Note that this file uses document.documentURI to get
-      // the URL (with the format from above). This is because
-      // document.location.href gets the current URI off the docshell,
-      // which is the URL displayed in the location bar, i.e.
-      // the URI that the user attempted to load.
-
-      function getCSSClass()
-      {
-        var url = document.documentURI;
-        var matches = url.match(/s\=([^&]+)\&/);
-        // s is optional, if no match just return nothing
-        if (!matches || matches.length < 2)
-          return "";
-
-        // parenthetical match is the second entry
-        return decodeURIComponent(matches[1]);
-      }
-
-      function toggleVisibility(id)
-      {
-        var node = document.getElementById(id);
-        node.style.visibility = node.style.visibility == "" ? "hidden" : "";
-        // Toggling the advanced panel must ensure that the debugging
-        // information panel is hidden as well, since it's opened by the
-        // error code link in the advanced panel.
-        if (id == "advancedPanel") {
-          var div = document.getElementById("certificateErrorDebugInformation");
-          div.style.display = "none";
-        }
-      }
-
-      function getDescription()
-      {
-        var url = document.documentURI;
-        var desc = url.search(/d\=/);
-
-        // desc == -1 if not found; if so, return an empty string
-        // instead of what would turn out to be portions of the URI
-        if (desc == -1)
-          return "";
-
-        return decodeURIComponent(url.slice(desc + 2));
-      }
-
-      function initPage()
-      {
-        for (let host of document.querySelectorAll(".hostname")) {
-          host.textContent = document.location.hostname;
-        }
-
-        var cssClass = getCSSClass();
-        if (cssClass == "expertBadCert") {
-          toggleVisibility('advancedPanel');
-        }
-
-        var checkbox = document.getElementById("automaticallyReportInFuture");
-        checkbox.addEventListener("change", function ({target: {checked}}) {
-          document.dispatchEvent(new CustomEvent("AboutCertErrorSetAutomatic", {
-            detail: checked,
-            bubbles: true
-          }));
-        });
-
-        addEventListener("AboutCertErrorOptions", function (event) {
-          var options = JSON.parse(event.detail);
-          if (options && options.enabled) {
-            // Display error reporting UI
-            document.getElementById("certificateErrorReporting").style.display = "block";
-
-            // set the checkbox
-            checkbox.checked = !!options.automatic;
-          }
-        }, true, true);
-
-        // Disallow overrides if this is a Strict-Transport-Security
-        // host and the cert is bad (STS Spec section 7.3) or if the
-        // certerror is in a frame (bug 633691).
-        if (cssClass == "badStsCert" || window != top) {
-          document.getElementById("exceptionDialogButton").setAttribute("hidden", "true");
-        }
-        if (cssClass != "badStsCert") {
-          document.getElementById("badStsCertExplanation").setAttribute("hidden", "true");
-        }
-
-        var tech = document.getElementById("technicalContentText");
-        if (tech)
-          tech.textContent = getDescription();
-
-        var event = new CustomEvent("AboutCertErrorLoad", {bubbles:true});
-        document.getElementById("advancedButton").dispatchEvent(event);
-
-        addDomainErrorLinks();
-      }
-
-      /* Try to preserve the links contained in the error description, like
-         the error code.
-
-         Also, in the case of SSL error pages about domain mismatch, see if
-         we can hyperlink the user to the correct site.  We don't want
-         to do this generically since it allows MitM attacks to redirect
-         users to a site under attacker control, but in certain cases
-         it is safe (and helpful!) to do so.  Bug 402210
-      */
-      function addDomainErrorLinks() {
-        // Rather than textContent, we need to treat description as HTML
-        var sd = document.getElementById("technicalContentText");
-        if (sd) {
-          var desc = getDescription();
-
-          // sanitize description text - see bug 441169
-
-          // First, find the index of the <a> tags we care about, being
-          // careful not to use an over-greedy regex.
-          var codeRe = /<a id="errorCode" title="([^"]+)">/;
-          var codeResult = codeRe.exec(desc);
-          var domainRe = /<a id="cert_domain_link" title="([^"]+)">/;
-          var domainResult = domainRe.exec(desc);
-
-          // The order of these links in the description is fixed in
-          // TransportSecurityInfo.cpp:formatOverridableCertErrorMessage.
-          var firstResult = domainResult;
-          if(!domainResult)
-            firstResult = codeResult;
-          if (!firstResult)
-            return;
-
-          // Remove sd's existing children
-          sd.textContent = "";
-
-          // Everything up to the first link should be text content.
-          sd.appendChild(document.createTextNode(desc.slice(0, firstResult.index)));
-
-          // Now create the actual links.
-          if (domainResult) {
-            createLink(sd, "cert_domain_link", domainResult[1])
-            // Append text for anything between the two links.
-            sd.appendChild(document.createTextNode(desc.slice(desc.indexOf("</a>") + "</a>".length, codeResult.index)));
-          }
-          createLink(sd, "errorCode", codeResult[1])
-
-          // Finally, append text for anything after the last closing </a>.
-          sd.appendChild(document.createTextNode(desc.slice(desc.lastIndexOf("</a>") + "</a>".length)));
-        }
-
-        // Initialize the error code link embedded in the error message to
-        // display debug information about the cert error.
-        var errorCode = document.getElementById("errorCode");
-        if (errorCode) {
-          errorCode.href = "#technicalInformation";
-          errorCode.addEventListener("click", () => {
-            var div = document.getElementById("certificateErrorDebugInformation");
-            if (div.style.display == "block") {
-              div.style.display = "none";
-            } else {
-              div.style.display = "block";
-              div.scrollIntoView(true);
-            }
-          }, false);
-        }
-
-        // Then initialize the cert domain link.
-        var link = document.getElementById('cert_domain_link');
-        if (!link)
-          return;
-
-        var okHost = link.getAttribute("title");
-        var thisHost = document.location.hostname;
-        var proto = document.location.protocol;
-
-        // If okHost is a wildcard domain ("*.example.com") let's
-        // use "www" instead.  "*.example.com" isn't going to
-        // get anyone anywhere useful. bug 432491
-        okHost = okHost.replace(/^\*\./, "www.");
-
-        /* case #1:
-         * example.com uses an invalid security certificate.
-         *
-         * The certificate is only valid for www.example.com
-         *
-         * Make sure to include the "." ahead of thisHost so that
-         * a MitM attack on paypal.com doesn't hyperlink to "notpaypal.com"
-         *
-         * We'd normally just use a RegExp here except that we lack a
-         * library function to escape them properly (bug 248062), and
-         * domain names are famous for having '.' characters in them,
-         * which would allow spurious and possibly hostile matches.
-         */
-        if (okHost.endsWith("." + thisHost))
-          link.href = proto + okHost;
-
-        /* case #2:
-         * browser.garage.maemo.org uses an invalid security certificate.
-         *
-         * The certificate is only valid for garage.maemo.org
-         */
-        if (thisHost.endsWith("." + okHost))
-          link.href = proto + okHost;
-
-        // If we set a link, meaning there's something helpful for
-        // the user here, expand the section by default
-        if (link.href && getCSSClass() != "expertBadCert")
-          toggleVisibility("advancedPanel");
-      }
-
-      function createLink(el, id, text) {
-        var anchorEl = document.createElement("a");
-        anchorEl.setAttribute("id", id);
-        anchorEl.setAttribute("title", text);
-        anchorEl.appendChild(document.createTextNode(text));
-        el.appendChild(anchorEl);
-      }
-    ]]></script>
-  </head>
-
-  <body dir="&locale.dir;">
-    <!-- PAGE CONTAINER (for styling purposes only) -->
-    <div id="errorPageContainer">
-
-      <!-- Error Title -->
-      <div id="errorTitle">
-        <h1 id="errorTitleText">&certerror.longpagetitle1;</h1>
-      </div>
-
-      <!-- LONG CONTENT (the section most likely to require scrolling) -->
-      <div id="errorLongContent">
-
-        <!-- Short Description -->
-        <div id="errorShortDesc">
-          <p>&certerror.introPara;</p>
-        </div>
-        <p id="badStsCertExplanation">&certerror.whatShouldIDo.badStsCertExplanation;</p>
-        <div>
-          <p><a href="https://support.mozilla.org/kb/what-does-your-connection-is-not-secure-mean" id="learnMoreLink" target="new">&certerror.learnMore;</a></p>
-        </div>
-
-        <div id="buttonContainer">
-          <button id="returnButton" autocomplete="off" autofocus="true">&certerror.returnToPreviousPage.label;</button>
-          <div id="buttonSpacer"></div>
-          <button id="advancedButton" autocomplete="off" onclick="toggleVisibility('advancedPanel');" autofocus="true">&certerror.advanced.label;</button>
-        </div>
-      </div>
-
-      <!-- UI for option to report certificate errors to Mozilla. -->
-      <div id="certificateErrorReporting">
-        <p>
-          <input type="checkbox" id="automaticallyReportInFuture" />
-          <label for="automaticallyReportInFuture" id="automaticallyReportInFuture">&errorReporting.automatic;</label>
-        </p>
-      </div>
-
-      <!-- Advanced panel, which is hidden by default -->
-      <div id="advancedPanel" style="visibility: hidden;">
-        <p id="technicalContentText"/>
-        <button id="exceptionDialogButton">&certerror.addException.label;</button>
-      </div>
-    </div>
-
-    <div id="certificateErrorDebugInformation">
-      <a name="technicalInformation"></a>
-      <button id="copyToClipboard">&certerror.copyToClipboard.label;</button>
-      <div id="certificateErrorText"/>
-      <button id="copyToClipboard">&certerror.copyToClipboard.label;</button>
-    </div>
-
-    <!--
-    - Note: It is important to run the script this way, instead of using
-    - an onload handler. This is because error pages are loaded as
-    - LOAD_BACKGROUND, which means that onload handlers will not be executed.
-    -->
-    <script type="application/javascript">initPage();</script>
-
-  </body>
-</html>
--- a/browser/base/jar.mn
+++ b/browser/base/jar.mn
@@ -56,18 +56,16 @@ browser.jar:
         content/browser/aboutaccounts/aboutaccounts.js                        (content/aboutaccounts/aboutaccounts.js)
         content/browser/aboutaccounts/aboutaccounts.css                       (content/aboutaccounts/aboutaccounts.css)
         content/browser/aboutaccounts/main.css                                (content/aboutaccounts/main.css)
         content/browser/aboutaccounts/normalize.css                           (content/aboutaccounts/normalize.css)
         content/browser/aboutaccounts/images/fox.png                          (content/aboutaccounts/images/fox.png)
         content/browser/aboutaccounts/images/graphic_sync_intro.png           (content/aboutaccounts/images/graphic_sync_intro.png)
         content/browser/aboutaccounts/images/graphic_sync_intro@2x.png        (content/aboutaccounts/images/graphic_sync_intro@2x.png)
 
-        content/browser/certerror/aboutCertError.xhtml     (content/aboutcerterror/aboutCertError.xhtml)
-        content/browser/certerror/aboutCertError.css       (content/aboutcerterror/aboutCertError.css)
 
         content/browser/aboutRobots-icon.png          (content/aboutRobots-icon.png)
         content/browser/aboutRobots-widget-left.png   (content/aboutRobots-widget-left.png)
         content/browser/aboutSocialError.xhtml        (content/aboutSocialError.xhtml)
         content/browser/aboutProviderDirectory.xhtml  (content/aboutProviderDirectory.xhtml)
         content/browser/aboutTabCrashed.css           (content/aboutTabCrashed.css)
         content/browser/aboutTabCrashed.js            (content/aboutTabCrashed.js)
         content/browser/aboutTabCrashed.xhtml         (content/aboutTabCrashed.xhtml)
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -41,17 +41,17 @@ struct RedirEntry {
 static RedirEntry kRedirMap[] = {
 #ifdef MOZ_SAFE_BROWSING
   { "blocked", "chrome://browser/content/blockedSite.xhtml",
     nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
     nsIAboutModule::URI_CAN_LOAD_IN_CHILD |
     nsIAboutModule::ALLOW_SCRIPT |
     nsIAboutModule::HIDE_FROM_ABOUTABOUT },
 #endif
-  { "certerror", "chrome://browser/content/certerror/aboutCertError.xhtml",
+  { "certerror", "chrome://browser/content/aboutNetError.xhtml",
     nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
     nsIAboutModule::URI_CAN_LOAD_IN_CHILD |
     nsIAboutModule::ALLOW_SCRIPT |
     nsIAboutModule::HIDE_FROM_ABOUTABOUT },
   { "socialerror", "chrome://browser/content/aboutSocialError.xhtml",
     nsIAboutModule::ALLOW_SCRIPT |
     nsIAboutModule::HIDE_FROM_ABOUTABOUT },
   { "providerdirectory", "chrome://browser/content/aboutProviderDirectory.xhtml",
deleted file mode 100644
--- a/browser/themes/shared/aboutCertError.css
+++ /dev/null
@@ -1,119 +0,0 @@
-/* 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/. */
-
-@import url("chrome://global/skin/in-content/common.css");
-
-body {
-  display: flex;
-  box-sizing: border-box;
-  min-height: 100vh;
-  padding: 0 48px;
-  align-items: center;
-  justify-content: center;
-}
-
-#errorPageContainer {
-  position: relative;
-  min-width: 320px;
-  max-width: 512px;
-}
-
-#errorTitle {
-  background: url("chrome://browser/skin/cert-error.svg") left 0 no-repeat;
-  background-size: 3em;
-  margin-inline-start: -5em;
-  padding-inline-start: 5em;
-}
-
-#errorTitle:-moz-dir(rtl) {
-  background-position: right 0;
-}
-
-#errorTitleText {
-  border-bottom: 1px solid #C1C1C1;
-  padding-bottom: 0.4em;
-}
-
-@media (max-width: 675px) {
-  #errorTitle {
-    padding-top: 0;
-    background-image: none;
-    margin-inline-start: 0;
-    padding-inline-start: 0;
-  }
-}
-
-#buttonContainer {
-  display: flex;
-  flex-flow: row wrap;
-}
-
-#buttonSpacer {
-  flex: 1;
-}
-
-#certificateErrorDebugInformation {
-  display: none;
-  background-color: var(--in-content-box-background-hover) !important;
-  border-top: 1px solid var(--in-content-border-color);
-  position: absolute;
-  left: 0%;
-  top: 100%;
-  width: 65%;
-  padding: 1em 17.5%;
-}
-
-#certificateErrorText {
-  font-family: monospace;
-  white-space: pre-wrap;
-  padding: 1em 0;
-}
-
-#errorCode {
-  white-space: nowrap;
-}
-
-#returnButton {
-  background-color: var(--in-content-primary-button-background);
-  border: none;
-  color: var(--in-content-selected-text);
-  min-width: 250px;
-  margin-inline-start: 0;
-}
-
-#returnButton:hover {
-  background-color: var(--in-content-primary-button-background-hover) !important;
-}
-
-#returnButton:hover:active {
-  background-color: var(--in-content-primary-button-background-active) !important;
-}
-
-#advancedButton {
-  min-width: 150px;
-}
-
-/* Advanced section is hidden via inline styles until the link is clicked */
-#advancedPanel {
-  background-color: white;
-  color: var(--in-content-text-color);
-  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 10px;
-  margin-top: 10px;
-  box-shadow: 0 0 4px #ddd;
-  font-size: 0.9em;
-}
-
-.hostname {
-  font-weight: bold;
-}
-
-#reportCertificateErrorRetry,
-#certificateErrorReporting,
-#reportSendingMessage,
-#reportSentMessage {
-  display: none;
-}
--- a/browser/themes/shared/aboutNetError.css
+++ b/browser/themes/shared/aboutNetError.css
@@ -35,16 +35,20 @@ ul {
 
 #errorTitle {
   background: url("chrome://global/skin/icons/info.svg") left 0 no-repeat;
   background-size: 3em;
   -moz-margin-start: -5em;
   -moz-padding-start: 5em;
 }
 
+body.certerror #errorTitle {
+  background-image: url("chrome://browser/skin/cert-error.svg");
+}
+
 #errorTitleText {
   border-bottom: 1px solid #C1C1C1;
   padding-bottom: 0.4em;
 }
 
 #errorTitleText:-moz-dir(rtl) {
   background-position: right 0;
 }
@@ -110,55 +114,32 @@ button:disabled {
   background-color: var(--in-content-primary-button-background-active) !important;
 }
 
 #advancedButton {
   display: none;
   min-width: 150px;
 }
 
-#certificateErrorReporting,
-#reportSentMessage {
+#certificateErrorReporting {
   display: none;
 }
 
-div#weakCryptoAdvanced {
-  display: none;
-  float: right;
-  /* Align with the "Try Again" button */
-  margin-top: 24px;
-  -moz-margin-end: 24px;
-}
-
-div#weakCryptoAdvanced a {
-  text-decoration: none;
-}
-
-div#weakCryptoAdvanced a:hover {
-  text-decoration: underline;
-}
-
-span.downArrow {
-  display: inline-block;
-  vertical-align: middle;
-  font-size: 0.6em;
-  -moz-margin-start: 0.5em;
-  transform: scaleY(0.7);
-}
-
-div#weakCryptoAdvancedPanel {
+#weakCryptoAdvancedPanel,
+#badCertAdvancedPanel {
   /* 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;
   font-size: 0.9em;
+  margin-top: 24px;
 }
 
 #overrideWeakCryptoPanel {
   display: none;
   flex-direction: row;
   flex-wrap: wrap;
   justify-content: space-between;
   align-content: space-between;
@@ -169,13 +150,43 @@ div#weakCryptoAdvancedPanel {
 span#hostname {
   font-weight: bold;
 }
 
 #automaticallyReportInFuture {
   cursor: pointer;
 }
 
-#errorCode {
+body:not(.certerror) #errorCode {
   color: var(--in-content-page-color);
   cursor: text;
   text-decoration: none;
 }
+
+body.certerror #errorCode {
+  white-space: nowrap;
+}
+
+#badCertTechnicalInfo {
+  overflow: auto;
+  white-space: pre-wrap;
+}
+
+#certificateErrorReporting {
+  display: none;
+}
+
+#certificateErrorDebugInformation {
+  display: none;
+  background-color: var(--in-content-box-background-hover) !important;
+  border-top: 1px solid var(--in-content-border-color);
+  position: absolute;
+  left: 0%;
+  top: 100%;
+  width: 65%;
+  padding: 1em 17.5%;
+}
+
+#certificateErrorText {
+  font-family: monospace;
+  white-space: pre-wrap;
+  padding: 1em 0;
+}
--- a/browser/themes/shared/jar.inc.mn
+++ b/browser/themes/shared/jar.inc.mn
@@ -2,17 +2,16 @@
 # 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/.
 
 # This is not a complete / proper jar manifest. It is included by the
 # actual theme-specific manifests, so that shared resources need only
 # be specified once. As a result, the source file paths are relative
 # to the location of the actual manifest.
 
-  skin/classic/browser/aboutCertError.css                      (../shared/aboutCertError.css)
   skin/classic/browser/aboutNetError.css                       (../shared/aboutNetError.css)
 * skin/classic/browser/aboutProviderDirectory.css              (../shared/aboutProviderDirectory.css)
 * skin/classic/browser/aboutSessionRestore.css                 (../shared/aboutSessionRestore.css)
   skin/classic/browser/aboutSocialError.css                    (../shared/aboutSocialError.css)
   skin/classic/browser/aboutTabCrashed.css                     (../shared/aboutTabCrashed.css)
   skin/classic/browser/aboutWelcomeBack.css                    (../shared/aboutWelcomeBack.css)
   skin/classic/browser/addons/addon-install-blocked.svg        (../shared/addons/addon-install-blocked.svg)
   skin/classic/browser/addons/addon-install-confirm.svg        (../shared/addons/addon-install-confirm.svg)