|
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 --> |
|
7 |
|
8 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
9 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
|
10 |
|
11 <window title="Test update check with certificate that is not 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"/> |
|
18 |
|
19 <script type="application/javascript"> |
|
20 <![CDATA[ |
|
21 |
|
22 const TESTS = [ { |
|
23 pageid: PAGEID_CHECKING |
|
24 }, { |
|
25 pageid: PAGEID_ERRORS, |
|
26 buttonClick: "finish" |
|
27 } ]; |
|
28 |
|
29 Components.utils.import("resource://gre/modules/CertUtils.jsm"); |
|
30 |
|
31 const CERT_ATTRS = ["nickname", "emailAddress", "subjectName", "commonName", |
|
32 "organization", "organizationalUnit", "sha1Fingerprint", |
|
33 "md5Fingerprint", "tokenName", "issuerName", "serialNumber", |
|
34 "issuerCommonName", "issuerOrganization", |
|
35 "issuerOrganizationUnit", "dbKey", "windowTitle"]; |
|
36 |
|
37 var gRequest; |
|
38 |
|
39 function runTest() { |
|
40 debugDump("entering"); |
|
41 |
|
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 } |
|
50 |
|
51 function testXHRError(aEvent) { |
|
52 debugDump("entering"); |
|
53 |
|
54 ok(true, "Entering testXHRError - something went wrong"); |
|
55 |
|
56 var request = aEvent.target; |
|
57 var status = 0; |
|
58 try { |
|
59 status = request.status; |
|
60 } |
|
61 catch (e) { |
|
62 } |
|
63 |
|
64 if (status == 0) |
|
65 status = request.channel.QueryInterface(AUS_Ci.nsIRequest).status; |
|
66 |
|
67 ok(false, "XHR onerror called: " + status); |
|
68 |
|
69 gRequest = null; |
|
70 finishTestDefault(); |
|
71 } |
|
72 |
|
73 function testXHRLoad(aEvent) { |
|
74 debugDump("entering"); |
|
75 |
|
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 }); |
|
83 |
|
84 Services.prefs.setBoolPref(PREF_APP_UPDATE_CERT_REQUIREBUILTIN, true); |
|
85 Services.prefs.setBoolPref(PREF_APP_UPDATE_CERT_CHECKATTRS, false); |
|
86 |
|
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); |
|
91 |
|
92 gRequest = null; |
|
93 gUP.checkForUpdates(); |
|
94 } |
|
95 |
|
96 function finishTest() { |
|
97 if (gRequest) { |
|
98 gRequest.abort(); |
|
99 gRequest = null; |
|
100 } |
|
101 finishTestDefault(); |
|
102 } |
|
103 |
|
104 ]]> |
|
105 </script> |
|
106 |
|
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> |