Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-generateCertificate.html

Issue 2828563002: RTCCertificate.getFingerprints added (exposed to the web) (Closed)
Patch Set: Changed fingerprints to getFingerprints() as per pull request Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 description("Tests RTCPeerConnection.generateCertificate RSA/ECDSA."); 8 description("Tests RTCPeerConnection.generateCertificate RSA/ECDSA.");
9 9
10 // Constants 10 // Constants
11 var minuteInMs = 60 * 1000; 11 var minuteInMs = 60 * 1000;
12 var dayInMs = 24 * 60 * minuteInMs; 12 var dayInMs = 24 * 60 * minuteInMs;
13 13
14 // Signature of the last generateCertificate call. 14 // Signature of the last generateCertificate call.
15 var generateCallString = null; 15 var generateCallString = null;
16 // Global certificate variables so that the "should..." methods can evaluate the m. 16 // Global variables so that the "should..." methods can evaluate them.
17 var certRSA = null; 17 var certRSA = null;
18 var certECDSA = null; 18 var certECDSA = null;
19 var certExpiresNegativeOneDay = null; 19 var certExpiresNegativeOneDay = null;
20 var certExpiresZero = null; 20 var certExpiresZero = null;
21 var certExpiresPositiveOneDay = null; 21 var certExpiresPositiveOneDay = null;
22 var fingerprints = null;
22 23
23 // 1: RSA-2048 using public exponent = 65537. 24 // 1: RSA-2048 using public exponent = 65537.
24 function generate1RSA() 25 function generate1RSA()
25 { 26 {
26 generateCallString = 'generateCertificate({ name: "RSASSA-PKCS1-v1_5", modul usLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256" })'; 27 generateCallString = 'generateCertificate({ name: "RSASSA-PKCS1-v1_5", modul usLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256" })';
27 RTCPeerConnection.generateCertificate({ name: "RSASSA-PKCS1-v1_5", modulusLe ngth: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256" }) 28 RTCPeerConnection.generateCertificate({ name: "RSASSA-PKCS1-v1_5", modulusLe ngth: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256" })
28 .then(generate1RSASuccessful, generate1RSAFailed); 29 .then(generate1RSASuccessful, generate1RSAFailed);
29 } 30 }
30 function generate1RSASuccessful(certificate) 31 function generate1RSASuccessful(certificate)
31 { 32 {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 shouldBeTrue('Math.abs(certExpiresPositiveOneDay.expires - (new Date().getTi me() + dayInMs)) <= minuteInMs'); 95 shouldBeTrue('Math.abs(certExpiresPositiveOneDay.expires - (new Date().getTi me() + dayInMs)) <= minuteInMs');
95 96
96 finishJSTest(); 97 finishJSTest();
97 } 98 }
98 99
99 // Helper functions. 100 // Helper functions.
100 function certificateSanityCheck(certVariableName) 101 function certificateSanityCheck(certVariableName)
101 { 102 {
102 shouldBeNonNull(certVariableName); 103 shouldBeNonNull(certVariableName);
103 shouldBeTrue('new Date().getTime() < ' + certVariableName + '.expires'); 104 shouldBeTrue('new Date().getTime() < ' + certVariableName + '.expires');
105 shouldBeTrue(certVariableName + '.getFingerprints().length == 1');
106 shouldBeTrue(certVariableName + '.getFingerprints()[0].algorithm === "sha-25 6"');
107 shouldBeTrue('isFingerprintValue(' +
108 certVariableName + '.getFingerprints()[0].value)');
109
110 // The returned array is frozen and should not be modifiable.
111 fingerprints = eval(certVariableName + '.getFingerprints()');
112 shouldBeTrue('(function(){ fingerprints[0] = null; return fingerprints[0] != null; })()');
113 try {
114 fingerprints.push(null);
115 fail('Exception not thrown doing ' + fingerprints.push(null));
116 } catch (e) {
117 }
118 // The elements of the array should be modifiable.
119 shouldBeTrue('(function(){ fingerprints[0].value = "garbage"; return fingerp rints[0].value === "garbage"; })()');
120 // The certificate should always return fingerprint copies, not harmed by mo difications.
121 shouldBeTrue(certVariableName + '.getFingerprints()[0] != ' + certVariableNa me + '.getFingerprints()[0]');
122 }
123 function isFingerprintValue(fingerprint) {
124 // / Begin regex
125 // ^ Start of line
126 // (?: Non-capturing parenthesis
127 // [a-z0-9]{2} 2 lowercase alphanumeric characters
128 // \: The : character
129 // )+ End of parenthesis, match 1 or more times
130 // [a-z0-9]{2} 2 lowercase alphanumeric characters
131 // $ End of line
132 // / End of regex
133 return /^(?:[a-z0-9]{2}\:)+[a-z0-9]{2}$/.test(fingerprint);
104 } 134 }
105 135
106 // Run each generate test sequentially. The ith generate method will make sure 136 // Run each generate test sequentially. The ith generate method will make sure
107 // the (i+1)st generate method is executed when its promise's callbacks are 137 // the (i+1)st generate method is executed when its promise's callbacks are
108 // invoked. generate2ECDSA's callback methods mark the end of the async tests. 138 // invoked. generate2ECDSA's callback methods mark the end of the async tests.
109 generate1RSA(); 139 generate1RSA();
110 140
111 window.jsTestIsAsync = true; 141 window.jsTestIsAsync = true;
112 window.successfullyParsed = true; 142 window.successfullyParsed = true;
113 </script> 143 </script>
114 </body> 144 </body>
115 </html> 145 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698