docshell/resources/content/netError.xhtml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/resources/content/netError.xhtml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,381 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +
     1.6 +<!DOCTYPE html [
     1.7 +  <!ENTITY % htmlDTD
     1.8 +    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     1.9 +    "DTD/xhtml1-strict.dtd">
    1.10 +  %htmlDTD;
    1.11 +  <!ENTITY % netErrorDTD
    1.12 +    SYSTEM "chrome://global/locale/netError.dtd">
    1.13 +  %netErrorDTD;
    1.14 +  <!ENTITY % globalDTD
    1.15 +    SYSTEM "chrome://global/locale/global.dtd">
    1.16 +  %globalDTD;
    1.17 +]>
    1.18 +
    1.19 +<!-- This Source Code Form is subject to the terms of the Mozilla Public
    1.20 +   - License, v. 2.0. If a copy of the MPL was not distributed with this
    1.21 +   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
    1.22 +
    1.23 +<html xmlns="http://www.w3.org/1999/xhtml">
    1.24 +  <head>
    1.25 +    <title>&loadError.label;</title>
    1.26 +    <link rel="stylesheet" href="chrome://global/skin/netError.css" type="text/css" media="all" />
    1.27 +    <!-- If the location of the favicon is changed here, the FAVICON_ERRORPAGE_URL symbol in
    1.28 +         toolkit/components/places/src/nsFaviconService.h should be updated. -->
    1.29 +    <link rel="icon" type="image/png" id="favicon" href="chrome://global/skin/icons/warning-16.png"/>
    1.30 +
    1.31 +    <script type="application/javascript"><![CDATA[
    1.32 +      // Error url MUST be formatted like this:
    1.33 +      //   moz-neterror:page?e=error&u=url&d=desc
    1.34 +      //
    1.35 +      // or optionally, to specify an alternate CSS class to allow for
    1.36 +      // custom styling and favicon:
    1.37 +      //
    1.38 +      //   moz-neterror:page?e=error&u=url&s=classname&d=desc
    1.39 +
    1.40 +      // Note that this file uses document.documentURI to get
    1.41 +      // the URL (with the format from above). This is because
    1.42 +      // document.location.href gets the current URI off the docshell,
    1.43 +      // which is the URL displayed in the location bar, i.e.
    1.44 +      // the URI that the user attempted to load.
    1.45 +
    1.46 +      function getErrorCode()
    1.47 +      {
    1.48 +        var url = document.documentURI;
    1.49 +        var error = url.search(/e\=/);
    1.50 +        var duffUrl = url.search(/\&u\=/);
    1.51 +        return decodeURIComponent(url.slice(error + 2, duffUrl));
    1.52 +      }
    1.53 +
    1.54 +      function getCSSClass()
    1.55 +      {
    1.56 +        var url = document.documentURI;
    1.57 +        var matches = url.match(/s\=([^&]+)\&/);
    1.58 +        // s is optional, if no match just return nothing
    1.59 +        if (!matches || matches.length < 2)
    1.60 +          return "";
    1.61 +
    1.62 +        // parenthetical match is the second entry
    1.63 +        return decodeURIComponent(matches[1]);
    1.64 +      }
    1.65 +
    1.66 +      function getDescription()
    1.67 +      {
    1.68 +        var url = document.documentURI;
    1.69 +        var desc = url.search(/d\=/);
    1.70 +
    1.71 +        // desc == -1 if not found; if so, return an empty string
    1.72 +        // instead of what would turn out to be portions of the URI
    1.73 +        if (desc == -1)
    1.74 +          return "";
    1.75 +
    1.76 +        return decodeURIComponent(url.slice(desc + 2));
    1.77 +      }
    1.78 +
    1.79 +      function retryThis(buttonEl)
    1.80 +      {
    1.81 +        // Note: The application may wish to handle switching off "offline mode"
    1.82 +        // before this event handler runs, but using a capturing event handler.
    1.83 +
    1.84 +        // Session history has the URL of the page that failed
    1.85 +        // to load, not the one of the error page. So, just call
    1.86 +        // reload(), which will also repost POST data correctly.
    1.87 +        try {
    1.88 +          location.reload();
    1.89 +        } catch (e) {
    1.90 +          // We probably tried to reload a URI that caused an exception to
    1.91 +          // occur;  e.g. a nonexistent file.
    1.92 +        }
    1.93 +
    1.94 +        buttonEl.disabled = true;
    1.95 +      }
    1.96 +
    1.97 +      function initPage()
    1.98 +      {
    1.99 +        var err = getErrorCode();
   1.100 +        
   1.101 +        // if it's an unknown error or there's no title or description
   1.102 +        // defined, get the generic message
   1.103 +        var errTitle = document.getElementById("et_" + err);
   1.104 +        var errDesc  = document.getElementById("ed_" + err);
   1.105 +        if (!errTitle || !errDesc)
   1.106 +        {
   1.107 +          errTitle = document.getElementById("et_generic");
   1.108 +          errDesc  = document.getElementById("ed_generic");
   1.109 +        }
   1.110 +
   1.111 +        var title = document.getElementById("errorTitleText");
   1.112 +        if (title)
   1.113 +        {
   1.114 +          title.parentNode.replaceChild(errTitle, title);
   1.115 +          // change id to the replaced child's id so styling works
   1.116 +          errTitle.id = "errorTitleText";
   1.117 +        }
   1.118 +
   1.119 +        var sd = document.getElementById("errorShortDescText");
   1.120 +        if (sd)
   1.121 +          sd.textContent = getDescription();
   1.122 +
   1.123 +        var ld = document.getElementById("errorLongDesc");
   1.124 +        if (ld)
   1.125 +        {
   1.126 +          ld.parentNode.replaceChild(errDesc, ld);
   1.127 +          // change id to the replaced child's id so styling works
   1.128 +          errDesc.id = "errorLongDesc";
   1.129 +        }
   1.130 +
   1.131 +        // remove undisplayed errors to avoid bug 39098
   1.132 +        var errContainer = document.getElementById("errorContainer");
   1.133 +        errContainer.parentNode.removeChild(errContainer);
   1.134 +
   1.135 +        var className = getCSSClass();
   1.136 +        if (className && className != "expertBadCert") {
   1.137 +          // Associate a CSS class with the root of the page, if one was passed in,
   1.138 +          // to allow custom styling.
   1.139 +          // Not "expertBadCert" though, don't want to deal with the favicon
   1.140 +          document.documentElement.className = className;
   1.141 +
   1.142 +          // Also, if they specified a CSS class, they must supply their own
   1.143 +          // favicon.  In order to trigger the browser to repaint though, we
   1.144 +          // need to remove/add the link element. 
   1.145 +          var favicon = document.getElementById("favicon");
   1.146 +          var faviconParent = favicon.parentNode;
   1.147 +          faviconParent.removeChild(favicon);
   1.148 +          favicon.setAttribute("href", "chrome://global/skin/icons/" + className + "_favicon.png");
   1.149 +          faviconParent.appendChild(favicon);
   1.150 +        }
   1.151 +        if (className == "expertBadCert") {
   1.152 +          showSecuritySection();
   1.153 +        }
   1.154 +
   1.155 +        if (err == "remoteXUL") {
   1.156 +          // Remove the "Try again" button for remote XUL errors given that
   1.157 +          // it is useless.
   1.158 +          document.getElementById("errorTryAgain").style.display = "none";
   1.159 +        }
   1.160 +
   1.161 +        if (err == "cspFrameAncestorBlocked") {
   1.162 +          // Remove the "Try again" button for CSP frame ancestors violation, since it's
   1.163 +          // almost certainly useless. (Bug 553180)
   1.164 +          document.getElementById("errorTryAgain").style.display = "none";
   1.165 +        }
   1.166 +
   1.167 +        if (err == "nssBadCert") {
   1.168 +          // Remove the "Try again" button for security exceptions, since it's
   1.169 +          // almost certainly useless.
   1.170 +          document.getElementById("errorTryAgain").style.display = "none";
   1.171 +          document.getElementById("errorPageContainer").setAttribute("class", "certerror");
   1.172 +          addDomainErrorLink();
   1.173 +        }
   1.174 +        else {
   1.175 +          // Remove the override block for non-certificate errors.  CSS-hiding
   1.176 +          // isn't good enough here, because of bug 39098
   1.177 +          var secOverride = document.getElementById("securityOverrideDiv");
   1.178 +          secOverride.parentNode.removeChild(secOverride);
   1.179 +        }
   1.180 +      }
   1.181 +      
   1.182 +      function showSecuritySection() {
   1.183 +        // Swap link out, content in
   1.184 +        document.getElementById('securityOverrideContent').style.display = '';
   1.185 +        document.getElementById('securityOverrideLink').style.display = 'none';
   1.186 +      }
   1.187 +      
   1.188 +      /* In the case of SSL error pages about domain mismatch, see if
   1.189 +         we can hyperlink the user to the correct site.  We don't want
   1.190 +         to do this generically since it allows MitM attacks to redirect
   1.191 +         users to a site under attacker control, but in certain cases
   1.192 +         it is safe (and helpful!) to do so.  Bug 402210
   1.193 +      */
   1.194 +      function addDomainErrorLink() {
   1.195 +        // Rather than textContent, we need to treat description as HTML
   1.196 +        var sd = document.getElementById("errorShortDescText");
   1.197 +        if (sd) {
   1.198 +          var desc = getDescription();
   1.199 +          
   1.200 +          // sanitize description text - see bug 441169
   1.201 +          
   1.202 +          // First, find the index of the <a> tag we care about, being careful not to
   1.203 +          // use an over-greedy regex
   1.204 +          var re = /<a id="cert_domain_link" title="([^"]+)">/;
   1.205 +          var result = re.exec(desc);
   1.206 +          if(!result)
   1.207 +            return;
   1.208 +          
   1.209 +          // Remove sd's existing children
   1.210 +          sd.textContent = "";
   1.211 +
   1.212 +          // Everything up to the link should be text content
   1.213 +          sd.appendChild(document.createTextNode(desc.slice(0, result.index)));
   1.214 +          
   1.215 +          // Now create the link itself
   1.216 +          var anchorEl = document.createElement("a");
   1.217 +          anchorEl.setAttribute("id", "cert_domain_link");
   1.218 +          anchorEl.setAttribute("title", result[1]);
   1.219 +          anchorEl.appendChild(document.createTextNode(result[1]));
   1.220 +          sd.appendChild(anchorEl);
   1.221 +          
   1.222 +          // Finally, append text for anything after the closing </a>
   1.223 +          sd.appendChild(document.createTextNode(desc.slice(desc.indexOf("</a>") + "</a>".length)));
   1.224 +        }
   1.225 +
   1.226 +        var link = document.getElementById('cert_domain_link');
   1.227 +        if (!link)
   1.228 +          return;
   1.229 +        
   1.230 +        var okHost = link.getAttribute("title");
   1.231 +        var thisHost = document.location.hostname;
   1.232 +        var proto = document.location.protocol;
   1.233 +
   1.234 +        // If okHost is a wildcard domain ("*.example.com") let's
   1.235 +        // use "www" instead.  "*.example.com" isn't going to
   1.236 +        // get anyone anywhere useful. bug 432491
   1.237 +        okHost = okHost.replace(/^\*\./, "www.");
   1.238 +
   1.239 +        /* case #1: 
   1.240 +         * example.com uses an invalid security certificate.
   1.241 +         *
   1.242 +         * The certificate is only valid for www.example.com
   1.243 +         *
   1.244 +         * Make sure to include the "." ahead of thisHost so that
   1.245 +         * a MitM attack on paypal.com doesn't hyperlink to "notpaypal.com"
   1.246 +         *
   1.247 +         * We'd normally just use a RegExp here except that we lack a
   1.248 +         * library function to escape them properly (bug 248062), and
   1.249 +         * domain names are famous for having '.' characters in them,
   1.250 +         * which would allow spurious and possibly hostile matches.
   1.251 +         */
   1.252 +        if (endsWith(okHost, "." + thisHost))
   1.253 +          link.href = proto + okHost;
   1.254 +
   1.255 +        /* case #2:
   1.256 +         * browser.garage.maemo.org uses an invalid security certificate.
   1.257 +         *
   1.258 +         * The certificate is only valid for garage.maemo.org
   1.259 +         */
   1.260 +        if (endsWith(thisHost, "." + okHost))
   1.261 +          link.href = proto + okHost;
   1.262 +      }
   1.263 +      
   1.264 +      function endsWith(haystack, needle) {
   1.265 +        return haystack.slice(-needle.length) == needle;
   1.266 +      }
   1.267 +
   1.268 +    ]]></script>
   1.269 +  </head>
   1.270 +
   1.271 +  <body dir="&locale.dir;">
   1.272 +
   1.273 +    <!-- ERROR ITEM CONTAINER (removed during loading to avoid bug 39098) -->
   1.274 +    <div id="errorContainer">
   1.275 +      <div id="errorTitlesContainer">
   1.276 +        <h1 id="et_generic">&generic.title;</h1>
   1.277 +        <h1 id="et_dnsNotFound">&dnsNotFound.title;</h1>
   1.278 +        <h1 id="et_fileNotFound">&fileNotFound.title;</h1>
   1.279 +        <h1 id="et_malformedURI">&malformedURI.title;</h1>
   1.280 +        <h1 id="et_unknownProtocolFound">&unknownProtocolFound.title;</h1>
   1.281 +        <h1 id="et_connectionFailure">&connectionFailure.title;</h1>
   1.282 +        <h1 id="et_netTimeout">&netTimeout.title;</h1>
   1.283 +        <h1 id="et_redirectLoop">&redirectLoop.title;</h1>
   1.284 +        <h1 id="et_unknownSocketType">&unknownSocketType.title;</h1>
   1.285 +        <h1 id="et_netReset">&netReset.title;</h1>
   1.286 +        <h1 id="et_notCached">&notCached.title;</h1>
   1.287 +        <h1 id="et_netOffline">&netOffline.title;</h1>
   1.288 +        <h1 id="et_netInterrupt">&netInterrupt.title;</h1>
   1.289 +        <h1 id="et_deniedPortAccess">&deniedPortAccess.title;</h1>
   1.290 +        <h1 id="et_proxyResolveFailure">&proxyResolveFailure.title;</h1>
   1.291 +        <h1 id="et_proxyConnectFailure">&proxyConnectFailure.title;</h1>
   1.292 +        <h1 id="et_contentEncodingError">&contentEncodingError.title;</h1>
   1.293 +        <h1 id="et_unsafeContentType">&unsafeContentType.title;</h1>
   1.294 +        <h1 id="et_nssFailure2">&nssFailure2.title;</h1>
   1.295 +        <h1 id="et_nssBadCert">&nssBadCert.title;</h1>
   1.296 +        <h1 id="et_malwareBlocked">&malwareBlocked.title;</h1>
   1.297 +        <h1 id="et_cspFrameAncestorBlocked">&cspFrameAncestorBlocked.title;</h1>
   1.298 +        <h1 id="et_remoteXUL">&remoteXUL.title;</h1>
   1.299 +        <h1 id="et_corruptedContentError">&corruptedContentError.title;</h1>
   1.300 +      </div>
   1.301 +      <div id="errorDescriptionsContainer">
   1.302 +        <div id="ed_generic">&generic.longDesc;</div>
   1.303 +        <div id="ed_dnsNotFound">&dnsNotFound.longDesc;</div>
   1.304 +        <div id="ed_fileNotFound">&fileNotFound.longDesc;</div>
   1.305 +        <div id="ed_malformedURI">&malformedURI.longDesc;</div>
   1.306 +        <div id="ed_unknownProtocolFound">&unknownProtocolFound.longDesc;</div>
   1.307 +        <div id="ed_connectionFailure">&connectionFailure.longDesc;</div>
   1.308 +        <div id="ed_netTimeout">&netTimeout.longDesc;</div>
   1.309 +        <div id="ed_redirectLoop">&redirectLoop.longDesc;</div>
   1.310 +        <div id="ed_unknownSocketType">&unknownSocketType.longDesc;</div>
   1.311 +        <div id="ed_netReset">&netReset.longDesc;</div>
   1.312 +        <div id="ed_notCached">&notCached.longDesc;</div>
   1.313 +        <div id="ed_netOffline">&netOffline.longDesc2;</div>
   1.314 +        <div id="ed_netInterrupt">&netInterrupt.longDesc;</div>
   1.315 +        <div id="ed_deniedPortAccess">&deniedPortAccess.longDesc;</div>
   1.316 +        <div id="ed_proxyResolveFailure">&proxyResolveFailure.longDesc;</div>
   1.317 +        <div id="ed_proxyConnectFailure">&proxyConnectFailure.longDesc;</div>
   1.318 +        <div id="ed_contentEncodingError">&contentEncodingError.longDesc;</div>
   1.319 +        <div id="ed_unsafeContentType">&unsafeContentType.longDesc;</div>
   1.320 +        <div id="ed_nssFailure2">&nssFailure2.longDesc;</div>
   1.321 +        <div id="ed_nssBadCert">&nssBadCert.longDesc2;</div>
   1.322 +        <div id="ed_malwareBlocked">&malwareBlocked.longDesc;</div>
   1.323 +        <div id="ed_cspFrameAncestorBlocked">&cspFrameAncestorBlocked.longDesc;</div>
   1.324 +        <div id="ed_remoteXUL">&remoteXUL.longDesc;</div>
   1.325 +        <div id="ed_corruptedContentError">&corruptedContentError.longDesc;</div>
   1.326 +      </div>
   1.327 +    </div>
   1.328 +
   1.329 +    <!-- PAGE CONTAINER (for styling purposes only) -->
   1.330 +    <div id="errorPageContainer">
   1.331 +    
   1.332 +      <!-- Error Title -->
   1.333 +      <div id="errorTitle">
   1.334 +        <h1 id="errorTitleText" />
   1.335 +      </div>
   1.336 +      
   1.337 +      <!-- LONG CONTENT (the section most likely to require scrolling) -->
   1.338 +      <div id="errorLongContent">
   1.339 +      
   1.340 +        <!-- Short Description -->
   1.341 +        <div id="errorShortDesc">
   1.342 +          <p id="errorShortDescText" />
   1.343 +        </div>
   1.344 +
   1.345 +        <!-- Long Description (Note: See netError.dtd for used XHTML tags) -->
   1.346 +        <div id="errorLongDesc" />
   1.347 +
   1.348 +        <!-- Override section - For ssl errors only.  Removed on init for other
   1.349 +             error types.  -->
   1.350 +        <div id="securityOverrideDiv">
   1.351 +          <a id="securityOverrideLink" href="javascript:showSecuritySection();" >&securityOverride.linkText;</a>
   1.352 +          <div id="securityOverrideContent" style="display: none;">&securityOverride.warningContent;</div>
   1.353 +        </div>
   1.354 +      </div>
   1.355 +
   1.356 +      <!-- Retry Button -->
   1.357 +      <button id="errorTryAgain" autocomplete="off" onclick="retryThis(this);">&retry.label;</button>
   1.358 +      <script>
   1.359 +        // Only do autofocus if we're the toplevel frame; otherwise we
   1.360 +        // don't want to call attention to ourselves!  The key part is
   1.361 +        // that autofocus happens on insertion into the tree, so we
   1.362 +        // can remove the button, add @autofocus, and reinsert the
   1.363 +        // button.
   1.364 +        if (window.top == window) {
   1.365 +            var button = document.getElementById("errorTryAgain");
   1.366 +            var nextSibling = button.nextSibling;
   1.367 +            var parent = button.parentNode;
   1.368 +            parent.removeChild(button);
   1.369 +            button.setAttribute("autofocus", "true");
   1.370 +            parent.insertBefore(button, nextSibling);
   1.371 +        }
   1.372 +      </script>
   1.373 +
   1.374 +    </div>
   1.375 +
   1.376 +    <!--
   1.377 +    - Note: It is important to run the script this way, instead of using
   1.378 +    - an onload handler. This is because error pages are loaded as
   1.379 +    - LOAD_BACKGROUND, which means that onload handlers will not be executed.
   1.380 +    -->
   1.381 +    <script type="application/javascript">initPage();</script>
   1.382 +
   1.383 +  </body>
   1.384 +</html>

mercurial