toolkit/mozapps/update/tests/chrome/test_0122_check_allowNonBuiltinCert_validCertAttrs.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 <?xml version="1.0"?>
     2 <!--
     3 /* Any copyright is dedicated to the Public Domain.
     4  * http://creativecommons.org/publicdomain/zero/1.0/
     5  */
     6 -->
     8 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     9 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
    11 <window title="Test update check without requiring a certificate that is built-in and valid certificate attribute names and values"
    12         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    13         onload="runTestDefault();">
    14 <script type="application/javascript"
    15         src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    16 <script type="application/javascript"
    17         src="utils.js"/>
    19 <script type="application/javascript">
    20 <![CDATA[
    22 const TESTS = [ {
    23   pageid: PAGEID_CHECKING
    24 }, {
    25   pageid: PAGEID_FOUND_BASIC,
    26   buttonClick: "extra1"
    27 } ];
    29 Components.utils.import("resource://gre/modules/CertUtils.jsm");
    31 const CERT_ATTRS = ["nickname", "emailAddress", "subjectName", "commonName",
    32                     "organization", "organizationalUnit", "sha1Fingerprint",
    33                     "md5Fingerprint", "tokenName", "issuerName", "serialNumber",
    34                     "issuerCommonName", "issuerOrganization",
    35                     "issuerOrganizationUnit", "dbKey", "windowTitle"];
    37 var gRequest;
    39 function runTest() {
    40   debugDump("entering");
    42   gRequest = AUS_Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
    43              createInstance(AUS_Ci.nsIXMLHttpRequest);
    44   gRequest.open("GET", "https://example.com/", true);
    45   gRequest.channel.notificationCallbacks = new BadCertHandler(true);
    46   gRequest.onload = function(event) { testXHRLoad(event); };
    47   gRequest.onerror = function(event) { testXHRError(event); };
    48   gRequest.send(null);
    49 }
    51 function testXHRError(aEvent) {
    52   debugDump("entering");
    54   ok(true, "Entering testXHRError - something went wrong");
    56   var request = aEvent.target;
    57   var status = 0;
    58   try {
    59     status = request.status;
    60   }
    61   catch (e) {
    62   }
    64   if (status == 0)
    65     status = request.channel.QueryInterface(AUS_Ci.nsIRequest).status;
    67   ok(false, "XHR onerror called: " + status);
    69   gRequest = null;
    70   finishTestDefault();
    71 }
    73 function testXHRLoad(aEvent) {
    74   debugDump("entering");
    76   var channel = aEvent.target.channel;
    77   var cert = channel.securityInfo.QueryInterface(AUS_Ci.nsISSLStatusProvider).
    78              SSLStatus.QueryInterface(AUS_Ci.nsISSLStatus).serverCert;
    79   CERT_ATTRS.forEach(function(aCertAttrName) {
    80     Services.prefs.setCharPref(PREF_APP_UPDATE_CERTS_BRANCH + "1." +
    81                                aCertAttrName, cert[aCertAttrName]);
    82   });
    84   Services.prefs.setBoolPref(PREF_APP_UPDATE_CERT_REQUIREBUILTIN, false);
    85   Services.prefs.setBoolPref(PREF_APP_UPDATE_CERT_CHECKATTRS, true);
    87   let url = URL_HTTPS_UPDATE_XML + "?showDetails=1" + getVersionParams();
    88   gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL);
    89   debugDump("setting default pref " + PREF_APP_UPDATE_URL + " to " + url);
    90   gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url);
    92   gRequest = null;
    93   gUP.checkForUpdates();
    94 }
    96 function finishTest() {
    97   if (gRequest) {
    98     gRequest.abort();
    99     gRequest = null;
   100   }
   101   finishTestDefault();
   102 }
   104 ]]>
   105 </script>
   107 <body xmlns="http://www.w3.org/1999/xhtml">
   108   <p id="display"></p>
   109   <div id="content" style="display: none"></div>
   110   <pre id="test"></pre>
   111 </body>
   112 </window>

mercurial